added support for libcurl to configure
authorTero Marttila <terom@fixme.fi>
Tue, 22 Jul 2008 23:11:26 +0300
changeset 11183 b8c8569d24fd
parent 11182 22f2cfb1f1f0
child 11184 88c967f1422b
added support for libcurl to configure
config.lib
--- a/config.lib	Tue Jul 22 22:55:50 2008 +0300
+++ b/config.lib	Tue Jul 22 23:11:26 2008 +0300
@@ -52,6 +52,7 @@
 	with_cocoa="1"
 	with_zlib="1"
 	with_png="1"
+	with_curl="1"
 	with_makedepend="1"
 	with_direct_music="1"
 	with_sort="1"
@@ -109,6 +110,7 @@
 		with_cocoa
 		with_zlib
 		with_png
+		with_curl
 		with_makedepend
 		with_direct_music
 		with_sort
@@ -262,6 +264,13 @@
 			--without-libpng)             with_png="0";;
 			--with-libpng=*)              with_png="$optarg";;
 
+            --with-curl)                  with_curl="2";;
+			--without-curl)               with_curl="0";;
+			--with-curl=*)                with_curl="$optarg";;
+			--with-libcurl)               with_curl="2";;
+			--without-libcurl)            with_curl="0";;
+			--with-libcurl=*)             with_curl="$optarg";;
+
 			--with-libtimidity)           with_libtimidity="2";;
 			--without-libtimidity)        with_libtimidity="0";;
 			--with-libtimidity=*)         with_libtimidity="$optarg";;
@@ -562,6 +571,7 @@
 
 	detect_zlib
 	detect_png
+	detect_curl
 	detect_freetype
 	detect_fontconfig
 	detect_iconv
@@ -1083,6 +1093,14 @@
 		else
 			LIBS="$LIBS `$png_config --ldflags | tr '\n\r' '  '`"
 		fi
+    fi
+
+    if [ -n "$curl_config" ]; then
+		CFLAGS="$CFLAGS -DWITH_CURL"
+		CFLAGS="$CFLAGS `$curl_config --cflags  | tr '\n\r' '  '`"
+        
+        # XXX: does this break on enable_static? curl-config doesn't take a --static option
+        LIBS="$LIBS `$curl_config --libs | tr '\n\r' '  '`"
 	fi
 
 	if [ -n "$fontconfig_config" ]; then
@@ -1843,6 +1861,45 @@
 	log 1 "checking libpng... found"
 }
 
+detect_curl() {
+	# 0 means no, 1 is auto-detect, 2 is force
+	if [ "$with_curl" = "0" ]; then
+		log 1 "checking curl... disabled"
+
+		curl_config=""
+		return 0
+	fi
+
+	if [ "$with_curl" = "1" ] || [ "$with_curl" = "" ] || [ "$with_curl" = "2" ]; then
+		curl_config="curl-config"
+	else
+		curl_config="$with_curl"
+	fi
+
+	version=`$curl_config --version 2>/dev/null`
+	ret=$?
+	log 2 "executing $curl_config --version"
+	log 2 "  returned $version"
+	log 2 "  exit code $ret"
+
+	if [ -z "$version" ] || [ "$ret" != "0" ]; then
+		log 1 "checking libcurl... not found"
+
+		# It was forced, so it should be found.
+		if [ "$with_curl" != "1" ]; then
+			log 1 "configure: error: curl-config couldn't be found"
+			log 1 "configure: error: you supplied '$with_curl', but it seems invalid"
+			exit 1
+		fi
+
+		curl_config=""
+		return 0
+	fi
+
+	log 1 "checking libcurl... found"
+
+}
+
 detect_freetype() {
 	# 0 means no, 1 is auto-detect, 2 is force
 	if [ "$with_freetype" = "0" ]; then
@@ -2378,6 +2435,7 @@
 	echo "  --with-sdl[=sdl-config]        enables SDL video driver support"
 	echo "  --with-zlib[=zlib.a]           enables zlib support"
 	echo "  --with-png[=libpng-config]     enables libpng support"
+	echo "  --with-curl[=curl-config]      enables libcurl support"
 	echo "  --with-freetype[=freetype-config]"
 	echo "                                 enables libfreetype support"
 	echo "  --with-fontconfig[=pkg-config fontconfig]"