Allow compilation in an other directory on unix, keeping the source tree
clean, by setting the BUILD_WORK environment variable. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1333 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
Changes towards version 0.4:
|
Changes towards version 0.4:
|
||||||
|
- Unix build: Make it possible to use another directory than the current
|
||||||
|
one for putting the build data in (such as build.vars, config.state,
|
||||||
|
the obj/ dir, and the final binary). - SvdB
|
||||||
- Fixed various odd behaviors when loading from HyperSpace (bug #587),
|
- Fixed various odd behaviors when loading from HyperSpace (bug #587),
|
||||||
from Nic and Michael
|
from Nic and Michael
|
||||||
- Added new 'triscan' scaler; derived from scale2x[.sf.net] -Alex
|
- Added new 'triscan' scaler; derived from scale2x[.sf.net] -Alex
|
||||||
|
|||||||
+4
-2
@@ -21,6 +21,8 @@ target-%:
|
|||||||
-include $(DEPEND_FILE)
|
-include $(DEPEND_FILE)
|
||||||
|
|
||||||
# Temporary:
|
# Temporary:
|
||||||
obj/release/./src/res/UrQuanMasters.rc.o: ./src/res/UrQuanMasters.rc
|
$(BUILD_WORK)/obj/release/./src/res/UrQuanMasters.rc.o:\
|
||||||
obj/debug/./src/res/UrQuanMasters.rc.o: ./src/res/UrQuanMasters.rc
|
./src/res/UrQuanMasters.rc
|
||||||
|
$(BUILD_WORK)/obj/debug/./src/res/UrQuanMasters.rc.o: \
|
||||||
|
./src/res/UrQuanMasters.rc
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -14,7 +14,7 @@ uqm_CFLAGS="$uqm_CFLAGS -I src -I src/sc2code -I src/sc2code/libs"
|
|||||||
# Stuff to install under the directory for libraries, as specified during
|
# Stuff to install under the directory for libraries, as specified during
|
||||||
# config.
|
# config.
|
||||||
uqm_INSTALL_LIBS="executable"
|
uqm_INSTALL_LIBS="executable"
|
||||||
uqm_INSTALL_LIB_executable_SRC="$uqm_NAME"
|
uqm_INSTALL_LIB_executable_SRC="$BUILD_WORK/$uqm_NAME"
|
||||||
uqm_INSTALL_LIB_executable_DEST=uqm/uqm
|
uqm_INSTALL_LIB_executable_DEST=uqm/uqm
|
||||||
uqm_INSTALL_LIB_executable_MODE="0755"
|
uqm_INSTALL_LIB_executable_MODE="0755"
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ uqm_INSTALL_SHARED_content_MODE="go+rX"
|
|||||||
# Stuff to install under the directory for binaries, as specified during
|
# Stuff to install under the directory for binaries, as specified during
|
||||||
# config.
|
# config.
|
||||||
uqm_INSTALL_BINS=wrapper
|
uqm_INSTALL_BINS=wrapper
|
||||||
uqm_INSTALL_BIN_wrapper_SRC="build/unix/uqm"
|
uqm_INSTALL_BIN_wrapper_SRC="$BUILD_WORK/uqm-wrapper"
|
||||||
uqm_INSTALL_BIN_wrapper_DEST="uqm"
|
uqm_INSTALL_BIN_wrapper_DEST="uqm"
|
||||||
uqm_INSTALL_BIN_wrapper_MODE="0755"
|
uqm_INSTALL_BIN_wrapper_MODE="0755"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -z "$BUILD_WORK" ]; then
|
||||||
|
BUILD_WORK=.
|
||||||
|
fi
|
||||||
|
|
||||||
# Include build functions used here
|
# Include build functions used here
|
||||||
. build/unix/config_functions
|
. build/unix/config_functions
|
||||||
. build/unix/menu_functions
|
. build/unix/menu_functions
|
||||||
@@ -182,7 +186,7 @@ INPUT_install_sharedir_VALIDATOR=validate_path
|
|||||||
|
|
||||||
|
|
||||||
# Show the menu and let people set things
|
# Show the menu and let people set things
|
||||||
do_menu MENU main config.state
|
do_menu MENU main "$BUILD_WORK/config.state"
|
||||||
echo "Configuration complete."
|
echo "Configuration complete."
|
||||||
|
|
||||||
# Set INSTALL_LIBDIR, INSTALL_BINDIR, and INSTALL_SHAREDIR to the specified
|
# Set INSTALL_LIBDIR, INSTALL_BINDIR, and INSTALL_SHAREDIR to the specified
|
||||||
@@ -197,22 +201,23 @@ prefix="$INPUT_install_prefix_VALUE" \
|
|||||||
# Set the content dir
|
# Set the content dir
|
||||||
CONTENTDIR="${INSTALL_SHAREDIR}uqm/content"
|
CONTENTDIR="${INSTALL_SHAREDIR}uqm/content"
|
||||||
|
|
||||||
|
CFLAGS="$CFLAGS -I \"$BUILD_WORK\""
|
||||||
|
|
||||||
# Export the HAVE_ symbols to config.h, using config.h.in as template
|
# Export the HAVE_ symbols to config_unix.h, using config_unix.h.in as template
|
||||||
SUBSTITUTE_VARS="$HAVE_SYMBOLS CONTENTDIR"
|
SUBSTITUTE_VARS="$HAVE_SYMBOLS CONTENTDIR"
|
||||||
SUBSTITUTE_FILES="src/config.h"
|
SUBSTITUTE_FILES="config_unix.h"
|
||||||
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES
|
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES src "$BUILD_WORK"
|
||||||
|
|
||||||
# Make build.vars from build.vars.in, substituting variables.
|
# Make build.vars from build.vars.in, substituting variables.
|
||||||
SUBSTITUTE_VARS="CFLAGS LDFLAGS MAKE DEBUG SOUNDMODULE HAVE_OPENGL \
|
SUBSTITUTE_VARS="CFLAGS LDFLAGS MAKE DEBUG SOUNDMODULE HAVE_OPENGL \
|
||||||
USE_ZIP_IO \
|
USE_ZIP_IO \
|
||||||
INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR WINDRES"
|
INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR WINDRES"
|
||||||
SUBSTITUTE_FILES="build.vars"
|
SUBSTITUTE_FILES="build.vars"
|
||||||
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES
|
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES . "$BUILD_WORK"
|
||||||
|
|
||||||
# Make 'uqm' shell script from build.vars.in, substituting variables.
|
# Make 'uqm' shell script from build.vars.in, substituting variables.
|
||||||
SUBSTITUTE_VARS="INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR uqm_NAME"
|
SUBSTITUTE_VARS="INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR uqm_NAME"
|
||||||
SUBSTITUTE_FILES="build/unix/uqm"
|
SUBSTITUTE_FILES="uqm-wrapper"
|
||||||
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES
|
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES build/unix "$BUILD_WORK"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,14 @@
|
|||||||
# Read in the functions we need
|
# Read in the functions we need
|
||||||
. build/unix/build_functions
|
. build/unix/build_functions
|
||||||
|
|
||||||
|
if [ -z "$BUILD_WORK" ]; then
|
||||||
|
BUILD_WORK=.
|
||||||
|
fi
|
||||||
|
|
||||||
# Read in the config settings that affect the build, if present.
|
# Read in the config settings that affect the build, if present.
|
||||||
# Don't reread for every dir when recursing.
|
# Don't reread for every dir when recursing.
|
||||||
if [ -e build.vars -a -z "$BUILD_COMMAND" ]; then
|
if [ -e "$BUILD_WORK/build.vars" -a -z "$BUILD_COMMAND" ]; then
|
||||||
. ./build.vars
|
. "$BUILD_WORK/build.vars"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Read in the Makeinfo file for the dir currently being processed
|
# Read in the Makeinfo file for the dir currently being processed
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ build_do_recursive() {
|
|||||||
|
|
||||||
# Build dependancy information for one file
|
# Build dependancy information for one file
|
||||||
build_dependancies() {
|
build_dependancies() {
|
||||||
eval echo -n \${${BUILD_PROJECT}_OBJS}\$BUILD_REC_PATH
|
eval echo -n \$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\$BUILD_REC_PATH
|
||||||
eval \$MKDEPEND "\${${BUILD_PROJECT}_CFLAGS}" "\$1"
|
eval \$MKDEPEND "\${${BUILD_PROJECT}_CFLAGS}" "\$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,9 +80,9 @@ build_rec_dependancies() {
|
|||||||
BUILD_FILES_VAR=${BUILD_PROJECT}_CFILES
|
BUILD_FILES_VAR=${BUILD_PROJECT}_CFILES
|
||||||
OFILES=`build_do_recursive build_collect_o_files :`
|
OFILES=`build_do_recursive build_collect_o_files :`
|
||||||
|
|
||||||
eval DEPEND_FILE=".depend.\${${BUILD_PROJECT}_NAME}"
|
eval DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME}"
|
||||||
{
|
{
|
||||||
eval echo -n "target-\${${BUILD_PROJECT}_NAME}:"
|
eval echo -n "\$BUILD_WORK/target-\${${BUILD_PROJECT}_NAME}:"
|
||||||
for OFILE in $OFILES $EXTRA_OFILES; do
|
for OFILE in $OFILES $EXTRA_OFILES; do
|
||||||
echo -n " $OFILE"
|
echo -n " $OFILE"
|
||||||
done
|
done
|
||||||
@@ -93,12 +93,12 @@ build_rec_dependancies() {
|
|||||||
|
|
||||||
# Output the .o file for a .c file.
|
# Output the .o file for a .c file.
|
||||||
build_collect_o_files() {
|
build_collect_o_files() {
|
||||||
eval echo "\${${BUILD_PROJECT}_OBJS}\${1%.c}.o"
|
eval echo "\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\${1%.c}.o"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output the extra .o file with the complete path
|
# Output the extra .o file with the complete path
|
||||||
build_collect_extra_o_files() {
|
build_collect_extra_o_files() {
|
||||||
eval echo "\${${BUILD_PROJECT}_OBJS}\$1"
|
eval echo "\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Recursively collect .o-files
|
# Recursively collect .o-files
|
||||||
@@ -123,25 +123,26 @@ build_config() {
|
|||||||
build_compile() {
|
build_compile() {
|
||||||
eval CFLAGS="\${${BUILD_PROJECT}_CFLAGS}" \
|
eval CFLAGS="\${${BUILD_PROJECT}_CFLAGS}" \
|
||||||
LDFLAGS="\${${BUILD_PROJECT}_LDFLAGS}" \
|
LDFLAGS="\${${BUILD_PROJECT}_LDFLAGS}" \
|
||||||
DEPEND_FILE=".depend.\${${BUILD_PROJECT}_NAME%/}" \
|
DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME%/}" \
|
||||||
\$MAKE -f Makefile.build "target-\${${BUILD_PROJECT}_NAME}"
|
\$MAKE -f Makefile.build "\$BUILD_WORK/target-\${${BUILD_PROJECT}_NAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Description: Remove the .o file for one .c file
|
# Description: Remove the .o file for one .c file
|
||||||
# Arguments: $1 - the .c file
|
# Arguments: $1 - the .c file
|
||||||
build_clean_file() {
|
build_clean_file() {
|
||||||
eval rm -f -- "\${${BUILD_PROJECT}_OBJS}\${1%.c}.o"
|
eval rm -f -- "\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\${1%.c}.o"
|
||||||
}
|
}
|
||||||
|
|
||||||
build_clean_dir() {
|
build_clean_dir() {
|
||||||
eval rmdir -- "\${${BUILD_PROJECT}_OBJS}\${1}" 2> /dev/null
|
eval rmdir -- "\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\${1}" 2> /dev/null
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
build_clean() {
|
build_clean() {
|
||||||
local DEPEND_FILE
|
local DEPEND_FILE
|
||||||
eval DEPEND_FILE=".depend.\${${BUILD_PROJECT}_NAME%/}"
|
eval DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME%/}"
|
||||||
rm -f "$DEPEND_FILE" build.vars config.state src/config.h
|
rm -f "$DEPEND_FILE" "$BUILD_WORK/build.vars" \
|
||||||
|
"$BUILD_WORK/config.state" "$BUILD_WORK/config_unix.h"
|
||||||
BUILD_FILES_VAR=${BUILD_PROJECT}_CFILES
|
BUILD_FILES_VAR=${BUILD_PROJECT}_CFILES
|
||||||
export BUILD_FILES_VAR
|
export BUILD_FILES_VAR
|
||||||
build_do_recursive build_clean_file build_clean_dir
|
build_do_recursive build_clean_file build_clean_dir
|
||||||
@@ -164,10 +165,10 @@ build_distclean() {
|
|||||||
# Description: check if the config files are present and load them.
|
# Description: check if the config files are present and load them.
|
||||||
# If they're not present, remake them.
|
# If they're not present, remake them.
|
||||||
build_check_config() {
|
build_check_config() {
|
||||||
[ ! -e build.vars -o -n "$BUILD_RUN_CONFIG" ] || return
|
[ ! -e "$BUILD_WORK/build.vars" -o -n "$BUILD_RUN_CONFIG" ] || return
|
||||||
|
|
||||||
build_config || exit $?
|
build_config || exit $?
|
||||||
. ./build.vars
|
. "$BUILD_WORK/build.vars"
|
||||||
. "${BUILD_REC_PATH:=./}Makeinfo"
|
. "${BUILD_REC_PATH:=./}Makeinfo"
|
||||||
unset BUILD_RUN_CONFIG
|
unset BUILD_RUN_CONFIG
|
||||||
}
|
}
|
||||||
@@ -175,7 +176,7 @@ build_check_config() {
|
|||||||
# Description: check if the necessary .depend file is present,
|
# Description: check if the necessary .depend file is present,
|
||||||
# if not, build it.
|
# if not, build it.
|
||||||
build_check_dependencies() {
|
build_check_dependencies() {
|
||||||
eval DEPEND_FILE=".depend.\${${BUILD_PROJECT}_NAME}"
|
eval DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME}"
|
||||||
[ ! -e "$DEPEND_FILE" -o -n "$BUILD_RUN_DEPEND" ] || return
|
[ ! -e "$DEPEND_FILE" -o -n "$BUILD_RUN_DEPEND" ] || return
|
||||||
|
|
||||||
build_rec_dependancies || exit $?
|
build_rec_dependancies || exit $?
|
||||||
|
|||||||
@@ -350,11 +350,15 @@ EOF
|
|||||||
# source, and the filename without .in as target.
|
# source, and the filename without .in as target.
|
||||||
# If a filename doesn't end on .in, that filename is used
|
# If a filename doesn't end on .in, that filename is used
|
||||||
# as target, and the filename with .in attached as source.
|
# as target, and the filename with .in attached as source.
|
||||||
|
# $3 - A path to which the input file names are relative
|
||||||
|
# $4 - A path to which the output file names are relative
|
||||||
substitute_vars() {
|
substitute_vars() {
|
||||||
local VARS VAR VALUE FILES FILE
|
local VARS VAR VALUE FILES FILE SRC_PATH DST_PATH
|
||||||
|
|
||||||
eval VARS=\"\$$1\"
|
eval VARS=\"\$$1\"
|
||||||
eval FILES=\"\$$2\"
|
eval FILES=\"\$$2\"
|
||||||
|
SRC_PATH="$3"
|
||||||
|
DST_PATH="$4"
|
||||||
|
|
||||||
for VAR in $VARS; do
|
for VAR in $VARS; do
|
||||||
# Escape all / in VAR so that we can use / as seperator char for sed
|
# Escape all / in VAR so that we can use / as seperator char for sed
|
||||||
@@ -367,9 +371,9 @@ EOF
|
|||||||
|
|
||||||
for FILE in $FILES; do
|
for FILE in $FILES; do
|
||||||
FILE="${FILE%.in}"
|
FILE="${FILE%.in}"
|
||||||
cp -p -- "$FILE".in "$FILE"
|
cp -p -- "$SRC_PATH/$FILE".in "$DST_PATH/$FILE"
|
||||||
# The copy is done so that the file modes are equal.
|
# The copy is done so that the file modes are equal.
|
||||||
$SED -f "${TEMPFILE}.sed" < "$FILE".in > "$FILE"
|
$SED -f "${TEMPFILE}.sed" < "$SRC_PATH/$FILE".in > "$DST_PATH/$FILE"
|
||||||
done
|
done
|
||||||
rm -- "${TEMPFILE}.sed"
|
rm -- "${TEMPFILE}.sed"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,6 +600,13 @@ menu_process_check() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Description: Start processing a menu
|
||||||
|
# Arguments: $1 - the type of the main menu
|
||||||
|
# $2 - the name of the main menu
|
||||||
|
# $3 - the path to the file to load and save the settings from/to
|
||||||
|
# (the file does not have to exist; in this case nothing is
|
||||||
|
# loaded)
|
||||||
|
# if the argument is empty, nothing is saved nor loaded
|
||||||
do_menu() {
|
do_menu() {
|
||||||
local MENU_TYPE START_MENU SAVE_FILE
|
local MENU_TYPE START_MENU SAVE_FILE
|
||||||
|
|
||||||
@@ -607,15 +614,15 @@ do_menu() {
|
|||||||
START_MENU="$2"
|
START_MENU="$2"
|
||||||
SAVE_FILE="$3"
|
SAVE_FILE="$3"
|
||||||
|
|
||||||
if [ -n "$SAVE_FILE" -a -e config.state ]; then
|
if [ -n "$SAVE_FILE" -a -e "$SAVE_FILE" ]; then
|
||||||
. config.state
|
. "$SAVE_FILE"
|
||||||
fi
|
fi
|
||||||
menu_init "$MENU_TYPE" "$START_MENU"
|
menu_init "$MENU_TYPE" "$START_MENU"
|
||||||
menu_handle "$MENU_TYPE" "$START_MENU"
|
menu_handle "$MENU_TYPE" "$START_MENU"
|
||||||
echo
|
echo
|
||||||
if [ -n "$SAVE_FILE" ]; then
|
if [ -n "$SAVE_FILE" ]; then
|
||||||
echo "Saving choices..."
|
echo "Saving choices..."
|
||||||
menu_save "$MENU_TYPE" "$START_MENU" > config.state
|
menu_save "$MENU_TYPE" "$START_MENU" > "$SAVE_FILE"
|
||||||
fi
|
fi
|
||||||
# echo "Propagating choices..."
|
# echo "Propagating choices..."
|
||||||
menu_process "$MENU_TYPE" "$START_MENU"
|
menu_process "$MENU_TYPE" "$START_MENU"
|
||||||
|
|||||||
Reference in New Issue
Block a user