src/configure
branchcustombridgeheads
changeset 5648 1608018c5ff2
parent 5647 cbde85c8c878
child 5649 55c8267c933f
equal deleted inserted replaced
5647:cbde85c8c878 5648:1608018c5ff2
     1 #!/bin/sh
       
     2 
       
     3 # This 'configure' script is a very easy wrapper around 'make updateconf'
       
     4 #  It allows cross-compilers to do their job much more easy.
       
     5 
       
     6 function showhelp() {
       
     7 	echo "Configure for OpenTTD"
       
     8 	echo ""
       
     9 	echo "Usage:"
       
    10 	echo " $0 --your_options"
       
    11 	echo ""
       
    12 	echo "Params:"
       
    13 	echo " --debug             Create debug-release                [no]"
       
    14 	echo " --profile           Create profile-release              [no]"
       
    15 	echo " --dedicated         Make a dedicated build              [no]"
       
    16 	echo " --revision          Set the revision of the compilation [detected]"
       
    17 	echo " --target-cc         Sets the target-compiler            [\$CC]"
       
    18 	echo " --target-cxx        Sets the C++ target-compiler        []"
       
    19 	echo " --host-cc           Sets the host-compiler              [\$CC]"
       
    20 	echo " --host-cxx          Sets the C++ host-compiler          []"
       
    21 	echo " --os                Sets the OS. Listens to:            [detected]"
       
    22 	echo "                        UNIX, OSX, FREEBSD, MORPHOS"
       
    23 	echo "                        BEOS, SUNOS, CYGWIN, MINGW, OS2"
       
    24 	echo " --windres           Sets the windres (Windows)          [windres]"
       
    25 	echo " --force-le          Force LE platform                   [no]"
       
    26 	echo " --force-be          Force BE platform                   [no]"
       
    27 	echo ""
       
    28 	echo "Params that can be used with --with or --without"
       
    29 	echo "   (e.g.: --without-static disables static (default))"
       
    30 	echo " static              Do you want a static build?         [no]"
       
    31 	echo " directmusic         Do you want direct-music?           [no]"
       
    32 	echo " zlib                Do you want zlib-support?           [yes]"
       
    33 	echo " sdl                 Do you want SDL-support?            [yes]"
       
    34 	echo " png                 Do you want PNG-support?            [yes]"
       
    35 	echo " iconv               Do you want iconv-support?          [no]"
       
    36 	echo " network             Do you want network-support?        [yes]"
       
    37 	echo " cocoa               Do you want cocoa-support? (MacOSX) [no]"
       
    38 	echo " freetype            Do you want freetype-support?       [yes]"
       
    39 	echo " fontconfig          Do you want fontconfig-support?     [yes]"
       
    40 	echo ""
       
    41 	echo "Params used to configure external libs:"
       
    42 	echo " --static-zlib-path  Set the path to your static zlib    []"
       
    43 	echo " --sdl-config        Where is your sdl-config            [sdl-config]"
       
    44 	echo " --libpng-config     Where is your libpng-config         [libpng-config]"
       
    45 	echo " --freetype-config   Where is your freetype-config       [freetype-config]"
       
    46 	echo " --fontconfig-config Where is your fontconfig-config     [pkg-config fontconfig]"
       
    47 	echo " --with-iconv        Set the path to your iconv headers  []"
       
    48 	echo " "
       
    49 }
       
    50 
       
    51 function handle() {
       
    52 	PARAM="$PARAM \"$1=`awk 'BEGIN { FS="="; $0="'"$2"'"; print $2;}'`\""
       
    53 }
       
    54 
       
    55 # The things you can use inside this case:
       
    56 #  handle NAME VALUE - Sets the value to give the 'make upgradeconf'
       
    57 #                         Value is in form: tag=REAL_VALUE
       
    58 #  ITEM="NAME"       - Will set the value as above, only with the next param
       
    59 #  SITEM="NAME"      - Will set the var $NAME to the next param
       
    60 for n in "$@"
       
    61 do
       
    62 	case "$n" in
       
    63 		--help | -h)
       
    64 			showhelp
       
    65 			exit 0
       
    66 			;;
       
    67 
       
    68 		--debug)
       
    69 			DEBUG_SET=1
       
    70 			ITEM="DEBUG"
       
    71 			;;
       
    72 		--debug=*)
       
    73 			handle "DEBUG" "$n"
       
    74 			;;
       
    75 		--profile)
       
    76 			PARAM="$PARAM PROFILE=1"
       
    77 			;;
       
    78 		--dedicated)
       
    79 			PARAM="$PARAM DEDICATED=1"
       
    80 			;;
       
    81 		--revision=*)
       
    82 			RELEASE=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
       
    83 			;;
       
    84 		--revision)
       
    85 			SITEM="RELEASE"
       
    86 			;;
       
    87 		--target-cc=*)
       
    88 			handle "CC_TARGET" "$n"
       
    89 			;;
       
    90 		--target-cc)
       
    91 			ITEM="CC_TARGET"
       
    92 			;;
       
    93 		--target-cxx=*)
       
    94 			handle "CXX_TARGET" "$n"
       
    95 			;;
       
    96 		--target-cxx)
       
    97 			SITEM="CXX_TARGET"
       
    98 			;;
       
    99 		--host-cc=*)
       
   100 			handle "CC_HOST" "$n"
       
   101 			;;
       
   102 		--host-cc)
       
   103 			ITEM="CC_HOST"
       
   104 			;;
       
   105 		--host-cxx=*)
       
   106 			handle "CXX_HOST" "$n"
       
   107 			;;
       
   108 		--host-cxx)
       
   109 			ITEM="CXX_HOST"
       
   110 			;;
       
   111 		--host-cflags=*)
       
   112 			handle CFLAGS_HOST "$n"
       
   113 			;;
       
   114 		--host-cflags)
       
   115 			ITEM="CFLAGS_HOST"
       
   116 			;;
       
   117 		--os=*)
       
   118 			TARGET_OS=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
       
   119 			;;
       
   120 		--os)
       
   121 			SITEM="TARGET_OS"
       
   122 			;;
       
   123 		--windres=*)
       
   124 			handle WINDRES "$n"
       
   125 			;;
       
   126 		--windres)
       
   127 			ITEM="WINDRES"
       
   128 			;;
       
   129 		--force-le)
       
   130 			PARAM="$PARAM ENDIAN_FORCE=LE"
       
   131 			;;
       
   132 		--force-be)
       
   133 			PARAM="$PARAM ENDIAN_FORCE=BE"
       
   134 			;;
       
   135 
       
   136 		--with-static)
       
   137 			PARAM="$PARAM STATIC=1"
       
   138 			;;
       
   139 		--without-static)
       
   140 			PARAM="$PARAM STATIC="
       
   141 			;;
       
   142 		--with-directmusic)
       
   143 			PARAM="$PARAM WITH_DIRECTMUSIC=1"
       
   144 			;;
       
   145 		--without-directmusic)
       
   146 			PARAM="$PARAM WITH_DIRECTMUSIC="
       
   147 			;;
       
   148 		--with-zlib)
       
   149 			PARAM="$PARAM WITH_ZLIB=1"
       
   150 			;;
       
   151 		--without-zlib)
       
   152 			PARAM="$PARAM WITH_ZLIB="
       
   153 			;;
       
   154 		--with-sdl)
       
   155 			PARAM="$PARAM WITH_SDL=1"
       
   156 			;;
       
   157 		--without-sdl)
       
   158 			PARAM="$PARAM WITH_SDL="
       
   159 			;;
       
   160 		--with-png)
       
   161 			PARAM="$PARAM WITH_PNG=1"
       
   162 			;;
       
   163 		--without-png)
       
   164 			PARAM="$PARAM WITH_PNG="
       
   165 			;;
       
   166 		--with-iconv)
       
   167 			PARAM="$PARAM WITH_ICONV=1"
       
   168 			;;
       
   169 		--with-iconv=*)
       
   170 			PARAM="$PARAM WITH_ICONV=1"
       
   171 			handle WITH_ICONV_PATH "$n"
       
   172 			;;
       
   173 		--without-iconv)
       
   174 			PARAM="$PARAM WITH_ICONV="
       
   175 			;;
       
   176 		--with-cocoa)
       
   177 			PARAM="$PARAM WITH_COCOA=1"
       
   178 			;;
       
   179 		--with-network)
       
   180 			PARAM="$PARAM WITH_NETWORK=1"
       
   181 			;;
       
   182 		--without-network)
       
   183 			PARAM="$PARAM WITH_NETWORK="
       
   184 			;;
       
   185 		--without-cocoa)
       
   186 			PARAM="$PARAM WITH_COCOA="
       
   187 			;;
       
   188 		--with-freetype)
       
   189 			PARAM="$PARAM WITH_FREETYPE=1"
       
   190 			;;
       
   191 		--without-freetype)
       
   192 			PARAM="$PARAM WITH_FREETYPE="
       
   193 			;;
       
   194 		--with-fontconfig)
       
   195 			PARAM="$PARAM WITH_FONTCONFIG=1"
       
   196 			;;
       
   197 		--without-fontconfig)
       
   198 			PARAM="$PARAM WITH_FONTCONFIG="
       
   199 			;;
       
   200 		--static-zlib-path=*)
       
   201 			handle STATIC_ZLIB_PATH "$n"
       
   202 			;;
       
   203 		--static-zlib-path)
       
   204 			ITEM="STATIC_ZLIB_PATH"
       
   205 			;;
       
   206 		--sdl-config=*)
       
   207 			handle SDL_CONFIG "$n"
       
   208 			;;
       
   209 		--sdl-config)
       
   210 			ITEM="SDL_CONFIG"
       
   211 			;;
       
   212 		--libpng-config=*)
       
   213 			handle LIBPNG_CONFIG "$n"
       
   214 			;;
       
   215 		--libpng-config)
       
   216 			ITEM="LIBPNG_CONFIG"
       
   217 			;;
       
   218 		--freetype-config=*)
       
   219 			handle FREETYPE_CONFIG "$n"
       
   220 			;;
       
   221 		--freetype-config)
       
   222 			ITEM="FREETYPE_CONFIG"
       
   223 			;;
       
   224 		--fontconfig-config=*)
       
   225 			handle FONTCONFIG_CONFIG "$n"
       
   226 			;;
       
   227 		--fontconfig-config)
       
   228 			ITEM="FONTCONFIG_CONFIG"
       
   229 			;;
       
   230 
       
   231 		--*=*)
       
   232 			echo -n "Unknown switch "
       
   233 			echo `awk 'BEGIN { FS="="; $0="'"$n"'"; print $1;}'`
       
   234 			exit 1
       
   235 			;;
       
   236 		-*)
       
   237 			echo "Unknown switch $n"
       
   238 			exit 1
       
   239 			;;
       
   240 
       
   241 		*)
       
   242 			if ! test -z "$ITEM"
       
   243 			then
       
   244 				PARAM="$PARAM $ITEM=\"$n\""
       
   245 				ITEM="";
       
   246 			elif ! test -z "$SITEM"
       
   247 			then
       
   248 				export $SITEM="$n"
       
   249 				SITEM=""
       
   250 			else
       
   251 				echo "Unknown switch $n"
       
   252 				exit 1
       
   253 			fi
       
   254 			;;
       
   255 	esac
       
   256 done
       
   257 
       
   258 if ! test -z "$TARGET_OS"
       
   259 then
       
   260 	TARGET_OS=`echo $TARGET_OS | tr '[:lower:]' '[:upper:]'`
       
   261 	case "$TARGET_OS" in
       
   262 		WIN32)
       
   263 			PARAM="$PARAM WIN32=1"
       
   264 			;;
       
   265 		UNIX)
       
   266 			PARAM="$PARAM UNIX=1"
       
   267 			;;
       
   268 		OSX)
       
   269 			PARAM="$PARAM OSX=1 UNIX=1"
       
   270 			;;
       
   271 		FREEBSD)
       
   272 			PARAM="$PARAM FREEBSD=1"
       
   273 			;;
       
   274 		MORPHOS)
       
   275 			PARAM="$PARAM MORPHOS=1 UNIX=1"
       
   276 			;;
       
   277 		BEOS)
       
   278 			PARAM="$PARAM BEOS=1 UNIX=1"
       
   279 			;;
       
   280 		OS2)
       
   281 			PARAM="$PARAM OS2=1 UNIX=1"
       
   282 			;;
       
   283 		SUNOS)
       
   284 			PARAM="$PARAM SUNOS=1 UNIX=1"
       
   285 			;;
       
   286 		CYGWIN)
       
   287 			PARAM="$PARAM CYGWIN=1 WIN32=1"
       
   288 			;;
       
   289 		MINGW)
       
   290 			PARAM="$PARAM MINGW=1 WIN32=1"
       
   291 			;;
       
   292 		*)
       
   293 			echo "Unknown OS: $TARGET_OS"
       
   294 			exit 1
       
   295 			;;
       
   296 	esac
       
   297 	PARAM="$PARAM BYPASS_OS_DETECT=1"
       
   298 fi
       
   299 
       
   300 if ! test -z "$DEBUG_SET"
       
   301 then
       
   302 	if test -z "`echo $PARAM | grep "DEBUG="`"
       
   303 	then
       
   304 		# Someone did --debug, without assigning a value, assume 1
       
   305 		PARAM="$PARAM DEBUG=1"
       
   306 	fi
       
   307 fi
       
   308 
       
   309 # First remove the Makefile.config, else you can have double entries
       
   310 rm -f Makefile.config
       
   311 
       
   312 echo "make upgradeconf $PARAM" > Makefile.run
       
   313 . Makefile.run
       
   314 rm -f Makefile.run
       
   315 
       
   316 # Makefile.config currently doesn't support custom RELEASE (revision), so, we add the line
       
   317 # yourself!
       
   318 
       
   319 if ! test -z "$RELEASE"
       
   320 then
       
   321 	echo "RELEASE=$RELEASE" >> Makefile.config
       
   322 fi
       
   323