config.lib
branchcpp_gui
changeset 6268 4b5241e5dd10
parent 6254 abc6ad7c035c
child 6285 187e3ef04cc9
--- a/config.lib	Tue Feb 27 23:54:28 2007 +0000
+++ b/config.lib	Wed Feb 28 00:33:40 2007 +0000
@@ -17,6 +17,7 @@
 	windres=""
 	strip=""
 	lipo=""
+	awk="awk"
 	os="DETECT"
 	endian="AUTO"
 	revision=""
@@ -57,7 +58,7 @@
 	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 @@
 			--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";;
@@ -285,30 +288,32 @@
 	# Some params want to be in full uppercase, else they might not work as
 	# expected.. fix that here
 
-	endian=`echo $endian | tr [:lower:] [:upper:]`
-	os=`echo $os | tr [:lower:] [:upper:]`
+	endian=`echo $endian | tr '[a-z]' '[A-Z]'`
+	os=`echo $os | tr '[a-z]' '[A-Z]'`
 
 	# Check if all params have valid values
 
 	# Endian only allows AUTO, LE and, BE
-	if ! echo $endian | grep -Eq "^(AUTO|LE|BE)$"; then
+	if [ -z "`echo $endian | egrep '^(AUTO|LE|BE)$'`" ]; then
 		echo "configure: error: invalid option --endian=$endian"
 		echo " Available options are: --endian=[AUTO|LE|BE]"
 		exit 1
 	fi
 	# OS only allows DETECT, UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, WINCE, and PSP
-	if ! echo $os | grep -Eq "^(DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP)$"; then
+	if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP)$'`" ]; then
 		echo "configure: error: invalid option --os=$os"
 		echo " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP]"
 		exit 1
 	fi
 	# enable_debug should be between 0 and 4
-	if ! echo $enable_debug | grep -q "^[0123]$"; then
+	if [ -z "`echo $enable_debug | grep '^[0123]$'`" ]; then
 		echo "configure: error: invalid option --enable-debug=$enable_debug"
 		echo " Available options are: --enable-debug[=0123]"
 		exit 1
 	fi
 
+	detect_awk
+
 	check_build
 	check_host
 
@@ -336,7 +341,11 @@
 	check_cxx_build
 	check_cxx_host
 	check_windres
-	check_strip
+	if [ "$enable_strip" != "0" ]; then
+		check_strip
+	else
+		log 1 "checking strip... disabled"
+	fi
 	check_lipo
 	check_makedepend
 
@@ -548,7 +557,7 @@
 			log 1 "detecting G5... yes (forced)"
 		else
 			# First, are we a real OSX system, else we can't detect it
-			native=`LC_ALL=C uname | tr [:upper:] [:lower:] | grep darwin`
+			native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin`
 			# If $host doesn't match $build , we are cross-compiling
 			if [ -n "$native" ] && [ "$build" != "$host" ]; then
 				$cc_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector
@@ -602,6 +611,7 @@
 			if [ "$os" = "MORPHOS" ]; then
 				CFLAGS="$CFLAGS -I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations"
 				CFLAGS="$CFLAGS -mcpu=604 -fno-inline -mstring -mmultiple"
+				LDFLAGS="$LDFLAGS -noixemul"
 			fi
 
 			CFLAGS="$CFLAGS -O2 -fomit-frame-pointer"
@@ -1138,12 +1148,51 @@
 	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
+	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 [:upper:] [:lower:] | awk '
+		os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk '
 					/linux/        { print "UNIX";    exit}
 					/darwin/       { print "OSX";     exit}
 					/freebsd/      { print "FREEBSD"; exit}
@@ -1158,7 +1207,7 @@
 		'`
 
 		if [ -z "$os" ]; then
-			os=`LC_ALL=C uname | tr [:upper:] [:lower:] | awk '
+			os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk '
 					/linux/        { print "UNIX";    exit}
 					/darwin/       { print "OSX";     exit}
 					/freebsd/      { print "FREEBSD"; exit}
@@ -1753,6 +1802,7 @@
 		s#!!OS!!#$os#g;
 		s#!!CONFIGURE_FILES!!#$CONFIGURE_FILES#g;
 		s#!!REVISION!!#$revision#g;
+		s#!!AWK!!#$awk#g;
 		s#!!ENABLE_INSTALL!!#$enable_install#g;
 	"
 }
@@ -1849,6 +1899,7 @@
 	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/"