truelight@3198: #!/bin/sh truelight@3198: truelight@3198: # This 'configure' script is a very easy wrapper around 'make updateconf' truelight@3198: # It allows cross-compilers to do their job much more easy. truelight@3198: truelight@3198: function showhelp() { truelight@3198: echo "Configure for OpenTTD" truelight@3198: echo "" truelight@3198: echo "Usage:" truelight@3198: echo " $0 --your_options" truelight@3198: echo "" truelight@3198: echo "Params:" truelight@3200: echo " --debug Create debug-release [no]" truelight@3200: echo " --profile Create profile-release [no]" truelight@3200: echo " --revision Set the revision of the compilation [detected]" truelight@3198: echo " --target-cc Sets the target-compiler [\$CC]" truelight@3198: echo " --target-cxx Sets the C++ target-compiler []" truelight@3198: echo " --host-cc Sets the host-compiler [\$CC]" truelight@3198: echo " --os Sets the OS. Listens to: [detected]" truelight@3198: echo " UNIX, OSX, FREEBSD, MORPHOS" truelight@3198: echo " BEOS, SUNOS, CYGWIN, MINGW" truelight@3198: echo " --windres Sets the windres (Windows) [windres]" truelight@3198: echo " --force-le Force LE platform [no]" truelight@3198: echo " --force-be Force BE platform [no]" truelight@3198: echo "" truelight@3198: echo "Params that can be used with --with or --without" truelight@3198: echo " (e.g.: --without-static disables static (default))" truelight@3198: echo " static Do you want a static build? [no]" truelight@3198: echo " directmusic Do you want direct-music? [no]" truelight@3198: echo " zlib Do you want zlib-support? [yes]" truelight@3198: echo " sdl Do you want SDL-support? [yes]" truelight@3198: echo " png Do you want PNG-support? [yes]" truelight@3198: echo " cocoa Do you want cocoa-support? (MacOSX) [no]" truelight@3198: echo "" truelight@3198: echo "Params used to configure external libs:" truelight@3198: echo " --static-zlib-path Set the path to your static zlib []" truelight@3198: echo " --sdl-config Where is your sdl-config [sdl-config]" truelight@3198: echo " --libpng-config Where is your libpng-config [libpng-config]" truelight@3198: echo " " truelight@3198: } truelight@3198: truelight@3198: function handle() { truelight@3198: PARAM="$PARAM $1=`awk 'BEGIN { FS="="; $0="'$2'"; print $2;}'`" truelight@3198: } truelight@3198: truelight@3198: # The things you can use inside this case: truelight@3198: # handle NAME VALUE - Sets the value to give the 'make upgradeconf' truelight@3198: # Value is in form: tag=REAL_VALUE truelight@3198: # ITEM="NAME" - Will set the value as above, only with the next param truelight@3198: # SITEM="NAME" - Will set the var $NAME to the next param truelight@3198: for n in $* truelight@3198: do truelight@3198: case "$n" in truelight@3198: --help | -h) truelight@3198: showhelp truelight@3198: exit 0 truelight@3198: ;; truelight@3198: truelight@3200: --debug) truelight@3200: PARAM="$PARAM DEBUG=1" truelight@3200: ;; truelight@3200: --profile) truelight@3200: PARAM="$PARAM PROFILE=1" truelight@3200: ;; truelight@3200: --revision=*) truelight@3200: RELEASE=`awk 'BEGIN { FS="="; $0="'$n'"; print $2;}'` truelight@3200: ;; truelight@3200: --revision) truelight@3200: SITEM="RELEASE" truelight@3200: ;; truelight@3198: --target-cc=*) truelight@3198: handle "CC_TARGET" $n truelight@3198: ;; truelight@3198: --target-cc) truelight@3198: ITEM="CCTARGET" truelight@3198: ;; truelight@3198: --target-cxx=*) truelight@3198: TARGET_CXX=`awk 'BEGIN { FS="="; $0="'$n'"; print $2;}'` truelight@3198: ;; truelight@3198: --target-cxx) truelight@3198: SITEM="TARGET_CXX" truelight@3198: ;; truelight@3198: --host-cc=*) truelight@3198: handle CC_HOST $n truelight@3198: ;; truelight@3198: --host-cc) truelight@3198: ITEM="CC_HOST" truelight@3198: ;; truelight@3198: --os=*) truelight@3201: TARGET_OS=`awk 'BEGIN { FS="="; $0="'$n'"; print $2;}'` truelight@3198: ;; truelight@3198: --os) truelight@3201: SITEM="TARGET_OS" truelight@3198: ;; truelight@3198: --windres=*) truelight@3198: handle WINDRES $n truelight@3198: ;; truelight@3198: --windres) truelight@3198: ITEM="WINDRES" truelight@3198: ;; truelight@3198: --force-le) truelight@3198: PARAM="$PARAM ENDIAN_FORCE=LE" truelight@3198: ;; truelight@3198: --force-be) truelight@3198: PARAM="$PARAM ENDIAN_FORCE=BE" truelight@3198: ;; truelight@3198: truelight@3198: --with-static) truelight@3198: PARAM="$PARAM STATIC=1" truelight@3198: ;; truelight@3198: --without-static) truelight@3198: PARAM="$PARAM STATIC=" truelight@3198: ;; truelight@3198: --with-directmusic) truelight@3198: PARAM="$PARAM WITH_DIRECTMUSIC=1" truelight@3198: ;; truelight@3198: --without-directmusic) truelight@3198: PARAM="$PARAM WITH_DIRECTMUSIC=" truelight@3198: ;; truelight@3198: --with-zlib) truelight@3198: PARAM="$PARAM WITH_ZLIB=1" truelight@3198: ;; truelight@3198: --without-zlib) truelight@3198: PARAM="$PARAM WITH_ZLIB=" truelight@3198: ;; truelight@3198: --with-sdl) truelight@3198: PARAM="$PARAM WITH_SDL=1" truelight@3198: ;; truelight@3198: --without-sdl) truelight@3198: PARAM="$PARAM WITH_SDL=" truelight@3198: ;; truelight@3198: --with-png) truelight@3198: PARAM="$PARAM WITH_PNG=1" truelight@3198: ;; truelight@3198: --without-png) truelight@3198: PARAM="$PARAM WITH_PNG=" truelight@3198: ;; truelight@3198: --with-cocoa) truelight@3198: PARAM="$PARAM WITH_COCOA=1" truelight@3198: ;; truelight@3198: --without-cocoa) truelight@3198: PARAM="$PARAM WITH_COCOA=" truelight@3198: ;; truelight@3198: --static-zlib-path=*) truelight@3198: handle STATIC_ZLIB_PATH $n truelight@3198: ;; truelight@3198: --static-zlib-path) truelight@3198: ITEM="STATIC_ZLIB_PATH" truelight@3198: ;; truelight@3198: --sdl-config=*) truelight@3198: handle SDL-CONFIG $n truelight@3198: ;; truelight@3198: --sdl-config) truelight@3198: ITEM="SDL-CONFIG" truelight@3198: ;; truelight@3198: --libpng-config=*) truelight@3198: handle LIBPNG-CONFIG $n truelight@3198: ;; truelight@3198: --lib-png-config) truelight@3198: ITEM="LIBPNG-CONFIG" truelight@3198: ;; truelight@3198: truelight@3198: --*=*) truelight@3198: echo -n "Unknown switch " truelight@3198: echo `awk 'BEGIN { FS="="; $0="'$n'"; print $1;}'` truelight@3198: exit 1 truelight@3198: ;; truelight@3198: -*) truelight@3198: echo "Unknown switch $n" truelight@3198: exit 1 truelight@3198: ;; truelight@3198: truelight@3198: *) truelight@3198: if ! test -z "$ITEM" truelight@3198: then truelight@3198: PARAM="$PARAM $ITEM=$n" truelight@3198: ITEM=""; truelight@3198: elif ! test -z "$SITEM" truelight@3198: then truelight@3198: export $SITEM=$n truelight@3198: SITEM="" truelight@3198: else truelight@3198: echo "Unknown switch $n" truelight@3198: exit 1 truelight@3198: fi truelight@3198: ;; truelight@3198: esac truelight@3198: done truelight@3198: truelight@3201: if ! test -z "$TARGET_OS" truelight@3198: then truelight@3201: TARGET_OS=`echo $TARGET_OS | tr '[:lower:]' '[:upper:]'` truelight@3201: case "$TARGET_OS" in truelight@3198: WIN32) truelight@3198: PARAM="$PARAM WIN32=1" truelight@3198: ;; truelight@3198: UNIX) truelight@3198: PARAM="$PARAM UNIX=1" truelight@3198: ;; truelight@3198: OSX) truelight@3198: PARAM="$PARAM OSX=1 UNIX=1" truelight@3198: ;; truelight@3198: FREEBSD) truelight@3198: PARAM="$PARAM FREEBSD=1" truelight@3198: ;; truelight@3198: MORPHOS) truelight@3198: PARAM="$PARAM MORPHOS=1 UNIX=1" truelight@3198: ;; truelight@3198: BEOS) truelight@3198: PARAM="$PARAM BEOS=1 UNIX=1" truelight@3198: ;; truelight@3198: SUNOS) truelight@3198: PARAM="$PARAM SUNOS=1 UNIX=1" truelight@3198: ;; truelight@3198: CYGWIN) truelight@3198: PARAM="$PARAM CYGWIN=1 WIN32=1" truelight@3198: ;; truelight@3198: MINGW) truelight@3198: PARAM="$PARAM MINGW=1 WIN32=1" truelight@3198: ;; truelight@3198: *) truelight@3198: echo "Unknown OS: $OS" truelight@3198: exit 1 truelight@3198: ;; truelight@3198: esac truelight@3198: PARAM="$PARAM BYPASS_OS_DETECT=1" truelight@3198: fi truelight@3198: truelight@3198: rm Makefile.config truelight@3198: make upgradeconf $PARAM truelight@3198: truelight@3198: # Makefile.config currently doesn't support custom CXX, so, we add the line truelight@3198: # ourself! truelight@3198: truelight@3199: if ! test -z "$TARGET_CXX" truelight@3199: then truelight@3199: echo "CXX=$TARGET_CXX" >> Makefile.config truelight@3199: fi truelight@3198: truelight@3200: # Same for RELEASE (read: REVISION) truelight@3200: truelight@3200: if ! test -z "$RELEASE" truelight@3200: then truelight@3200: echo "RELEASE=$RELEASE" >> Makefile.config truelight@3200: fi truelight@3200: