OpenTTD-patches/makefiledir/Makefile.libdetection
bjarni 41f4c473da (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
2006-03-23 23:54:43 +00:00

133 lines
2.6 KiB
Makefile

# this file detects what OS and libs the computer have/are running
ifndef CONFIG_VERSION
CONFIG_VERSION:=0
endif
ifeq ($(shell expr $(CONFIG_VERSION) \< 9), 1)
ifndef BYPASS_OS_DETECT
# Automatically recognize if building on Win32
ifdef WINDIR
ifndef UNIX
WIN32:=1
CYGWIN:=1
MINGW:=1
STATIC:=1
SKIP_STATIC_CHECK:=1
endif
else
UNIX:=1
endif
# Automatically recognize if building on FreeBSD
ifeq ($(shell uname),FreeBSD)
FREEBSD:=1
endif
# Automatically recognize if building on MacOSX
ifeq ($(shell uname), Darwin)
OSX:=1
# OSX uses the unix setup too
UNIX:=1
endif
# Automatically recognize if building on MorphOS
ifeq ($(shell uname), MorphOS)
MORPHOS:=1
# MorphOS uses UNIX setup too
UNIX:=1
endif
# Automatically recognize if building on BeOS
ifeq ($(shell uname), BeOS)
BEOS:=1
# BeOS uses UNIX setup too
UNIX:=1
# Except that in BeOS 5.0 we need to use net_server, not BONE networking
ifeq ($(shell uname -r), 5.0)
BEOS_NET_SERVER:=1
endif
endif
# Automatically recognize if building on SunOS/Solaris
ifeq ($(shell uname), SunOS)
SUNOS:=1
# SunOS uses UNIX setup too
UNIX:=1
endif
# END BYPASS_OS_DETECT
endif
# FreeBSD uses sdl11 instead of sdl
ifdef FREEBSD
SDL-CONFIG:=sdl11-config
else
SDL-CONFIG:=sdl-config
endif
# Networking, enabled by default
WITH_NETWORK:=1
# Library detections
WITH_SDL:=$(shell $(SDL-CONFIG) --version 2>/dev/null)
# libpng detection
WITH_PNG:=$(shell $(LIBPNG-CONFIG) --version 2>/dev/null)
ifdef WITH_PNG
# LibPNG depends on Zlib
WITH_ZLIB:=1
else
# We go looking for zlib with a little hack
WITH_ZLIB:=$(shell ls /usr/include | grep "zlib.h" 2>/dev/null) \
$(shell ls /usr/local/include | grep "zlib.h" 2>/dev/null)
ifdef WITH_ZLIB
WITH_ZLIB:=1
endif
endif
# sets the default paths
ifdef UNIX
ifndef OSX
ifndef MORPHOS
ifndef BIN_DIR
#BINARY_DIR:=
#DATA_DIR_PREFIX:=
#INSTALL_DIR:=/usr/local/
#USE_HOMEDIR:=
endif
endif
endif
endif
ifdef OSX
# we prefer to use cocoa drivers rather than SDL drivers
# if you really want SDL drivers, you can always modify Makefile.config
ifndef DEDICATED
WITH_COCOA:=1
WITH_SDL:=
endif
endif
# workaround
# cygwin have problems with libpng, so we will just disable it for now until the problem is solved
ifdef CYGWIN
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