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@3302: echo " --dedicated Make a dedicated build [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]" peter1138@4094: echo " --host-cxx Sets the C++ host-compiler []" 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]" Darkvater@3408: echo " iconv Do you want iconv-support? [no]" Darkvater@4827: echo " network Do you want network-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]" Darkvater@3408: echo " --with-iconv Set the path to your iconv headers []" truelight@3198: echo " " truelight@3198: } truelight@3198: truelight@3198: function handle() { truelight@3305: 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@3221: 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@3205: DEBUG_SET=1 truelight@3205: ITEM="DEBUG" truelight@3205: ;; truelight@3205: --debug=*) truelight@3305: handle "DEBUG" "$n" truelight@3200: ;; truelight@3200: --profile) truelight@3200: PARAM="$PARAM PROFILE=1" truelight@3200: ;; truelight@3302: --dedicated) truelight@3302: PARAM="$PARAM DEDICATED=1" truelight@3302: ;; truelight@3200: --revision=*) truelight@3305: RELEASE=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'` truelight@3200: ;; truelight@3200: --revision) truelight@3200: SITEM="RELEASE" truelight@3200: ;; truelight@3198: --target-cc=*) truelight@3305: handle "CC_TARGET" "$n" truelight@3198: ;; truelight@3198: --target-cc) truelight@3305: ITEM="CC_TARGET" truelight@3198: ;; truelight@3198: --target-cxx=*) peter1138@4094: handle "CXX_TARGET" "$n" truelight@3198: ;; truelight@3198: --target-cxx) peter1138@4094: SITEM="CXX_TARGET" truelight@3198: ;; truelight@3198: --host-cc=*) peter1138@4094: handle "CC_HOST" "$n" truelight@3198: ;; truelight@3198: --host-cc) truelight@3198: ITEM="CC_HOST" truelight@3198: ;; peter1138@4094: --host-cxx=*) peter1138@4094: handle "CXX_HOST" "$n" peter1138@4094: ;; peter1138@4094: --host-cxx) peter1138@4094: ITEM="CXX_HOST" peter1138@4094: ;; truelight@3306: --host-cflags=*) truelight@3306: handle CFLAGS_HOST "$n" truelight@3306: ;; truelight@3306: --host-cflags) truelight@3306: ITEM="CFLAGS_HOST" truelight@3306: ;; truelight@3198: --os=*) truelight@3305: 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@3305: 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: ;; Darkvater@3408: --with-iconv) Darkvater@3408: PARAM="$PARAM WITH_ICONV=1" Darkvater@3408: ;; Darkvater@3408: --with-iconv=*) Darkvater@3408: PARAM="$PARAM WITH_ICONV=1" Darkvater@3408: handle WITH_ICONV_PATH "$n" Darkvater@3408: ;; Darkvater@3408: --without-iconv) Darkvater@3408: PARAM="$PARAM WITH_ICONV=" Darkvater@3408: ;; truelight@3198: --with-cocoa) truelight@3198: PARAM="$PARAM WITH_COCOA=1" truelight@3198: ;; Darkvater@4827: --with-network) Darkvater@4827: PARAM="$PARAM WITH_NETWORK=1" Darkvater@4827: ;; Darkvater@4827: --without-network) Darkvater@4827: PARAM="$PARAM WITH_NETWORK=" Darkvater@4827: ;; truelight@3198: --without-cocoa) truelight@3198: PARAM="$PARAM WITH_COCOA=" truelight@3198: ;; truelight@3198: --static-zlib-path=*) truelight@3305: handle STATIC_ZLIB_PATH "$n" truelight@3198: ;; truelight@3198: --static-zlib-path) truelight@3198: ITEM="STATIC_ZLIB_PATH" truelight@3198: ;; truelight@3198: --sdl-config=*) peter1138@3406: handle SDL_CONFIG "$n" truelight@3198: ;; truelight@3198: --sdl-config) peter1138@3406: ITEM="SDL_CONFIG" truelight@3198: ;; truelight@3198: --libpng-config=*) peter1138@3406: handle LIBPNG_CONFIG "$n" truelight@3198: ;; peter1138@4094: --libpng-config) peter1138@3406: ITEM="LIBPNG_CONFIG" truelight@3198: ;; truelight@3198: truelight@3198: --*=*) truelight@3198: echo -n "Unknown switch " truelight@3305: 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@3305: PARAM="$PARAM $ITEM=\"$n\"" truelight@3198: ITEM=""; truelight@3198: elif ! test -z "$SITEM" truelight@3198: then truelight@3305: 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@3202: echo "Unknown OS: $TARGET_OS" truelight@3198: exit 1 truelight@3198: ;; truelight@3198: esac truelight@3198: PARAM="$PARAM BYPASS_OS_DETECT=1" truelight@3198: fi truelight@3198: truelight@3205: if ! test -z "$DEBUG_SET" truelight@3205: then truelight@3205: if test -z "`echo $PARAM | grep "DEBUG="`" truelight@3205: then truelight@3205: # Someone did --debug, without assigning a value, assume 1 truelight@3205: PARAM="$PARAM DEBUG=1" truelight@3205: fi truelight@3205: fi truelight@3205: truelight@3205: # First remove the Makefile.config, else you can have double entries tron@4009: rm -f Makefile.config truelight@3205: truelight@3305: echo "make upgradeconf $PARAM" > Makefile.run truelight@3305: . Makefile.run truelight@3305: rm -f Makefile.run truelight@3198: peter1138@4094: # Makefile.config currently doesn't support custom RELEASE (revision), so, we add the line peter1138@4094: # yourself! truelight@3200: truelight@3200: if ! test -z "$RELEASE" truelight@3200: then truelight@3200: echo "RELEASE=$RELEASE" >> Makefile.config truelight@3200: fi truelight@3200: