#!/bin/bash function program_exists() { $1 $2 1>/dev/null 2>&1 if [ $? -eq 127 ]; then return 0 fi upname=$(echo $1 | tr '[a-z]' '[A-Z]' | tr '-' '_') eval "$upname=$1" return 1 } function print_make_file_list() { FOO=GL_SRC FOOO=GL_OBJ ( grep -l "^namespace OpenGL" *.cpp ; echo "gl_frustum.cpp";echo "math/obox.cpp coldet/math3d.cpp" ) | sort | xargs echo "$FOO =" echo "$FOOO = \${$FOO:.cpp=.o}" FOO=OGTA_SRC FOOO=OGTA_OBJ ( grep -l "^namespace OpenGTA" *.cpp ; echo "slope_height_func.cpp" ) | sort | xargs echo "$FOO =" echo "$FOOO = \${$FOO:.cpp=.o}" UTIL_SRC=$(ls util/*.cpp | grep -v color.cpp | grep -v sound | xargs echo) SOUND_SRC=$(ls util/*.cpp | grep sound.* | xargs echo) LUA_SRC=$(ls lua_addon/*.cpp | xargs echo) cat < src_list.make #print_target_list >> src_list.make function pkg_config_haslib () { $PKG_CONFIG $1 1>/dev/null 2>&1 if [ $? -eq 0 ]; then return 1 fi return 0 } function check_sdl () { program_exists sdl-config if [ $? -eq 1 ]; then SDL_INC=$($SDL_CONFIG --cflags) SDL_LIB=$($SDL_CONFIG --libs) else program_exists pkg-config if [ $? -eq 1 ]; then pkg_config_try_multiple SDL SDL sdl fi fi } function pkg_config_try_multiple () { local _prefixName=$1 shift while [ $# -gt 0 ]; do pkg_config_haslib $1 if [ $? -eq 1 ]; then eval "${_prefixName}_INC=\$($PKG_CONFIG --cflags $1)" eval "${_prefixName}_LIB=\$($PKG_CONFIG --libs $1)" return fi shift done } function check_lua () { program_exists pkg-config if [ $? -eq 1 ]; then pkg_config_try_multiple LUA lua5.1 lua51 lua5 lua else program_exists lua-config if [ $? -eq 1 ]; then LUA_INC=$($LUA_CONFIG --include) LUA_LIB=$($LUA_CONFIG --libs) fi fi } function check_physfs () { program_exists pkg-config if [ $? -eq 1 ]; then pkg_config_try_multiple PHYSFS physfs fi } function check_compiler () { g++ 1>/dev/null 2>&1 if [ $? -eq 1 ]; then CXX=g++ else CXX= fi gcc 1>/dev/null 2>&1 if [ $? -eq 1 ]; then CC=gcc else CC= fi } # defaults DEBUG=-ggdb WARN=-Wall OPT=-O2 if [ "$1" == "LINUX" ]; then DEFS="-DLINUX -DDO_SCALEX" else DEFS="-DWIN32 -DDO_SCALEX" fi PHYSFS_LIB=-lphysfs SDL_LIB=-lSDL LUA_LIB=-llua51 function print_detected() { cat <= 5.1 (but not 5.0); not detected LUA_INC = $LUA_INC LUA_LIB = $LUA_LIB LINK_LAZY = -Xlinker --unresolved-symbols -Xlinker ignore-all EOF } function print_w32settings() { cat <= 5.1 (but not 5.0); not detected LUA_INC = $LUA_INC LUA_LIB = $LUA_LIB # good idea here? LINK_LAZY = -Xlinker --unresolved-symbols -Xlinker ignore-all EOF } function print_all() { check_sdl check_lua check_physfs check_compiler print_detected print_make_file_list print_target_list cat < src_list.make else echo "*** WIN32 ***" print_w32settings > src_list.make print_make_file_list >> src_list.make print_target_list >> src_list.make fi