(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
This commit is contained in:
bjarni
2006-03-23 23:54:43 +00:00
parent 747fe64b31
commit 41f4c473da
5 changed files with 39 additions and 4 deletions

View File

@@ -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,)

View File

@@ -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

View File

@@ -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;
}