config.lib
changeset 6360 37f43b7ce27b
parent 6232 09125a3ceba4
child 6361 8fc35d15114f
--- a/config.lib	Fri Feb 16 09:39:32 2007 +0000
+++ b/config.lib	Fri Feb 16 09:50:28 2007 +0000
@@ -52,11 +52,12 @@
 	with_iconv="1"
 	with_midi=""
 	with_midi_arg=""
+	with_libtimidity="1"
 	with_freetype="1"
 	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_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 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() {
@@ -184,6 +185,10 @@
 			--without-libpng)             with_png="0";;
 			--with-libpng=*)              with_png="$optarg";;
 
+			--with-libtimidity)           with_libtimidity="2";;
+			--without-libtimidity)        with_libtimidity="0";;
+			--with-libtimidity=*)         with_libtimidity="$optarg";;
+
 			--with-freetype)              with_freetype="2";;
 			--without-freetype)           with_freetype="0";;
 			--with-freetype=*)            with_freetype="$optarg";;
@@ -421,6 +426,7 @@
 	detect_fontconfig
 	detect_iconv
 	detect_pspconfig
+	detect_libtimidity
 
 	if [ "$with_direct_music" = "1" ] || [ "$with_direct_music" = "2" ]; then
 		if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
@@ -776,6 +782,15 @@
 		CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT"
 	fi
 
+	if [ "$with_libtimidity" != "0" ]; then
+		if [ "$enable_static" != "0" ]; then
+			LIBS="$LIBS $libtimidity"
+		else
+			LIBS="$LIBS -ltimidity"
+		fi
+		CFLAGS="$CFLAGS -DLIBTIMIDITY"
+	fi
+
 	if [ "$with_iconv" != "0" ]; then
 		CFLAGS="$CFLAGS -DWITH_ICONV"
 		LIBS="$LIBS -liconv"
@@ -1273,65 +1288,78 @@
 	log 1 "checking COCOA... found"
 }
 
-detect_zlib() {
+detect_library() {
+	# $1 - config-param ($with_zlib value)
+	# $2 - library name ('zlib', sets $zlib)
+	# $3 - static library name (libz.a)
+	# $4 - header name (zlib.h)
+
 	# 0 means no, 1 is auto-detect, 2 is force
-	if [ "$with_zlib" = "0" ]; then
-		log 1 "checking zlib... disabled"
+	if [ "$1" = "0" ]; then
+		log 1 "checking $2... disabled"
 
-		zlib=""
+		eval "$2=\"\""
 		return 0
 	fi
 
-	log 2 "detecting zlib"
+	log 2 "detecting $2"
 
-	if [ "$with_zlib" = "1" ] || [ "$with_zlib" = "" ] || [ "$with_zlib" = "2" ]; then
-		zlib=`ls -1 /usr/include/*.h 2>/dev/null | grep "\/zlib.h$"`
-		if [ -z "$zlib" ]; then
-			log 2 "  trying /usr/include/zlib.h... no"
-			zlib=`ls -1 /usr/local/include/*.h 2>/dev/null | grep "\/zlib.h$"`
+	if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
+		eval "$2=`ls -1 /usr/include/*.h 2>/dev/null | grep \"\/$4\$\"`"
+		eval "res=\$$2"
+		if [ -z "$res" ]; then
+			log 2 "  trying /usr/include/$4... no"
+			eval "$2=`ls -1 /usr/local/include/*.h 2>/dev/null | grep \"\/$4\$\"`"
 		fi
-		if [ -z "$zlib" ]; then
-			log 2 "  trying /usr/local/include/zlib.h... no"
+		eval "res=\$$2"
+		if [ -z "$res" ]; then
+			log 2 "  trying /usr/local/include/$4... no"
 		fi
 
-		if [ -n "$zlib" ] && [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
-			log 2 "  trying $zlib... found"
+		eval "res=\$$2"
+		if [ -n "$res" ] && [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
+			eval "res=\$$2"
+			log 2 "  trying $res... found"
 			# Now find the static lib, if needed
-			zlib=`ls /lib/*.a 2>/dev/null | grep "\/libz.a$"`
-			if [ -z "$zlib" ]; then
-				log 2 "  trying /lib/libz.a... no"
-				zlib=`ls /usr/lib/*.a 2>/dev/null | grep "\/libz.a$"`
+			eval "$2=`ls /lib/*.a 2>/dev/null | grep \"\/$3\$\"`"
+			eval "res=\$$2"
+			if [ -z "$res" ]; then
+				log 2 "  trying /lib/$3... no"
+				eval "$2=`ls /usr/lib/*.a 2>/dev/null | grep \"\/$3\$\"`"
 			fi
-			if [ -z "$zlib" ]; then
-				log 2 "  trying /usr/lib/libz.a... no"
-				zlib=`ls /usr/local/lib/*.a 2>/dev/null | grep "\/libz.a$"`
+			eval "res=\$$2"
+			if [ -z "$res" ]; then
+				log 2 "  trying /usr/lib/$3... no"
+				eval "$2=`ls /usr/local/lib/*.a 2>/dev/null | grep \"\/$3\$\"`"
 			fi
-			if [ -z "$zlib" ]; then
-				log 2 "  trying /usr/local/lib/libz.a... no"
-				log 1 "configure: error: zlib couldn't be found"
-				log 1 "configure: error: you requested a static link, but I can't find zlib.a"
+			eval "res=\$$2"
+			if [ -z "$res" ]; then
+				log 2 "  trying /usr/local/lib/$3... no"
+				log 1 "configure: error: $2 couldn't be found"
+				log 1 "configure: error: you requested a static link, but I can't find $3"
 
 				exit 1
 			fi
 		fi
 	else
 		# Make sure it exists
-		if [ -f "$with_zlib" ]; then
-			zlib=`ls $with_zlib 2>/dev/null`
+		if [ -f "$1" ]; then
+			eval "$2=`ls $1 2>/dev/null`"
 		else
-			zlib=`ls $with_zlib/libz.a 2>/dev/null`
+			eval "$2=`ls $1/$3 2>/dev/null`"
 		fi
 	fi
 
-	if [ -z "$zlib" ]; then
-		log 1 "checking zlib... not found"
-		if [ "$with_zlib" = "2" ]; then
-			log 1 "configure: error: zlib couldn't be found"
+	eval "res=\$$2"
+	if [ -z "$res" ]; then
+		log 1 "checking $2... not found"
+		if [ "$1" = "2" ]; then
+			log 1 "configure: error: $2 couldn't be found"
 
 			exit 1
-		elif [ "$with_zlib" != "1" ]; then
-			log 1 "configure: error: zlib couldn't be found"
-			log 1 "configure: error: you supplied '$with_zlib', but it seems invalid"
+		elif [ "$1" != "1" ]; then
+			log 1 "configure: error: $2 couldn't be found"
+			log 1 "configure: error: you supplied '$1', but it seems invalid"
 
 			exit 1
 		fi
@@ -1339,9 +1367,18 @@
 		return 0
 	fi
 
-	log 2 "  trying $zlib... found"
+	eval "res=\$$2"
+	log 2 "  trying $res... found"
 
-	log 1 "checking zlib... found"
+	log 1 "checking $2... found"
+}
+
+detect_zlib() {
+	detect_library "$with_zlib" "zlib" "libz.a" "zlib.h"
+}
+
+detect_libtimidity() {
+	detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "timidity.h"
 }
 
 detect_png() {