config.lib
branchNewGRF_ports
changeset 6871 5a9dc001e1ad
parent 6870 ca3fd1fbe311
child 6872 1c4a4a609f85
--- a/config.lib	Sat Oct 06 21:16:00 2007 +0000
+++ b/config.lib	Mon Dec 03 23:39:38 2007 +0000
@@ -805,6 +805,7 @@
 	if [ $cc_version -ge 29 ]; then
 		CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
 		CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
+		CFLAGS="$CFLAGS -Wno-uninitialized"
 
 		CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
 	fi
@@ -882,6 +883,10 @@
 		LIBS="$LIBS -pthread"
 	fi
 
+	if [ "$os" = "FREEBSD" ]; then
+		LIBS="$LIBS -lpthread"
+	fi
+
 	if [ "$os" = "OSX" ]; then
 		LDFLAGS="$LDFLAGS -framework Cocoa"
 		if [ "$enable_dedicated" = "0" ]; then
@@ -1003,6 +1008,10 @@
 			CFLAGS="$CFLAGS -I$with_iconv/include"
 			LIBS="$LIBS -L$with_iconv/lib"
 		fi
+
+		if [ "$have_broken_iconv" != "no" ]; then
+			CFLAGS="$CFLAGS -DHAVE_BROKEN_ICONV"
+		fi
 	fi
 
 	if [ -n "$with_midi" ]; then
@@ -1849,6 +1858,32 @@
 	log 2 "found iconv in $iconv"
 
 	log 1 "checking iconv... found"
+
+	# Check if we need to work around buggy iconv implementation where inbuf
+	# is wrongly typed as non-const. Correct implementation is at
+	# http://www.opengroup.org/onlinepubs/007908799/xsh/iconv.html
+
+	cat > tmp.iconv.cpp << EOF
+#include "src/stdafx.h"
+#include <iconv.h>
+int main() {
+	static char buf[1024];
+	iconv_t convd = 0;
+	const char *inbuf = "";
+	char *outbuf  = buf;
+	size_t outlen = 1023;
+	size_t inlen  = 0;
+	return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
+}
+EOF
+	execute="$cxx_host $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
+	eval $execute >&/dev/null
+	ret=$?
+	log 2 "executing $execute"
+	log 2 "  exit code $ret"
+	if [ "$ret" = "0" ]; then have_broken_iconv="no"; else have_broken_iconv="yes"; fi
+	log 1 "checking if iconv has non-const inbuf... $have_broken_iconv"
+	rm -f tmp.iconv tmp.iconv.cpp
 }
 
 _detect_sort() {