Unix build improvement (build tool detection).
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2535 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+3
-1
@@ -1,4 +1,6 @@
|
||||
Changes towards version 0.6:
|
||||
- Unix build scripts improvements. - SvdB
|
||||
- Build fixes for MacOS X (with thanks to Nic) - SvdB
|
||||
=======
|
||||
- Ships in battle can resume normal speed in all circumstances after
|
||||
the enemy Avatar's tractor beam disengages (bug #860; this is a
|
||||
netplay desynchronizing change) - Alex
|
||||
|
||||
+5
-5
@@ -18,11 +18,11 @@ endef
|
||||
endif
|
||||
|
||||
define act_mkdep_c
|
||||
$(MKDEPEND) $(CFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
|
||||
$(MKDEP_C) $(CFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
|
||||
endef
|
||||
|
||||
define act_mkdep_m
|
||||
$(MKDEPEND) $(CFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
|
||||
$(MKDEP_OBJC) $(CFLAGS) "$<" -MT "$(@D)/$(<F).o" -MF "$@"
|
||||
endef
|
||||
|
||||
define act_windres
|
||||
@@ -30,15 +30,15 @@ define act_windres
|
||||
endef
|
||||
|
||||
define act_cc
|
||||
$(COMPILE) -o "$@" -c $(CFLAGS) "$<"
|
||||
$(COMPILE_C) -o "$@" $(CFLAGS) "$<"
|
||||
endef
|
||||
|
||||
define act_objcc
|
||||
$(COMPILE) -o "$@" -c $(CFLAGS) "$<"
|
||||
$(COMPILE_OBJC) -o "$@" $(CFLAGS) "$<"
|
||||
endef
|
||||
|
||||
define act_link
|
||||
$(COMPILE) -o "$@" $^ $(LDFLAGS)
|
||||
$(LINK) -o "$@" $^ $(LDFLAGS)
|
||||
endef
|
||||
|
||||
|
||||
|
||||
+7
-2
@@ -17,8 +17,13 @@
|
||||
|
||||
BUILD_SYSTEM='@BUILD_SYSTEM@'
|
||||
HOST_SYSTEM='@HOST_SYSTEM@'
|
||||
COMPILE='@COMPILE@'
|
||||
MKDEPEND='@COMPILE@ -MM'
|
||||
PREPROC_C='@PREPROC_C@'
|
||||
MKDEP_C='@MKDEP_C@'
|
||||
COMPILE_C='@COMPILE_C@'
|
||||
PREPROC_OBJC='@PREPROC_OBJC@'
|
||||
MKDEP_OBJC='@MKDEP_OBJC@'
|
||||
COMPILE_OBJC='@COMPILE_OBJC@'
|
||||
LINK='@LINK@'
|
||||
MAKE='@MAKE@'
|
||||
ECHON='@ECHON@'
|
||||
SED='@SED@'
|
||||
|
||||
+10
-10
@@ -9,17 +9,15 @@
|
||||
uqm_requirements()
|
||||
{
|
||||
# Some requirements:
|
||||
have_program gcc || exit 1
|
||||
COMPILE="$PROG_gcc_FILE"
|
||||
|
||||
have_build_tools_language C || exit 1
|
||||
have_build_tool LINK || exit 1
|
||||
case "$HOST_SYSTEM" in
|
||||
MINGW32*)
|
||||
have_program windres
|
||||
WINDRES="$PROG_windres_FILE"
|
||||
have_build_tool WINDRES || exit 1
|
||||
;;
|
||||
Darwin)
|
||||
have_program Rez || exit 1
|
||||
REZ="$PROG_Rez_FILE"
|
||||
have_build_tools_language OBJC || exit 1
|
||||
have_build_tool REZ || exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -343,7 +341,9 @@ uqm_process_config() {
|
||||
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES src "$BUILD_WORK"
|
||||
|
||||
# Make build.vars from build.vars.in, substituting variables.
|
||||
SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM COMPILE CFLAGS LDFLAGS \
|
||||
SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM CFLAGS LDFLAGS LINK \
|
||||
PREPROC_C MKDEP_C COMPILE_C \
|
||||
PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC \
|
||||
MAKE ECHON SED DEBUG JOYSTICK NETPLAY \
|
||||
SOUNDMODULE USE_INTERNAL_MIKMOD \
|
||||
HAVE_OPENGL HAVE_REGEX_H_FLAG USE_ZIP_IO \
|
||||
@@ -389,7 +389,7 @@ uqm_post_build() {
|
||||
# the resource fork, in fact)
|
||||
case "$HOST_SYSTEM" in
|
||||
Darwin)
|
||||
${REZ} ${RFORK} -o ${TARGET_FILE}
|
||||
$REZ "$RFORK" -o "$TARGET_FILE"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -449,7 +449,7 @@ uqm_install_osx() {
|
||||
for HEADER in $HEADERS; do
|
||||
HEADER_FILE=`basename $HEADER`
|
||||
eval FRAMEWORK=`echo '' | \
|
||||
$COMPILE -E -D__MACOSX__ -include $HEADER - | \
|
||||
$PREPROC_C -D__MACOSX__ -include $HEADER - | \
|
||||
awk '(/'$HEADER_FILE'/ && $2 == 1) { print $3; exit }' | \
|
||||
$SED 's/.Headers.*$/"/'`
|
||||
cp -r "$FRAMEWORK" "$INSTROOT/Frameworks"
|
||||
|
||||
@@ -18,8 +18,9 @@ The files
|
||||
|
||||
These are the files in the directory with the build script.
|
||||
Of these files only build.config should be modified for a specific build.
|
||||
For unknown dependencies, additions to config_proginfo might need to be
|
||||
made. The other files should not be modified.
|
||||
For unknown dependencies, additions to config_proginfo_build or
|
||||
config_proginfo_host might need to be made. The other files should not
|
||||
be modified.
|
||||
Only build.sh is to be called directly.
|
||||
|
||||
ansi ansi colour definitions.
|
||||
@@ -114,8 +115,8 @@ There are three types of menu items.
|
||||
|
||||
|
||||
|
||||
Program info (from config_proginfo)
|
||||
-----------------------------------
|
||||
Program info (from config_proginfo_build)
|
||||
-----------------------------------------
|
||||
|
||||
Information about programs used should be supplied in the following form:
|
||||
- PROG_${PROGRAM}_NAME
|
||||
@@ -148,9 +149,26 @@ Information about programs used should be supplied in the following form:
|
||||
1 if the program has been verified to be not present
|
||||
<empty> if presence of the program hasn't been verified
|
||||
|
||||
Information about build tools in general (say "a C compiler"), where you're
|
||||
not interested in what program is actually called, should be supplied in
|
||||
the following corm:
|
||||
- BUILDTOOL_${TOOL}_NAME
|
||||
A string describing the build tool.
|
||||
- BUILDTOOL_${TOOL}_COMMAND
|
||||
The command, with arguments, that is to be executed to run this tool.
|
||||
- BUILDTOOL_${TOOL}_DEPEND
|
||||
A whitespace separated list of programs (as described above)
|
||||
that this tool depends on.
|
||||
- BUILDTOOL_${TOOL}_PRESENT (set by the configuration program)
|
||||
0 if the tool has been verified to be present
|
||||
1 if the tool has been verified to be not present
|
||||
<empty> if presence of the tool hasn't been verified
|
||||
Each tool described, once detected, will be available through the environment
|
||||
variable with the name as specified in $TOOL.
|
||||
|
||||
Library info (from config_proginfo)
|
||||
-----------------------------------
|
||||
|
||||
Library info (from config_proginfo_host)
|
||||
-----------------------------------------
|
||||
|
||||
Information about libraries used should be supplied in the following form:
|
||||
- LIB_${LIB}_NAME
|
||||
|
||||
@@ -79,7 +79,8 @@ if [ -z "$TARGET" ]; then
|
||||
exit 1
|
||||
fi
|
||||
BUILD_PROJECT="$TARGET"
|
||||
export TARGET BUILD_PROJECT COMPILE MKDEPEND ECHON
|
||||
export TARGET BUILD_PROJECT ECHON
|
||||
export PREPROC_C MKDEP_C COMPILE_C PREPROC_OBJC MKDEP_OBJC COMPILE_OBJC LINK
|
||||
export "${BUILD_PROJECT}_CFLAGS" "${BUILD_PROJECT}_LDFLAGS"
|
||||
|
||||
# Add trailing / from objs dir
|
||||
|
||||
+114
-21
@@ -15,8 +15,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
BUILDLOG=/dev/null
|
||||
BUILDLOG=/tmp/build.log
|
||||
TEMPFILE="/tmp/build.$$.tmp"
|
||||
#KEEPTEMPFILES=keeptempfiles
|
||||
|
||||
|
||||
# Description: perform a command, and set the exit status to the opposite.
|
||||
@@ -74,29 +75,51 @@ $RESULT
|
||||
EOF
|
||||
}
|
||||
|
||||
# Description: delete the files passed as arguments, unless
|
||||
# $KEEPTEMPFILES is set.
|
||||
deleteTempFiles() {
|
||||
if [ -n "$KEEPTEMPFILES" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
rm -f -- "$@"
|
||||
}
|
||||
|
||||
# Description: read text from stdin to use as a c file to compile
|
||||
# Arguments: $1 - CFLAGS to use for compilation (optional)
|
||||
# $2 - LDFLAGS to use for linking (optional)
|
||||
# Returns: 0 - if compile successful
|
||||
# something else - if compile failed
|
||||
try_compile_c() {
|
||||
local SYSTEM_FLAGS
|
||||
if [ -z "$COMPILE" ]; then
|
||||
echo "Fatal: Program \$COMPILE is not defined!" >&2
|
||||
local SYSTEM_FLAGS RESULT
|
||||
|
||||
if [ -z "$COMPILE_C" ]; then
|
||||
echo "Fatal: Program \$COMPILE_C is not defined!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SYSTEM_FLAGS="$SYSTEM_BUILD_CFLAGS $SYSTEM_BUILD_LDFLAGS $SYSTEM_HOST_CFLAGS $SYSTEM_HOST_LDFLAGS"
|
||||
cat > "$TEMPFILE.c"
|
||||
echo_and_perform $COMPILE $SYSTEM_FLAGS $1 $2 "$TEMPFILE.c" \
|
||||
-o "$TEMPFILE.out" >> "$BUILDLOG" 2>&1
|
||||
|
||||
echo_and_perform $COMPILE_C $SYSTEM_FLAGS $1 "$TEMPFILE.c" \
|
||||
-o "$TEMPFILE.c.o" >> "$BUILDLOG" 2>&1
|
||||
RESULT=$?
|
||||
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
echo_and_perform $LINK $SYSTEM_FLAGS $2 "$TEMPFILE.c.o" \
|
||||
-o "$TEMPFILE.out" >> "$BUILDLOG" 2>&1
|
||||
RESULT=$?
|
||||
fi
|
||||
|
||||
if [ $RESULT -ne 0 ]; then
|
||||
echo "Failed program was:" >> "$BUILDLOG"
|
||||
echo "+++ START $TEMPFILE.c" >> "$BUILDLOG"
|
||||
cat "$TEMPFILE.c" >> "$BUILDLOG"
|
||||
echo "+++ END $TEMPFILE.c" >> "$BUILDLOG"
|
||||
fi
|
||||
rm -f "$TEMPFILE.c" "$TEMPFILE.out"
|
||||
|
||||
deleteTempFiles "$TEMPFILE.c $TEMPFILE.c.o $TEMPFILE.out"
|
||||
|
||||
echo >> "$BUILDLOG"
|
||||
return $RESULT
|
||||
}
|
||||
@@ -104,25 +127,36 @@ try_compile_c() {
|
||||
# Description: read text from stdin to use as a c file to compile
|
||||
# Arguments: $1 - CFLAGS to use for compilation (optional)
|
||||
# $2 - LDFLAGS to use for linking (optional)
|
||||
# Returns: -1 - if compile failed
|
||||
# Returns: 128 - if compiling or linking failed
|
||||
# otherwise - exit status of the program
|
||||
try_compile_and_run_c() {
|
||||
local SYSTEM_FLAGS
|
||||
if [ -z "$COMPILE" ]; then
|
||||
echo "Fatal: Program \$COMPILE is not defined!" >&2
|
||||
local SYSTEM_FLAGS RESULT
|
||||
|
||||
if [ -z "$COMPILE_C" ]; then
|
||||
echo "Fatal: Program \$COMPILE_C is not defined!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SYSTEM_FLAGS="$SYSTEM_BUILD_CFLAGS $SYSTEM_BUILD_LDFLAGS $SYSTEM_HOST_CFLAGS $SYSTEM_HOST_LDFLAGS"
|
||||
cat > "$TEMPFILE.c"
|
||||
echo_and_perform $COMPILE $SYSTEM_FLAGS $1 $2 "$TEMPFILE.c" \
|
||||
-o "$TEMPFILE.out" >> "$BUILDLOG" 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
return -1
|
||||
fi
|
||||
rm -f -- "$TEMPFILE.c"
|
||||
"$TEMPFILE.out"
|
||||
|
||||
echo_and_perform $COMPILE_C $SYSTEM_FLAGS $1 "$TEMPFILE.c" \
|
||||
-o "$TEMPFILE.c.o" >> "$BUILDLOG" 2>&1
|
||||
RESULT=$?
|
||||
rm -f -- "$TEMPFILE.out"
|
||||
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
echo_and_perform $LINK $SYSTEM_FLAGS $2 "$TEMPFILE.c.o" \
|
||||
-o "$TEMPFILE.out" >> "$BUILDLOG" 2>&1
|
||||
RESULT=$?
|
||||
fi
|
||||
|
||||
if [ $RESULT -eq 0 ]; then
|
||||
"$TEMPFILE.out"
|
||||
RESULT=$?
|
||||
fi
|
||||
|
||||
deleteTempFiles "$TEMPFILE.c $TEMPFILE.c.o $TEMPFILE.out"
|
||||
|
||||
echo >> "$BUILDLOG"
|
||||
return $RESULT
|
||||
}
|
||||
@@ -268,7 +302,8 @@ detect_dependencies_library() {
|
||||
}
|
||||
|
||||
# Description: check if a program is present in the path
|
||||
# Arguments:
|
||||
# Arguments: $1 - The name of the program as used in config_proginfo after
|
||||
# "BIN_"
|
||||
have_program() {
|
||||
local PROG TEMP_NAME TEMP_FILE TEMP_VERSION TEMP_PRESENT TEMP_DETECT
|
||||
local TEMP_DEPEND_DETECT_PROG TEMP_DEPEND_DETECT_LIB
|
||||
@@ -347,6 +382,64 @@ but version $2 is required!"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Description: check if a build tool is present, and define the appropriate
|
||||
# environment variable for it.
|
||||
# Arguments: $1 - The type of compile tool. One of PREPROC_C, MKDEP_C,
|
||||
# COMPILE_C, PREPROC_OBJC, MKDEP_OBJC, COMPILE_OBJC,
|
||||
# and LINK.
|
||||
have_build_tool() {
|
||||
local TOOL TEMP_NAME TEMP_PRESENT DEPENDS DEPEND SUCCESS COMMAND
|
||||
|
||||
TOOL=$1
|
||||
|
||||
TEMP_NAME=`evalVar BUILDTOOL_${TOOL}_NAME`
|
||||
if [ -z "$TEMP_NAME" ]; then
|
||||
echo "Fatal: Program '$TOOL' is not defined!" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval TEMP_PRESENT="\$BUILDTOOL_${TOOL}_PRESENT"
|
||||
if [ -n "$TEMP_PRESENT" ]; then
|
||||
return "$TEMP_PRESENT"
|
||||
fi
|
||||
|
||||
SUCCESS=0
|
||||
eval DEPENDS="\$BUILDTOOL_${TOOL}_DEPEND"
|
||||
for DEPEND in $DEPENDS; do
|
||||
if not have_program "$DEPEND"; then
|
||||
SUCCESS=1
|
||||
fi
|
||||
done
|
||||
|
||||
eval "BUILDTOOL_${TOOL}_PRESENT"="\$SUCCESS"
|
||||
|
||||
eval COMMAND="\$BUILDTOOL_${TOOL}_COMMAND"
|
||||
# Expand environment variables in $COMMAND:
|
||||
eval COMMAND=\"$COMMAND\"
|
||||
|
||||
if [ $SUCCESS -eq 0 ]; then
|
||||
build_message "We have a $TEMP_NAME."
|
||||
eval "${TOOL}"="\$COMMAND"
|
||||
else
|
||||
build_message "No $TEMP_NAME found."
|
||||
fi
|
||||
|
||||
return $SUCCESS
|
||||
}
|
||||
|
||||
have_build_tools_language() {
|
||||
local LANGUAGE
|
||||
|
||||
LANGUAGE=$1
|
||||
|
||||
have_build_tool "PREPROC_$LANGUAGE" || return 1
|
||||
have_build_tool "MKDEP_$LANGUAGE" || return 1
|
||||
have_build_tool "COMPILE_$LANGUAGE" || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# Description: check if a library is present on the system
|
||||
# Arguments: $1 - The name of the library as used in config_proginfo after
|
||||
# "LIB_"
|
||||
@@ -832,7 +925,7 @@ EOF
|
||||
# The copy is done so that the file modes are equal.
|
||||
$SED -f "${TEMPFILE}.sed" < "$SRC_PATH/$FILE".in > "$DST_PATH/$FILE"
|
||||
done
|
||||
rm -- "${TEMPFILE}.sed"
|
||||
deleteTempFiles "${TEMPFILE}.sed"
|
||||
}
|
||||
|
||||
# Define the build system type.
|
||||
|
||||
@@ -29,6 +29,61 @@ SYSTEM_BUILD_CFLAGS=""
|
||||
# LDFLAGS
|
||||
SYSTEM_BUILD_LDFLAGS=""
|
||||
|
||||
# Compilers etc.
|
||||
BUILDTOOL_PREPROC_C_NAME="C preprocessor"
|
||||
BUILDTOOL_MKDEP_C_NAME="C dependency generator"
|
||||
BUILDTOOL_COMPILE_C_NAME="C compiler"
|
||||
BUILDTOOL_PREPROC_OBJC_NAME="Objective-C preprocessor"
|
||||
BUILDTOOL_MKDEP_OBJC_NAME="Objective-C dependency generator"
|
||||
BUILDTOOL_COMPILE_OBJC_NAME="Objective-C compiler"
|
||||
BUILDTOOL_LINK_NAME="linker"
|
||||
useGccBuildTools() {
|
||||
# These strings will be evaluated later.
|
||||
BUILDTOOL_PREPROC_C_COMMAND="\$PROG_gcc_FILE -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_C"
|
||||
BUILDTOOL_PREPROC_C_DEPEND='gcc'
|
||||
|
||||
BUILDTOOL_MKDEP_C_COMMAND="\$PROG_gcc_FILE -MM $EXTRA_PLATFORM_GCC_FLAGS_MKDEP_C"
|
||||
BUILDTOOL_MKDEP_C_DEPEND='gcc'
|
||||
|
||||
BUILDTOOL_COMPILE_C_COMMAND="\$PROG_gcc_FILE -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C"
|
||||
BUILDTOOL_COMPILE_C_DEPEND='gcc'
|
||||
|
||||
BUILDTOOL_PREPROC_OBJC_COMMAND="\$PROG_gcc_FILE -E $EXTRA_PLATFORM_GCC_FLAGS_PREPROC_OBJC"
|
||||
BUILDTOOL_PREPROC_OBJC_DEPEND='gcc'
|
||||
|
||||
BUILDTOOL_MKDEP_OBJC_COMMAND="\$PROG_gcc_FILE -MF $EXTRA_PLATFORM_GCC_FLAGS_MKDEP_OBJC"
|
||||
BUILDTOOL_MKDEP_OBJC_DEPEND='gcc'
|
||||
|
||||
BUILDTOOL_COMPILE_OBJC_COMMAND="\$PROG_gcc_FILE -c $EXTRA_PLATFORM_GCC_FLAGS_COMPILE_OBJC"
|
||||
BUILDTOOL_COMPILE_OBJC_DEPEND='gcc'
|
||||
|
||||
BUILDTOOL_LINK_COMMAND="\$PROG_gcc_FILE $EXTRA_PLATFORM_GCC_LINK_FLAGS"
|
||||
BUILDTOOL_LINK_DEPEND='gcc'
|
||||
}
|
||||
case "$BUILD_SYSTEM" in
|
||||
Darwin)
|
||||
EXTRA_PLATFORM_GCC_FLAGS_COMPILE_C='-arch ppc -arch i386'
|
||||
EXTRA_PLATFORM_GCC_FLAGS_COMPILE_OBJC='-arch ppc -arch i386'
|
||||
EXTRA_PLATFORM_GCC_FLAGS_LINK='-arch ppc -arch i386'
|
||||
useGccBuildTools
|
||||
;;
|
||||
*)
|
||||
useGccBuildTools
|
||||
;;
|
||||
esac
|
||||
case "$BUILD_SYSTEM" in
|
||||
Darwin)
|
||||
BUILDTOOL_REZ_NAME="MacOS X resource compiler (Rez)"
|
||||
BUILDTOOL_REZ='$PROG_Rez_FILE'
|
||||
BUILDTOOL_REZ_DEPEND='Rez'
|
||||
;;
|
||||
MINGW32*|CYGWIN*)
|
||||
BUILDTOOL_WINDRES_NAME="Windows resource linker (windres)"
|
||||
BUILDTOOL_WINDRES='$PROG_windres_FILE'
|
||||
BUILDTOOL_WINDRES_DEPEND='windres'
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Describe the programs (possibly) used: #
|
||||
|
||||
Reference in New Issue
Block a user