diff options
author | bjarni <bjarni@openttd.org> | 2006-03-23 23:54:43 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2006-03-23 23:54:43 +0000 |
commit | 10936e70345e4d462517e35511f0e56b69c444e9 (patch) | |
tree | 6ffab345b4e5937c329ed5663a3b4bd2a268b369 | |
parent | 541703a2f6687fcb7d9f4d1453f84d80b67cd58c (diff) | |
download | openttd-10936e70345e4d462517e35511f0e56b69c444e9.tar.xz |
(svn r4074) -Feature: [Makefile] the makefile can now detect if iconv is present in the system
if detected, WITH_ICONV will be defined in the C code
WITH_ICONV is also added to Makefile.config
OSX do not use this flag setting in Makefile.config, as it is set at compile time based on target OS version
the actual C code is not changed as the current iconv code is hardcoded for OSX and would break if any other OS got iconv
This detection system is by request of Darkvater
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | makefiledir/Makefile.config_writer | 2 | ||||
-rw-r--r-- | makefiledir/Makefile.libdetection | 9 | ||||
-rw-r--r-- | makefiledir/iconv_detector.c | 18 | ||||
-rw-r--r-- | os/macosx/Makefile.setup | 7 |
5 files changed, 39 insertions, 4 deletions
@@ -130,7 +130,7 @@ # Makefile version tag # it checks if the version tag in Makefile.config is the same and force update outdated config files -MAKEFILE_VERSION:=9 +MAKEFILE_VERSION:=10 # CONFIG_WRITER has to be found even for manual configuration CONFIG_WRITER=makefiledir/Makefile.config_writer @@ -485,10 +485,9 @@ LIBS += $(shell $(LIBPNG-CONFIG) --L_opts $(PNGCONFIG_FLAGS)) endif endif -ifdef OSX -ifndef JAGUAR +ifdef WITH_ICONV LIBS += -liconv -endif +CFLAGS += -DWITH_ICONV endif # enables/disables assert() diff --git a/makefiledir/Makefile.config_writer b/makefiledir/Makefile.config_writer index 581411c54..60c6727ba 100644 --- a/makefiledir/Makefile.config_writer +++ b/makefiledir/Makefile.config_writer @@ -64,9 +64,11 @@ $(MAKE_CONFIG): $(call CONFIG_LINE,) $(call CONFIG_LINE,\# Libs) + $(call CONFIG_LINE,\# WITH_ICONV is not used on OSX since the flag is overwritten. It is always used unless the target OS is 10.2.8) $(call CONFIG_LINE,WITH_ZLIB:=$(WITH_ZLIB)) $(call CONFIG_LINE,WITH_SDL:=$(WITH_SDL)) $(call CONFIG_LINE,WITH_PNG:=$(WITH_PNG)) + $(call CONFIG_LINE,WITH_ICONV:=$(WITH_ICONV)) $(call CONFIG_LINE,STATIC_ZLIB_PATH:=$(STATIC_ZLIB_PATH)) $(call CONFIG_LINE,WITH_COCOA:=$(WITH_COCOA)) $(call CONFIG_LINE,) diff --git a/makefiledir/Makefile.libdetection b/makefiledir/Makefile.libdetection index 237c02f98..47d8edee1 100644 --- a/makefiledir/Makefile.libdetection +++ b/makefiledir/Makefile.libdetection @@ -121,3 +121,12 @@ WITH_PNG:= endif endif + +ifeq ($(shell expr $(CONFIG_VERSION) \< 10), 1) +# we need to test if iconv is present on the current system +# even though we test on OSX, the read data is actually not used since it relies on target OS and this flag will be overwritten later + +$(shell $(CC) -liconv -o makefiledir/iconv_detector makefiledir/iconv_detector.c 2>/dev/null) +WITH_ICONV:=$(shell makefiledir/iconv_detector 2>/dev/null) +$(shell rm makefiledir/iconv_detector 2>/dev/null) +endif diff --git a/makefiledir/iconv_detector.c b/makefiledir/iconv_detector.c new file mode 100644 index 000000000..709656cb9 --- /dev/null +++ b/makefiledir/iconv_detector.c @@ -0,0 +1,18 @@ +/* $Id$ */ + +#include <stdlib.h> +#include <iconv.h> +#include <stdio.h> + +/* this is a pretty simple app, that will return 1 if it manages to compile and execute + * This means that it can be used by the makefile to detect if iconv is present on the current system + * no iconv means this file fails and will return nothing */ + +int main () +{ + iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + printf("1\n"); + return 0; +} diff --git a/os/macosx/Makefile.setup b/os/macosx/Makefile.setup index 159bf0aa5..92969ae43 100644 --- a/os/macosx/Makefile.setup +++ b/os/macosx/Makefile.setup @@ -84,3 +84,10 @@ $(shell $(CC) os/macosx/G5_detector.c -o os/macosx/G5_detector) endif endif endif + +# the OSX port need Apple's modified iconv to use the charset UTF-8-MAC. This was added by default in 10.3, but is not present in earlier versions +ifdef JAGUAR + WITH_ICONV:= +else + WITH_ICONV:=1 +endif |