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:
meep-eep
2004-02-27 14:09:13 +00:00
parent 164e5f3798
commit 2990805c14
9 changed files with 60 additions and 34 deletions
+3
View File
@@ -1,4 +1,7 @@
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),
from Nic and Michael
- Added new 'triscan' scaler; derived from scale2x[.sf.net] -Alex
+4 -2
View File
@@ -21,6 +21,8 @@ target-%:
-include $(DEPEND_FILE)
# Temporary:
obj/release/./src/res/UrQuanMasters.rc.o: ./src/res/UrQuanMasters.rc
obj/debug/./src/res/UrQuanMasters.rc.o: ./src/res/UrQuanMasters.rc
$(BUILD_WORK)/obj/release/./src/res/UrQuanMasters.rc.o:\
./src/res/UrQuanMasters.rc
$(BUILD_WORK)/obj/debug/./src/res/UrQuanMasters.rc.o: \
./src/res/UrQuanMasters.rc
+2 -2
View File
@@ -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
# config.
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_MODE="0755"
@@ -28,7 +28,7 @@ uqm_INSTALL_SHARED_content_MODE="go+rX"
# Stuff to install under the directory for binaries, as specified during
# config.
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_MODE="0755"
+13 -8
View File
@@ -1,5 +1,9 @@
#!/bin/sh
if [ -z "$BUILD_WORK" ]; then
BUILD_WORK=.
fi
# Include build functions used here
. build/unix/config_functions
. build/unix/menu_functions
@@ -82,7 +86,7 @@ strictdebug_action() {
# We shouldn't do this until we actually nail them
# all in the original code. Then we can enforce them
# on ourselves.
# CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI
# CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI
# CFLAGS="$CFLAGS -Wnested-externs"
# We know they're in the code, and though we'd like to get
# rid of them, they're not bugs.
@@ -182,7 +186,7 @@ INPUT_install_sharedir_VALIDATOR=validate_path
# 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."
# Set INSTALL_LIBDIR, INSTALL_BINDIR, and INSTALL_SHAREDIR to the specified
@@ -197,22 +201,23 @@ prefix="$INPUT_install_prefix_VALUE" \
# Set the content dir
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_FILES="src/config.h"
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES
SUBSTITUTE_FILES="config_unix.h"
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES src "$BUILD_WORK"
# Make build.vars from build.vars.in, substituting variables.
SUBSTITUTE_VARS="CFLAGS LDFLAGS MAKE DEBUG SOUNDMODULE HAVE_OPENGL \
USE_ZIP_IO \
INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR WINDRES"
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.
SUBSTITUTE_VARS="INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR uqm_NAME"
SUBSTITUTE_FILES="build/unix/uqm"
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES
SUBSTITUTE_FILES="uqm-wrapper"
substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES build/unix "$BUILD_WORK"
+6 -2
View File
@@ -22,10 +22,14 @@
# Read in the functions we need
. build/unix/build_functions
if [ -z "$BUILD_WORK" ]; then
BUILD_WORK=.
fi
# Read in the config settings that affect the build, if present.
# Don't reread for every dir when recursing.
if [ -e build.vars -a -z "$BUILD_COMMAND" ]; then
. ./build.vars
if [ -e "$BUILD_WORK/build.vars" -a -z "$BUILD_COMMAND" ]; then
. "$BUILD_WORK/build.vars"
fi
# Read in the Makeinfo file for the dir currently being processed
+15 -14
View File
@@ -63,7 +63,7 @@ build_do_recursive() {
# Build dependancy information for one file
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"
}
@@ -80,9 +80,9 @@ build_rec_dependancies() {
BUILD_FILES_VAR=${BUILD_PROJECT}_CFILES
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
echo -n " $OFILE"
done
@@ -93,12 +93,12 @@ build_rec_dependancies() {
# Output the .o file for a .c file.
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
build_collect_extra_o_files() {
eval echo "\${${BUILD_PROJECT}_OBJS}\$1"
eval echo "\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\$1"
}
# Recursively collect .o-files
@@ -123,25 +123,26 @@ build_config() {
build_compile() {
eval CFLAGS="\${${BUILD_PROJECT}_CFLAGS}" \
LDFLAGS="\${${BUILD_PROJECT}_LDFLAGS}" \
DEPEND_FILE=".depend.\${${BUILD_PROJECT}_NAME%/}" \
\$MAKE -f Makefile.build "target-\${${BUILD_PROJECT}_NAME}"
DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME%/}" \
\$MAKE -f Makefile.build "\$BUILD_WORK/target-\${${BUILD_PROJECT}_NAME}"
}
# Description: Remove the .o file for one .c file
# Arguments: $1 - the .c 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() {
eval rmdir -- "\${${BUILD_PROJECT}_OBJS}\${1}" 2> /dev/null
eval rmdir -- "\$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\${1}" 2> /dev/null
return 0
}
build_clean() {
local DEPEND_FILE
eval DEPEND_FILE=".depend.\${${BUILD_PROJECT}_NAME%/}"
rm -f "$DEPEND_FILE" build.vars config.state src/config.h
eval DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME%/}"
rm -f "$DEPEND_FILE" "$BUILD_WORK/build.vars" \
"$BUILD_WORK/config.state" "$BUILD_WORK/config_unix.h"
BUILD_FILES_VAR=${BUILD_PROJECT}_CFILES
export BUILD_FILES_VAR
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.
# If they're not present, remake them.
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.vars
. "$BUILD_WORK/build.vars"
. "${BUILD_REC_PATH:=./}Makeinfo"
unset BUILD_RUN_CONFIG
}
@@ -175,7 +176,7 @@ build_check_config() {
# Description: check if the necessary .depend file is present,
# if not, build it.
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
build_rec_dependancies || exit $?
+7 -3
View File
@@ -350,11 +350,15 @@ EOF
# source, and the filename without .in as target.
# If a filename doesn't end on .in, that filename is used
# 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() {
local VARS VAR VALUE FILES FILE
local VARS VAR VALUE FILES FILE SRC_PATH DST_PATH
eval VARS=\"\$$1\"
eval FILES=\"\$$2\"
SRC_PATH="$3"
DST_PATH="$4"
for VAR in $VARS; do
# Escape all / in VAR so that we can use / as seperator char for sed
@@ -367,9 +371,9 @@ EOF
for FILE in $FILES; do
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.
$SED -f "${TEMPFILE}.sed" < "$FILE".in > "$FILE"
$SED -f "${TEMPFILE}.sed" < "$SRC_PATH/$FILE".in > "$DST_PATH/$FILE"
done
rm -- "${TEMPFILE}.sed"
}
+10 -3
View File
@@ -600,6 +600,13 @@ menu_process_check() {
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() {
local MENU_TYPE START_MENU SAVE_FILE
@@ -607,15 +614,15 @@ do_menu() {
START_MENU="$2"
SAVE_FILE="$3"
if [ -n "$SAVE_FILE" -a -e config.state ]; then
. config.state
if [ -n "$SAVE_FILE" -a -e "$SAVE_FILE" ]; then
. "$SAVE_FILE"
fi
menu_init "$MENU_TYPE" "$START_MENU"
menu_handle "$MENU_TYPE" "$START_MENU"
echo
if [ -n "$SAVE_FILE" ]; then
echo "Saving choices..."
menu_save "$MENU_TYPE" "$START_MENU" > config.state
menu_save "$MENU_TYPE" "$START_MENU" > "$SAVE_FILE"
fi
# echo "Propagating choices..."
menu_process "$MENU_TYPE" "$START_MENU"