diff options
-rw-r--r-- | Makefile.in | 3 | ||||
-rw-r--r-- | Makefile.src.in | 5 | ||||
-rw-r--r-- | config.lib | 52 | ||||
-rwxr-xr-x | configure | 12 |
4 files changed, 60 insertions, 12 deletions
diff --git a/Makefile.in b/Makefile.in index ca99575f0..c237bc0eb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -30,6 +30,7 @@ TTDS = $(SRC_DIRS:%=%/$(TTD)) OS = !!OS!! OSXAPP = !!OSXAPP!! REVISION = !!REVISION!! +AWK = !!AWK!! RES := $(shell if ! [ -f $(CONFIG_CACHE_SOURCE_LIST) ] || [ -n "`cmp $(CONFIG_CACHE_SOURCE_LIST) $(SOURCE_LIST)`" ]; then cp $(SOURCE_LIST) $(CONFIG_CACHE_SOURCE_LIST); fi ) @@ -118,7 +119,7 @@ ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1) # Find if the local source if modified REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' ) # Find the revision like: rXXXX-branch -REV := $(shell LC_ALL=C svn info $(SRC_DIR) | awk '/^URL:.*branches/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') +REV := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^URL:.*branches/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') endif endif # Make sure we have something in REV diff --git a/Makefile.src.in b/Makefile.src.in index 9d0980d9a..ca96f16c9 100644 --- a/Makefile.src.in +++ b/Makefile.src.in @@ -27,6 +27,7 @@ MAKEDEPEND = !!MAKEDEPEND!! CFLAGS_MAKEDEP= !!CFLAGS_MAKEDEP!! SORT = !!SORT!! REVISION = !!REVISION!! +AWK = !!AWK!! CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!! CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!! CONFIG_CACHE_ENDIAN = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_ENDIAN!! @@ -82,7 +83,7 @@ ifeq ($(shell if test -d $(SRC_DIR)/.svn; then echo 1; fi), 1) # Find if the local source if modified REV_MODIFIED := $(shell svnversion $(SRC_DIR) | sed -n 's/.*\(M\).*/\1/p' ) # Find the revision like: rXXXX-branch -REV := $(shell LC_ALL=C svn info $(SRC_DIR) | awk '/^URL:.*branch/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') +REV := $(shell LC_ALL=C svn info $(SRC_DIR) | $(AWK) '/^URL:.*branch/ { split($$2, a, "/"); BRANCH="-"a[5] } /^Last Changed Rev:/ { REV="r"$$4"$(REV_MODIFIED)" } END { print REV BRANCH }') endif endif # Make sure we have something in REV @@ -166,7 +167,7 @@ endif # Remove all comments and includes that don't start with $(SRC_DIR) # Remove $(SRC_DIR) from object-file-name - @awk ' \ + @$(AWK) ' \ /^# DO NOT/ { print $$0 ; next} \ /^#/ {next} \ /:/ { \ diff --git a/config.lib b/config.lib index 2276baff3..40ed96843 100644 --- a/config.lib +++ b/config.lib @@ -17,6 +17,7 @@ set_default() { windres="" strip="" lipo="" + awk="awk" os="DETECT" endian="AUTO" revision="" @@ -57,7 +58,7 @@ set_default() { with_fontconfig="1" with_psp_config="1" - save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip lipo os revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir custom_lang_dir second_data_dir enable_install enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_osx_sysroot enable_universal enable_osx_g5 with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config CC CXX CFLAGS LDFLAGS" + save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir custom_lang_dir second_data_dir enable_install enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_osx_sysroot enable_universal enable_osx_g5 with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config CC CXX CFLAGS LDFLAGS" } detect_params() { @@ -99,6 +100,8 @@ detect_params() { --cxx-host=*) cxx_host="$optarg";; --windres) prevp_p="windres";; --windres=*) windres="$optarg";; + --awk) prevp_p="awk";; + --awk=*) awk="$optarg";; --strip) prevp_p="strip";; --strip=*) strip="$optarg";; --lipo) prevp_p="lipo";; @@ -309,6 +312,8 @@ check_params() { exit 1 fi + detect_awk + check_build check_host @@ -1139,12 +1144,51 @@ check_makedepend() { log 1 "checking makedepend... $makedepend" } +detect_awk() { + # Not all awks allow gsub(), so we test for that here! It is in fact all we need... + + # These awks are known to work. Test for them explicit + awks="gawk mawk nawk" + + awk_prefix="echo \"a.c b.c c.c\" | tr ' ' \\\\n | " + awk_param="' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", \$0); print \$0; }' 2>/dev/null" + awk_result="a.o b.o c.o " + log 2 "Detecing awk..." + + log 2 "Trying: $awk_prefix $awk $awk_param" + res=`eval $awk_prefix $awk $awk_param` + log 2 "Result: '$res'" + if [ "$res" != "$awk_result" ] && [ "$awk" = "awk" ]; then + # User didn't supply his own awk, so try to detect some other known working names for an awk + for awk in $awks; do + log 2 "Trying: $awk_prefix $awk $awk_param" + res=`eval $awk_prefix $awk $awk_param` + log 2 "Result: '$res'" + if [ "$res" = "$awk_result" ]; then break; fi + done + + if [ "$res" != "$awk_result" ]; then + log 1 "checking awk... not found" + log 1 "configure: error: no awk found" + log 1 "configure: error: please install one of the following: $awks" + exit 1 + fi + fi + if [ "$res" != "$awk_result" ]; then + log 1 "checking awk... not found" + log 1 "configure: error: you supplied '$awk' but it doesn't seem a valid gawk or mawk" + exit 1 + fi + + log 1 "checking awk... $awk" +} + detect_os() { if [ "$os" = "DETECT" ]; then # Detect UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP # Try first via dumpmachine, then via uname - os=`echo "$host" | tr '[A-Z]' '[a-z]' | awk ' + os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk ' /linux/ { print "UNIX"; exit} /darwin/ { print "OSX"; exit} /freebsd/ { print "FREEBSD"; exit} @@ -1159,7 +1203,7 @@ detect_os() { '` if [ -z "$os" ]; then - os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | awk ' + os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk ' /linux/ { print "UNIX"; exit} /darwin/ { print "OSX"; exit} /freebsd/ { print "FREEBSD"; exit} @@ -1754,6 +1798,7 @@ make_sed() { s#!!OS!!#$os#g; s#!!CONFIGURE_FILES!!#$CONFIGURE_FILES#g; s#!!REVISION!!#$revision#g; + s#!!AWK!!#$awk#g; s#!!ENABLE_INSTALL!!#$enable_install#g; " } @@ -1850,6 +1895,7 @@ showhelp() { echo " on HOST [BUILD]" echo " --windres=WINDRES the windres to use [HOST-windres]" echo " --strip=STRIP the strip to use [HOST-strip]" + echo " --awk=AWK the awk to use in configure [awk]" echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]" echo " --os=OS the OS we are compiling for [DETECT]" echo " DETECT/UNIX/OSX/FREEBSD/MORPHOS/BEOS/" @@ -58,7 +58,7 @@ if ! [ -f "$LANG_DIR/english.txt" ]; then fi # Read the source.list and process it -SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | awk ' +SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk ' { } /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; } /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; } @@ -100,11 +100,11 @@ SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | awk ' } ' | $PIPE_SORT`" -OBJS_C="` echo \"$SRCS\" | awk ' { ORS = " " } /\.c$/ { gsub(".c$", ".o", $0); print $0; }'`" -OBJS_CPP="`echo \"$SRCS\" | awk ' { ORS = " " } /\.cpp$/ { gsub(".cpp$", ".o", $0); print $0; }'`" -OBJS_MM="` echo \"$SRCS\" | awk ' { ORS = " " } /\.mm$/ { gsub(".mm$", ".o", $0); print $0; }'`" -OBJS_RC="` echo \"$SRCS\" | awk ' { ORS = " " } /\.rc$/ { gsub(".rc$", ".o", $0); print $0; }'`" -SRCS="` echo \"$SRCS\" | awk ' { ORS = " " } { print $0; }'`" +OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.c$/ { gsub(".c$", ".o", $0); print $0; }'`" +OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = " " } /\.cpp$/ { gsub(".cpp$", ".o", $0); print $0; }'`" +OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.mm$/ { gsub(".mm$", ".o", $0); print $0; }'`" +OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = " " } /\.rc$/ { gsub(".rc$", ".o", $0); print $0; }'`" +SRCS="` echo \"$SRCS\" | $awk ' { ORS = " " } { print $0; }'`" # In makefiles, we always use -u for sort if [ -z "$sort" ]; then |