diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 54baf474f..84d71174f 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.4: +- Made the unix build scripts more portable. Removed some small + bugs. - SvdB - No longer chdir() to the content dir (bug #564) Environment variables and ~ are interpreted in the supplied content path now. diff --git a/sc2/build.vars.in b/sc2/build.vars.in index bb2bb1c63..1da5b6469 100644 --- a/sc2/build.vars.in +++ b/sc2/build.vars.in @@ -18,6 +18,7 @@ COMPILE=gcc MKDEPEND='gcc -MM' MAKE='@MAKE@' +ECHON='@ECHON@' uqm_CFLAGS='@CFLAGS@' uqm_LDFLAGS='@LDFLAGS@' uqm_INSTALL_BINDIR='@INSTALL_BINDIR@' diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index be61af105..0d05097c8 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -222,7 +222,7 @@ uqm_process_config() { 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 \ + SUBSTITUTE_VARS="CFLAGS LDFLAGS MAKE ECHON DEBUG SOUNDMODULE HAVE_OPENGL \ USE_ZIP_IO \ INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR \ REZ SETFILE WINDRES" diff --git a/sc2/build/unix/build.sh b/sc2/build/unix/build.sh index 96e49f922..80deca6f7 100644 --- a/sc2/build/unix/build.sh +++ b/sc2/build/unix/build.sh @@ -88,7 +88,7 @@ if [ -z "$TARGET" ]; then exit 1 fi BUILD_PROJECT="$TARGET" -export TARGET BUILD_PROJECT COMPILE MKDEPEND +export TARGET BUILD_PROJECT COMPILE MKDEPEND ECHON export "${BUILD_PROJECT}_CFLAGS" "${BUILD_PROJECT}_LDFLAGS" # Add trailing / from objs dir diff --git a/sc2/build/unix/build_functions b/sc2/build/unix/build_functions index 36d02417a..eb4a8fad9 100644 --- a/sc2/build/unix/build_functions +++ b/sc2/build/unix/build_functions @@ -69,7 +69,7 @@ build_do_recursive() { # Build dependancy information for one file build_dependancies() { - eval echo -n \$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\$BUILD_REC_PATH + eval $ECHON \$BUILD_WORK/\${${BUILD_PROJECT}_OBJS}\$BUILD_REC_PATH eval eval \\\$MKDEPEND \"\${${BUILD_PROJECT}_CFLAGS}\" \"\\\$1\" } @@ -95,9 +95,9 @@ build_rec_dependancies() { eval DEPEND_FILE="\$BUILD_WORK/.depend.\${${BUILD_PROJECT}_NAME}" { - eval echo -n "\$BUILD_WORK_ESC/target-\${${BUILD_PROJECT}_NAME}:" + eval $ECHON "\$BUILD_WORK_ESC/target-\${${BUILD_PROJECT}_NAME}:" for OFILE in $OFILES $EXTRA_OFILES; do - echo -n " $OFILE" + $ECHON " $OFILE" done echo build_do_recursive build_dependancies : diff --git a/sc2/build/unix/config_functions b/sc2/build/unix/config_functions index c3c15ff03..7db2a2d74 100644 --- a/sc2/build/unix/config_functions +++ b/sc2/build/unix/config_functions @@ -40,7 +40,7 @@ try_compile_c() { fi cat > "$TEMPFILE.c" echo_and_perform $COMPILE $1 $2 "$TEMPFILE.c" \ - -o "$TEMPFILE.out" 2>&1 >> "$BUILDLOG" + -o "$TEMPFILE.out" >> "$BUILDLOG" 2>&1 RESULT=$? rm -f "$TEMPFILE.c" "$TEMPFILE.out" return $RESULT @@ -58,7 +58,7 @@ try_compile_and_run_c() { fi cat > "$TEMPFILE.c" echo_and_perform $COMPILE $1 $2 "$TEMPFILE.c" \ - -o "$TEMPFILE.out" 2>&1 >> "$BUILDLOG" + -o "$TEMPFILE.out" >> "$BUILDLOG" 2>&1 if [ $? -ne 0 ]; then return -1 fi @@ -119,7 +119,7 @@ have_program() { eval eval TEMP_FILE="\\\"\$PROG_${PROG}_FILE\\\"" - type "$TEMP_FILE" 2>&1 > /dev/null + type "${TEMP_FILE%% *}" > /dev/null 2>&1 if [ $? -ne 0 ]; then build_message "$TEMP_NAME not found." return 1 @@ -245,7 +245,7 @@ have_symbol() { # TODO: I'll want the include handling to be done differently # eventually. - try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF 2>&1 > /dev/null + try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF > /dev/null 2>&1 #include #include #include @@ -287,7 +287,7 @@ have_header() { local HEADER HEADER="$1" - try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF 2>&1 > /dev/null + try_compile_c "$TEMP_CFLAGS" "$TEMP_LDFLAGS" << EOF > /dev/null 2>&1 #include <$HEADER> int main() { return 0; @@ -399,6 +399,8 @@ HAVE_SYMBOLS="" config_requirements() { # Requirements for the config program itself + have_program echon || exit 1 + ECHON="$PROG_echon_FILE" have_program sed || exit 1 SED="$PROG_sed_FILE" have_program tr || exit 1 diff --git a/sc2/build/unix/config_proginfo b/sc2/build/unix/config_proginfo index 05fb7a20c..e8aff3575 100644 --- a/sc2/build/unix/config_proginfo +++ b/sc2/build/unix/config_proginfo @@ -28,6 +28,39 @@ PROG_sed_FILE="sed" PROG_sed_ACTION="" PROG_sed_VERSION='' +PROG_echon_NAME="'echo -n' capable echo" +PROG_echon_FILE="" +PROG_echon_ACTION="" +PROG_echon_VERSION='' +PROG_echon_DETECT="echon_detect" +echon_detect() { + local TEST + + # Default echo (probably builtin) + TEST=`echo -n X` + if [ "$TEST" = X ]; then + PROG_echon_FILE="echo -n" + return 0; + fi + + # External echo + TEST=`/bin/echo -n X` + if [ "$TEST" = X ]; then + PROG_echon_FILE="/bin/echo -n" + return 0; + fi + + # Using printf as echo + TEST=`printf %s X` + if [ "$TEST" = X ]; then + PROG_echon_FILE="printf %s" + return 0; + fi + + # No good echo found + return 1 +} + PROG_make_NAME="Make" case "$OSNAME" in FreeBSD|OpenBSD|SunOS) diff --git a/sc2/build/unix/menu_functions b/sc2/build/unix/menu_functions index 37c27e349..236c6b0c4 100644 --- a/sc2/build/unix/menu_functions +++ b/sc2/build/unix/menu_functions @@ -277,7 +277,7 @@ EOF echo echo "Press a number plus if you want to change something, " - echo -n "or just if everything is ok: " + $ECHON "or just if everything is ok: " read CHOICE # Check if the choice was empty @@ -367,7 +367,7 @@ EOF echo echo "Select the option you want by typing a number plus " - echo -n "or just if everything is ok: " + $ECHON "or just if everything is ok: " read CHOICE echo @@ -434,7 +434,7 @@ EOF eval TEMP_DEFAULT="\$INPUT_${ITEM}_DEFAULT" echo " Default value: $TEMP_DEFAULT" echo " Current value: $TEMP_VALUE" - echo -n " New value: " + $ECHON " New value: " read NEW_VALUE # If no new value is entered, keep the old one.