[Scummvm-cvs-logs] SF.net SVN: scummvm:[46655] tools/branches/gsoc2009-gui

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Dec 27 19:51:57 CET 2009


Revision: 46655
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46655&view=rev
Author:   lordhoto
Date:     2009-12-27 18:51:57 +0000 (Sun, 27 Dec 2009)

Log Message:
-----------
Added initial code for auto detection of iconv (hopefully this will work fine with FreeBSD's iconv implementation too).

Modified Paths:
--------------
    tools/branches/gsoc2009-gui/Makefile.common
    tools/branches/gsoc2009-gui/configure
    tools/branches/gsoc2009-gui/create_sjisfnt.cpp

Modified: tools/branches/gsoc2009-gui/Makefile.common
===================================================================
--- tools/branches/gsoc2009-gui/Makefile.common	2009-12-27 18:24:48 UTC (rev 46654)
+++ tools/branches/gsoc2009-gui/Makefile.common	2009-12-27 18:51:57 UTC (rev 46655)
@@ -68,9 +68,11 @@
 	scummvm-tools-cli$(EXEEXT)
 
 ifdef USE_FREETYPE
+ifdef USE_ICONV
 TARGETS += \
 	create_sjisfnt$(EXEEXT)
 endif
+endif
 
 ifdef USE_WXWIDGETS
 TARGETS += \
@@ -147,9 +149,9 @@
 
 
 create_sjisfnt_OBJS := create_sjisfnt.o $(UTILS)
-create_sjisfnt_LIBS := $(FREETYPELIBS) #-liconv # TODO: Some systems seem to require "iconv" to be linked, we need to handle that...
+create_sjisfnt_LIBS := $(FREETYPELIBS) $(ICONVLIBS)
 # Set custom build flags
-create_sjisfnt.o: CPPFLAGS+=$(FREETYPEINCLUDES)
+create_sjisfnt.o: CPPFLAGS+=$(FREETYPEINCLUDES) $(ICONVCFLAGS)
 
 
 sword2_clue_OBJS := engines/sword2/sword2_clue.o

Modified: tools/branches/gsoc2009-gui/configure
===================================================================
--- tools/branches/gsoc2009-gui/configure	2009-12-27 18:24:48 UTC (rev 46654)
+++ tools/branches/gsoc2009-gui/configure	2009-12-27 18:51:57 UTC (rev 46655)
@@ -77,6 +77,7 @@
 _png=auto
 _wxwidgets=auto
 _freetype=auto
+_iconv=auto
 _endian=unknown
 _need_memalign=no
 _verbose_build=no
@@ -316,6 +317,8 @@
 	--disable-wxwidgets)      _wxwidgets=no   ;;
 	--enable-freetype)        _freetype=yes   ;;
 	--disable-freetype)       _freetype=no    ;;
+	--enable-iconv)           _iconv=yes      ;;
+	--disable-iconv)          _iconv=no       ;;
 	--enable-verbose-build)   _verbose_build=yes ;;
 	--with-ogg-prefix=*)
 		arg=`echo $ac_option | cut -d '=' -f 2`
@@ -627,7 +630,6 @@
 		DEFINES="$DEFINES -DUNIX"
 		LDFLAGS="$LDFLAGS -L/usr/local/lib"
 		CXXFLAGS="$CXXFLAGS -I/usr/local/include"
-		_iconv_const=yes
 		;;
 	beos*)
 		DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
@@ -950,6 +952,89 @@
 echo "$freetype_version"
 
 #
+# Check for iconv
+#
+echo_n "Checking whether iconv.h is present... "
+if test "$_iconv" = auto ; then
+	_iconv=no
+	cat > $TMPC << EOF
+#include <iconv.h>
+int main(int, char **) {
+	return 0;
+}
+EOF
+	cc_check $LDFLAGS $CXXFLAGS && _iconv=yes
+fi
+
+create_iconv_test() {
+	cat > $TMPC << EOF
+#include <iconv.h>
+int main(int, char **) {
+	iconv_t iconv = iconv_open("UTF-32", "SJIS");
+	iconv_close(iconv);
+	return 0;
+}
+EOF
+}
+echo "$_iconv"
+
+if test "$_iconv" = yes ; then
+	echo_n "Checking whether iconv needs linking against libiconv... "
+
+	needs_iconvlib='auto'
+	create_iconv_test
+	cc_check $LDFLAGS $CXXFLAGS -liconv && needs_iconvlib='yes'
+	# We do check linking without -liconv here too, just in case
+	# it would fail otherwise too
+	create_iconv_test
+	cc_check $LDFLAGS $CXXFLAGS && needs_iconvlib='no'
+
+	if test "$needs_iconvlib" = auto ; then
+		_iconv=no
+		echo "does not link at all"
+	else
+		if test "$needs_iconvlib" = yes ; then
+			_iconvlibs='-liconv'
+		else
+			_iconvlibs=''
+		fi
+		echo "$needs_iconvlib"
+
+		echo_n "Checking signature of iconv... "
+		uses_const=no
+
+		cat > $TMPC << EOF
+#include <iconv.h>
+int main(int, char **) {
+	iconv_t iconv;
+	const char **inbuf = 0;
+	iconv(iconv, inbuf, 0, 0, 0);
+	return 0;
+}
+EOF
+		cc_check $LDFLAGS $CXXFLAGS $_iconvlibs && uses_const = yes
+
+		if test "$uses_const" = yes ; then
+			echo "iconv_t, const char **, size_t *, char **, size_t *"
+			_iconvcflags='-DICONV_USES_CONST'
+		else
+			echo "iconv_t, char **, size_t *, char **, size_t *"
+			_iconvcflags='-UICONV_USES_CONST'
+		fi
+	fi
+fi
+
+if test "$_iconv" = yes ; then
+	_def_iconv='#define USE_ICONV'
+else
+	_def_iconv='#undef USE_ICONV'
+fi
+
+echocheck "iconv"
+add_to_config_mk_if_yes "$_iconv" 'USE_ICONV = 1'
+echo "$_iconv"
+
+#
 # Check for wxWidgets
 #
 if test "$_wxwidgets" = auto ; then
@@ -1039,6 +1124,7 @@
 $_def_zlib
 $_def_png
 $_def_freetype
+$_def_iconv
 
 #endif /* CONFIG_H */
 EOF
@@ -1081,6 +1167,9 @@
 FREETYPEINCLUDES := $_freetypeincludes
 FREETYPELIBS := $_freetypelibs
 
+ICONVLIBS := $_iconvlibs
+ICONVCFLAGS := $_iconvcflags
+
 SAVED_CONFIGFLAGS  := $SAVED_CONFIGFLAGS
 SAVED_LDFLAGS      := $SAVED_LDFLAGS
 SAVED_CXX          := $SAVED_CXX

Modified: tools/branches/gsoc2009-gui/create_sjisfnt.cpp
===================================================================
--- tools/branches/gsoc2009-gui/create_sjisfnt.cpp	2009-12-27 18:24:48 UTC (rev 46654)
+++ tools/branches/gsoc2009-gui/create_sjisfnt.cpp	2009-12-27 18:51:57 UTC (rev 46655)
@@ -337,8 +337,11 @@
 
 	size_t inBufSize = sizeof(inBuf);
 	size_t outBufSize = sizeof(outBuf);
-	// This need to be "char *", because iconv requires the second parameter to be "char **" (at least on Linux).
+#ifdef ICONV_USES_CONST
+	const char *inBufWrap = inBuf;
+#else
 	char *inBufWrap = inBuf;
+#endif
 	char *outBufWrap = outBuf;
 
 	if (iconv(confSetup, &inBufWrap, &inBufSize, &outBufWrap, &outBufSize) == (size_t)-1)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list