--- a/config.lib Wed Jun 13 12:05:56 2007 +0000
+++ b/config.lib Tue Jun 19 07:21:01 2007 +0000
@@ -22,17 +22,15 @@
awk="awk"
os="DETECT"
endian="AUTO"
+ cpu_type="DETECT"
revision=""
config_log="config.log"
prefix_dir="/usr/local"
binary_dir="games"
data_dir="share/games/openttd"
icon_dir="share/pixmaps"
- personal_dir=""
- custom_lang_dir=""
- second_data_dir=""
+ personal_dir="1"
install_dir="/"
- enable_install="0"
enable_debug="0"
enable_profiling="0"
enable_dedicated="0"
@@ -45,6 +43,7 @@
enable_osx_g5="0"
enable_unicode="1"
with_distcc="1"
+ with_ccache="1"
with_osx_sysroot="1"
with_application_bundle="1"
with_sdl="1"
@@ -62,7 +61,7 @@
with_fontconfig="1"
with_psp_config="1"
- save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir custom_lang_dir second_data_dir enable_install enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_distcc with_osx_sysroot enable_universal enable_osx_g5 enable_unicode with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config CC CXX CFLAGS LDFLAGS"
+ save_params_array="build host cc_build cc_host cxx_build cxx_host windres strip awk lipo os cpu_type revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_distcc with_ccache with_osx_sysroot enable_universal enable_osx_g5 enable_unicode with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_libtimidity with_freetype with_fontconfig with_psp_config CC CXX CFLAGS LDFLAGS"
}
detect_params() {
@@ -92,6 +91,9 @@
--os) prev_p="os";;
--os=*) os="$optarg";;
+ --cpu-type) prev_p="cpu_type";;
+ --cpu-type=*) cpu_type="$optarg";;
+
--revision=*) revision="$optarg";;
--cc-build) prevp_p="cc_build";;
@@ -130,20 +132,11 @@
--personal-dir) prevp_p="personal-dir";;
--personal-dir=*) personal_dir="$optarg";;
+ --without-personal-dir) personal_dir="";;
--install-dir) prevp_p="install-dir";;
--install-dir=*) install_dir="$optarg";;
-# TODO: The next few cases will be removed when the search path patch is applied
- --custom-lang-dir) prevp_p="custom-lang-dir";;
- --custom-lang-dir=*) custom_lang_dir="$optarg";;
-
- --second-data-dir) prevp_p="second-data-dir";;
- --second-data-dir=*) second_data_dir="$optarg";;
-
- --enable-install) enable_install="1";;
- --enable-install=*) enable_install="$optarg";;
-# TODO: End of to be removed cases
--enable-debug) enable_debug="1";;
@@ -240,6 +233,10 @@
--with-distcc) with_distcc="2";;
--with-distcc=*) with_distcc="$optarg";;
+ --without-ccache) with_ccache="0";;
+ --with-ccache) with_ccache="2";;
+ --with-ccache=*) with_ccache="$optarg";;
+
--without-osx-sysroot) with_osx_sysroot="0";;
--with-osx-sysroot) with_osx_sysroot="2";;
--with-osx-sysroot=*) with_osx_sysroot="$optarg";;
@@ -301,6 +298,7 @@
endian=`echo $endian | tr '[a-z]' '[A-Z]'`
os=`echo $os | tr '[a-z]' '[A-Z]'`
+ cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'`
# Check if all params have valid values
@@ -316,6 +314,12 @@
echo " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2|WINCE|PSP]"
exit 1
fi
+ # cpu_type can be either 32 or 64
+ if [ -z "`echo $cpu_type | grep '^32$\|^64$\|^DETECT$'`" ]; then
+ echo "configure: error: invalid option --cpu-type=$cpu_type"
+ echo " Available options are: --cpu-type[=DETECT|32|64]"
+ exit 1
+ fi
# enable_debug should be between 0 and 4
if [ -z "`echo $enable_debug | grep '^[0123]$'`" ]; then
echo "configure: error: invalid option --enable-debug=$enable_debug"
@@ -359,6 +363,7 @@
fi
check_lipo
check_makedepend
+ detect_cputype
if [ "$enable_static" = "1" ]; then
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "OSX" ]; then
@@ -546,6 +551,35 @@
log 1 "checking distcc... $distcc"
fi
+ if [ "$with_ccache" = "0" ]; then
+ log 1 "checking ccache... no"
+ elif [ "$with_ccache" = "1" ]; then
+ with_ccache="0"
+
+ log 1 "checking ccache... no (only used when forced)"
+ elif [ "$with_ccache" = "2" ]; then
+ ccache="ccache"
+ else
+ ccache="$with_ccache"
+ fi
+ if [ "$with_ccache" != "0" ]; then
+ res="`$ccache --version 2>/dev/null | head -n 1 | cut -b 0-6`"
+ if [ "$res" != "ccache" ]; then
+ ccache=""
+ log 1 "checking ccache... no"
+ if [ "$with_ccache" = "2" ]; then
+ log 1 "configure: error: no ccache detected, but was forced to be used"
+ exit 1
+ fi
+ if [ "$with_ccache" != "1" ]; then
+ log 1 "configure: error: '$with_ccache' doesn't seem a ccache to me"
+ exit 1
+ fi
+ fi
+
+ log 1 "checking ccache... $ccache"
+ fi
+
if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
if [ "$with_osx_sysroot" = "1" ]; then
with_osx_sysroot="0"
@@ -589,21 +623,6 @@
if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ]; then
OSXAPP="OpenTTD.app"
-
-# TODO: remove next few lines of code when the search path patch has been applied
- if [ -n "$custom_lang_dir" ] && [ "$custom_lang_dir" != "${OSXAPP}/Contents/Resources/lang/" ]; then
- log 1 "configure: error: --custom-lang-dir and --with-application-bundle are not compatible
- exit 1
- fi
-
- if [ -n "$custom_lang_dir" ] && [ "$second_data_dir" != "${OSXAPP}/Contents/Resources/data/" ]; then
- log 1 "configure: error: --second-data-dir and --with-application-bundle are not compatible
- exit 1
- fi
-
- custom_lang_dir="${OSXAPP}/Contents/Resources/lang/"
- second_data_dir="${OSXAPP}/Contents/Resources/data/"
-# TODO: remove till here
else
OSXAPP=""
fi
@@ -686,6 +705,30 @@
sleep 5
fi
fi
+
+ if [ "$personal_dir" = "1" ]; then
+ if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
+ personal_dir="OpenTTD"
+ elif [ "$os" = "OSX" ]; then
+ personal_dir="Documents/OpenTTD"
+ else
+ personal_dir=".openttd"
+ fi
+ fi
+
+ if [ -n "$personal_dir" ]
+ then
+ log 1 "personal home directory... $personal_dir"
+ else
+ log 1 "personal home directory... none"
+ fi
+
+ if [ -n "$install_dir" ]
+ then
+ log 1 "installation directory... $install_dir"
+ else
+ log 1 "installation directory... none"
+ fi
}
make_cflags_and_ldflags() {
@@ -984,29 +1027,11 @@
LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$with_osx_sysroot.sdk"
fi
-# TODO: remove next few lines of code when the search path patch has been applied
- if [ -n "$second_data_dir" ]; then
- CFLAGS="$CFLAGS -DSECOND_DATA_DIR=\\\\\"$second_data_dir\\\\\""
+ if [ -n "$personal_dir" ]; then
+ CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
fi
- if [ -n "$custom_lang_dir" ]; then
- CFLAGS="$CFLAGS -DCUSTOM_LANG_DIR=\\\\\"$custom_lang_dir\\\\\""
- fi
-# TODO: remove till here
-
- if [ "$enable_install" = "1" ]; then
- if [ -n "$personal_dir" ]; then
- CFLAGS="$CFLAGS -DUSE_HOMEDIR=1 -DPERSONAL_DIR=\\\\\"$personal_dir/\\\\\""
- fi
-
- if [ -n "$data_dir" ]; then
- CFLAGS="$CFLAGS -DGAME_DATA_DIR=\\\\\"$prefix_dir/$data_dir/\\\\\""
- fi
-
- if [ -n "$icon_dir" ]; then
- CFLAGS="$CFLAGS -DICON_DIR=\\\\\"$prefix_dir/$icon_dir/\\\\\""
- fi
- fi
+ CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
log 1 "using LDFLAGS... $LIBS $LDFLAGS"
@@ -1030,6 +1055,11 @@
log 1 " NOTICE: remind yourself to use 'make -jN' to make use of distcc"
log 1 ""
fi
+
+ if [ "$with_ccache" != "0" ]; then
+ cc_host="$ccache $cc_host"
+ cxx_host="$ccache $cxx_host"
+ fi
}
check_compiler() {
@@ -1467,6 +1497,9 @@
# $2 - library name ('zlib', sets $zlib)
# $3 - static library name (libz.a)
# $4 - header name (zlib.h)
+ # $5 - force static (if non-empty)
+
+ if [ -n "$5" ]; then force_static="1"; fi
# 0 means no, 1 is auto-detect, 2 is force
if [ "$1" = "0" ]; then
@@ -1491,7 +1524,7 @@
fi
eval "res=\$$2"
- if [ -n "$res" ] && [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
+ if [ -n "$res" ] && ( [ -n "$force_static" ] || ( [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] ) ); then
eval "res=\$$2"
log 2 " trying $res... found"
# Now find the static lib, if needed
@@ -1854,6 +1887,25 @@
fi
}
+detect_cputype() {
+ if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then
+ log 1 "forcing cpu-type... $cpu_type bits"
+ return;
+ fi
+ echo "#include \"src/stdafx.h\"" > tmp.64bit.cpp
+ echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp
+ echo "int main() { return 0; }" >> tmp.64bit.cpp
+ execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1"
+ cpu_type="`eval $execute 2>/dev/null`"
+ ret=$?
+ log 2 "executing $execute"
+ log 2 " returned $cpu_type"
+ log 2 " exit code $ret"
+ if [ "$ret" = "0" ]; then cpu_type="64"; else cpu_type="32"; fi
+ log 1 "detecting cpu-type... $cpu_type bits"
+ rm -f tmp.64bit tmp.64bit.cpp
+}
+
make_sed() {
# We check here if we are PPC, because then we need to enable FOUR_BYTE_BOOL
# We do this here, and not sooner, so universal builds also have this
@@ -1935,7 +1987,6 @@
s#!!REVISION!!#$revision#g;
s#!!AWK!!#$awk#g;
s#!!GCC295!!#$gcc295#g;
- s#!!ENABLE_INSTALL!!#$enable_install#g;
s#!!DISTCC!!#$distcc#g;
"
}
@@ -2051,18 +2102,10 @@
echo " [share/games/openttd]"
echo " --icon-dir=dir location of icons. Will be prefixed"
echo " with the prefix-dir [share/pixmaps]"
- echo " --personal-dir=dir location of the personal directory []"
+ echo " --personal-dir=dir location of the personal directory [.openttd]"
echo " --install-dir=dir specifies the root to install to."
echo " Useful to install into jails [/]"
echo ""
-# TODO: The Following 3 tags will be removed when the 'search path patch' is applied
- echo " --second-data-dir=dir specifies a second directory for the"
- echo " data files"
- echo " --custom-lang-dir=dir specifies a custom directory for the"
- echo " language files"
- echo " --enable-install make a binary that uses the specified"
- echo " data-dir and icon-dir"
- echo ""
echo "Features and packages:"
echo " --enable-debug[=LVL] enable debug-mode (LVL=[0123], 0 is release)"
echo " --enable-profiling enables profiling"