From 8ff3e5ab2014528318326c9a397b5e05d9fe4ead Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Sat, 24 Jul 2010 17:51:08 +0000
Subject: [PATCH] iconv now tested in configure.sh
---
Rules.make.standalone | 2 +-
Rules.make.system | 2 +-
configure.sh | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/Rules.make.standalone b/Rules.make.standalone
index d45328e..1b2d38b 100644
--- a/Rules.make.standalone
+++ b/Rules.make.standalone
@@ -27,7 +27,7 @@ LUA_LFLAGS=$(shell pkg-config --libs lua5.1)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LFLAGS=$(shell sdl-config --libs) -lSDL_ttf -lSDL_mixer -lSDL_image
-CFLAGS += -g -Wall -D_HAVE_ICONV -Dunix -D_USE_UNPACK -D_LOCAL_APPDATA # -D_SDL_MOD_BUG
+CFLAGS += -g -Wall -Dunix -D_USE_UNPACK -D_LOCAL_APPDATA # -D_SDL_MOD_BUG
INSTALLD=echo "Do not install standalone version!"
INSTALLB=echo "Do not install standalone version!"
diff --git a/Rules.make.system b/Rules.make.system
index 490a9d4..ce09a5d 100644
--- a/Rules.make.system
+++ b/Rules.make.system
@@ -28,7 +28,7 @@ LUA_LFLAGS=$(shell pkg-config --libs lua5.1)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LFLAGS=$(shell sdl-config --libs) -lSDL_ttf -lSDL_mixer -lSDL_image
-CFLAGS += -Wall -Dunix -D_HAVE_ICONV -D_USE_UNPACK # -D_SDL_MOD_BUG
+CFLAGS += -Wall -Dunix -D_USE_UNPACK # -D_SDL_MOD_BUG
INSTALLD=install -d -m 0755
INSTALLB=install -m 0755
diff --git a/configure.sh b/configure.sh
index 74c4482..be289da 100755
--- a/configure.sh
+++ b/configure.sh
@@ -1,4 +1,6 @@
#!/bin/bash
+cflags=""
+lflags=""
echo -n "Checking pkg-config..."
if ! pkg-config --version >/dev/null 2>&1; then
@@ -109,11 +111,46 @@ if ! $cc /tmp/sdl-test.c $ops `sdl-config --cflags` `sdl-config --libs` -lSDL_tt
fi
echo "ok"
rm -f /tmp/sdl-test.c /tmp/sdl-test
+
+cat << EOF >/tmp/iconv-test.c
+#include
+int main(int argc, char **argv)
+{
+ iconv_open("","");
+}
+EOF
+echo $cc
+echo -n "Checking iconv...("
+echo -n "$cc /tmp/iconv-test.c -o iconv-test)..."
+if ! $cc /tmp/iconv-test.c -o iconv-test; then
+ if ! $cc /tmp/iconv-test.c -liconv -o iconv-test; then
+ echo -n "failed. Build without iconv.".
+ else
+ cflags="-D_HAVE_ICONV"
+ lflags="-liconv"
+ echo "ok, with -liconv"
+ fi
+else
+ cflags="-D_HAVE_ICONV"
+ echo "ok"
+fi
+
+rm -f /tmp/iconv-test.c /tmp/iconv-test
+
if ! make clean >/dev/null 2>&1; then
echo " * Warning!!! Can not do make clean..."
fi
echo -n "Generating config.make..."
echo "# autamatically generated by configure.sh" >config.make
+
+if [[ ! -z "$cflags" ]]; then
+ echo "EXTRA_CFLAGS+=$cflags" >> config.make
+fi
+
+if [[ ! -z "$lflags" ]]; then
+ echo "EXTRA_LDFLAGS+=$lflags" >> config.make
+fi
+
if [[ ! -z "$gtk_cflags" ]]; then
echo "EXTRA_CFLAGS+=-D_USE_GTK -D_USE_BROWSE" >> config.make
echo "EXTRA_CFLAGS+=\$(shell $gtk_cflags)" >> config.make