# This file is sourced by build.sh # Include build functions used here . build/unix/config_functions . build/unix/menu_functions . build/unix/ansi uqm_requirements() { # Some requirements: have_program gcc || exit 1 COMPILE="$PROG_gcc_FILE" case "$HOST_SYSTEM" in MINGW32*) have_program windres WINDRES="$PROG_windres_FILE" ;; Darwin) have_program Rez || exit 1 REZ="$PROG_Rez_FILE" ;; esac # Define WORDS_BIGENDIAN on bigendian machines check_endianness # Libraries always used use_library SDL 1.2.8 || exit 1 use_library SDL_image || exit 1 # Add defines for HAVE_READDIR_R, HAVE_SETENV, HAVE_STRUPR # and HAVE_STRICMP define_have_symbol readdir_r define_have_symbol setenv define_have_symbol strupr define_have_symbol stricmp # Add defines for HAVE_ISWGRAPH, HAVE_WCHAR_T, and HAVE_WINT_T define_have_symbol iswgraph define_have_type wchar_t define_have_type wint_t # Add defines for HAVE_GETOPT_H and HAVE_REGEX_H define_have_header getopt.h define_have_header regex.h } uqm_prepare_config() { # Describe the menu: MENU_main_ITEMS="debug graphics sound ovcodec ioformat accel" case "$HOST_SYSTEM" in Darwin) # Installation directory not modifiable ;; MINGW32*) # No install procedure available for MinGW ;; *) MENU_main_ITEMS="$MENU_main_ITEMS install_path" ;; esac MENU_main_TITLE="Main menu" MENU_main_ITEM_debug_TYPE=CHOICE MENU_main_ITEM_graphics_TYPE=CHOICE MENU_main_ITEM_sound_TYPE=CHOICE MENU_main_ITEM_ovcodec_TYPE=CHOICE MENU_main_ITEM_ioformat_TYPE=CHOICE MENU_main_ITEM_accel_TYPE=CHOICE MENU_main_ITEM_link_TYPE=CHOICE MENU_main_ITEM_install_path_TYPE=MENU CHOICE_debug_OPTIONS="nodebug debug strictdebug" CHOICE_debug_TITLE="Type of build" CHOICE_debug_OPTION_nodebug_TITLE="Optimised release build" CHOICE_debug_OPTION_nodebug_ACTION='nodebug_action' nodebug_action() { CFLAGS="$CFLAGS -O3" DEBUG=0 } CHOICE_debug_OPTION_debug_TITLE="Debugging build" CHOICE_debug_OPTION_debug_ACTION='debug_action' debug_action() { CFLAGS="$CFLAGS -g -O0 -W -Wall -DDEBUG" LDFLAGS="$LDFLAGS -O0" DEBUG=1 } CHOICE_debug_OPTION_strictdebug_TITLE="Debug + strict compile checks" CHOICE_debug_OPTION_strictdebug_ACTION='strictdebug_action' strictdebug_action() { CFLAGS="$CFLAGS -O1" # This is needed for -Wunitialized CFLAGS="$CFLAGS -W -Wall \ -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \ -Wstrict-prototypes -Wmissing-declarations \ -Wwrite-strings -Wimplicit -Wreturn-type -Wformat \ -Wswitch -Wcomment -Wchar-subscripts \ -Wparentheses -Wcast-align \ -Winline -Wuninitialized" # CFLAGS="$CFLAGS -Waggregate-return" # It's not unreasonable to return structs at times. # CFLAGS="$CFLAGS "-Wpointer-arith" # Some standard header won't even compile with this on # CFLAGS="$CFLAGS -Wshadow" # This gives absurd conflicts with standard files, # like from 'y0 and y1' # CFLAGS="$CFLAGS -Werror" # We shouldn't do this until we actually nail them # all in the original code. Then we can enforce them # on ourselves. # CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI # CFLAGS="$CFLAGS -Wnested-externs" # We know they're in the code, and though we'd like to get # rid of them, they're not bugs. CFLAGS=`echo $CFLAGS` # Remove all the unnecessary spaces from $CFLAGS, # for more readable messages. DEBUG=1 } CHOICE_debug_DEFAULT=debug CHOICE_graphics_OPTIONS="pure opengl" CHOICE_graphics_TITLE="OpenGL graphics support" CHOICE_graphics_OPTION_pure_TITLE="Don't include OpenGL graphics support" CHOICE_graphics_OPTION_pure_ACTION='graphics_pure_action' graphics_pure_action() { CFLAGS="$CFLAGS -DGFXMODULE_SDL" HAVE_OPENGL=0 } CHOICE_graphics_OPTION_opengl_TITLE="Include OpenGL graphics support" CHOICE_graphics_OPTION_opengl_ACTION='graphics_opengl_action' CHOICE_graphics_OPTION_opengl_PRECOND="have_library opengl" graphics_opengl_action() { CFLAGS="$CFLAGS -DGFXMODULE_SDL -DHAVE_OPENGL" HAVE_OPENGL=1 use_library opengl } CHOICE_graphics_DEFAULT=opengl CHOICE_sound_OPTIONS="mixsdl openal" CHOICE_sound_TITLE="Sound backend" CHOICE_sound_OPTION_mixsdl_TITLE="Use MixSDL for sound (internal)" CHOICE_sound_OPTION_mixsdl_ACTION=sound_mixsdl_action sound_mixsdl_action() { CFLAGS="$CFLAGS -DSOUNDMODULE_SDL" SOUNDMODULE=mixsdl } CHOICE_sound_OPTION_openal_TITLE="Include OpenAL support (experimental)" CHOICE_sound_OPTION_openal_PRECOND="have_library openal" CHOICE_sound_OPTION_openal_ACTION=sound_openal_action sound_openal_action() { CFLAGS="$CFLAGS -DHAVE_OPENAL -DSOUNDMODULE_SDL" SOUNDMODULE=openal use_library openal } CHOICE_sound_DEFAULT=mixsdl CHOICE_ovcodec_OPTIONS="standard tremor" CHOICE_ovcodec_TITLE="Ogg Vorbis codec" CHOICE_ovcodec_OPTION_standard_TITLE="Xiph libogg + libvorbis" CHOICE_ovcodec_OPTION_standard_PRECOND="have_library vorbisfile" # CHOICE_ovcodec_OPTION_standard_PRECOND="have_library vorbisfile && have_library vorbis" CHOICE_ovcodec_OPTION_standard_ACTION=ovcodec_standard_action ovcodec_standard_action() { use_library vorbisfile # use_library vorbis } CHOICE_ovcodec_OPTION_tremor_TITLE="Tremor (avoids floating point math)" CHOICE_ovcodec_OPTION_tremor_PRECOND="have_library tremor" CHOICE_ovcodec_OPTION_tremor_ACTION=ovcodec_tremor_action ovcodec_tremor_action() { CFLAGS="$CFLAGS -DOVCODEC_TREMOR" use_library tremor } CHOICE_ovcodec_DEFAULT=standard CHOICE_ioformat_OPTIONS="stdio stdio_zip" CHOICE_ioformat_TITLE="Supported file i/o methods" CHOICE_ioformat_OPTION_stdio_TITLE="Only direct file i/o" CHOICE_ioformat_OPTION_stdio_zip_TITLE="Direct & .zip file i/o" CHOICE_ioformat_OPTION_stdio_zip_PRECOND="have_library zlib" CHOICE_ioformat_OPTION_stdio_zip_ACTION="ioformat_stdio_zip_action" ioformat_stdio_zip_action() { CFLAGS="$CFLAGS -DHAVE_ZIP=1" USE_ZIP_IO=1 use_library zlib } CHOICE_ioformat_DEFAULT=stdio_zip CHOICE_accel_OPTIONS="asm plainc" CHOICE_accel_TITLE="Graphics/Sound optimizations" CHOICE_accel_OPTION_asm_TITLE="Platform acceleration (asm, etc.)" CHOICE_accel_OPTION_asm_ACTION="accel_asm_action" accel_asm_action() { CFLAGS="$CFLAGS -DUSE_PLATFORM_ACCEL" USE_PLATFORM_ACCEL=1 } CHOICE_accel_OPTION_plainc_TITLE="Only plain C code" CHOICE_accel_OPTION_plainc_ACTION="accel_plainc_action" accel_plainc_action() { USE_PLATFORM_ACCEL=0 } CHOICE_accel_DEFAULT=asm # Making static binaries is more complicated than this. # For now, it will have to be done by hand. #CHOICE_link_OPTIONS="static dynamic" #CHOICE_link_TITLE="Linking" #CHOICE_link_OPTION_static_TITLE="Statically linked libraries" #CHOICE_link_OPTION_static_ACTION='eval LDFLAGS="$LDFLAGS -static"' #CHOICE_link_OPTION_dynamic_TITLE="Dynamically linked libraries" #CHOICE_link_DEFAULT=dynamic MENU_install_path_ITEMS="install_prefix install_bindir install_libdir \ install_sharedir" MENU_install_path_TITLE="Installation paths" MENU_install_path_ITEM_install_prefix_TYPE=INPUT MENU_install_path_ITEM_install_bindir_TYPE=INPUT MENU_install_path_ITEM_install_libdir_TYPE=INPUT MENU_install_path_ITEM_install_sharedir_TYPE=INPUT INPUT_install_prefix_DEFAULT="/usr/local/games" INPUT_install_prefix_TITLE="Installation prefix" INPUT_install_prefix_VALIDATOR=validate_path INPUT_install_prefix_ACTION='eval INSTALL_PREFIX=$MENU_install_prefix_VALUE' INPUT_install_bindir_DEFAULT='$prefix/bin' INPUT_install_bindir_TITLE="Location for binaries" INPUT_install_bindir_VALIDATOR=validate_path INPUT_install_libdir_DEFAULT='$prefix/lib' INPUT_install_libdir_TITLE="Location for non-sharable data" INPUT_install_libdir_VALIDATOR=validate_path INPUT_install_sharedir_DEFAULT='$prefix/share' INPUT_install_sharedir_TITLE="Location for sharable data" INPUT_install_sharedir_VALIDATOR=validate_path } uqm_do_config() { # Show the menu and let people set things do_menu MENU main "$BUILD_WORK/config.state" echo "Configuration complete." } uqm_process_config() { menu_process MENU main # Set INSTALL_LIBDIR, INSTALL_BINDIR, and INSTALL_SHAREDIR to the specified # values, replacing '$prefix' to the prefix set. local prefix prefix="$INPUT_install_prefix_VALUE" eval INSTALL_BINDIR="${INPUT_install_bindir_VALUE%/}/" eval INSTALL_LIBDIR="${INPUT_install_libdir_VALUE%/}/" eval INSTALL_SHAREDIR="${INPUT_install_sharedir_VALUE%/}/" # Set the content dir CONTENTDIR="${INSTALL_SHAREDIR}uqm/content" CFLAGS="$CFLAGS -I \"$BUILD_WORK\"" # Export the HAVE_ symbols to config_unix.h, using config_unix.h.in # as template (or config_win.h/config_win.h.in). SUBSTITUTE_VARS="$HAVE_SYMBOLS CONTENTDIR" case "$HOST_SYSTEM" in MINGW32*|CYGWIN*) SUBSTITUTE_FILES="config_win.h" ;; *) SUBSTITUTE_FILES="config_unix.h" ;; esac substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES src "$BUILD_WORK" # Make build.vars from build.vars.in, substituting variables. SUBSTITUTE_VARS="BUILD_SYSTEM HOST_SYSTEM CFLAGS LDFLAGS MAKE \ ECHON DEBUG SED SOUNDMODULE \ HAVE_OPENGL HAVE_REGEX_H_FLAG USE_ZIP_IO \ USE_PLATFORM_ACCEL \ INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR \ REZ WINDRES" SUBSTITUTE_FILES="build.vars" substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES . "$BUILD_WORK" # Make 'uqm' shell script from build.vars.in, substituting variables. SUBSTITUTE_VARS="INSTALL_LIBDIR INSTALL_BINDIR INSTALL_SHAREDIR uqm_NAME" SUBSTITUTE_FILES="uqm-wrapper" substitute_vars SUBSTITUTE_VARS SUBSTITUTE_FILES build/unix "$BUILD_WORK" } uqm_load_config() { do_menu_load MENU main "$BUILD_WORK/config.state" } uqm_save_config() { do_menu_save MENU main "$BUILD_WORK/config.state" } uqm_pre_build() { : # Nothing to do } uqm_post_build() { local TARGET_FILE local RFORK eval TARGET_FILE="\$BUILD_WORK/\${${BUILD_PROJECT}_NAME}" RFORK="src/res/darwin/${BUILD_PROJECT}.r" test -f "$TARGET_FILE" || return # If run from the command-line on OSX, the Window Manager # will refuse to recognize the window unless the program has # a resource fork; so we give it a small one here. When # run from inside an application package, this step is useless # (the cp command in the install step implicitly strips off # the resource fork, in fact) case "$HOST_SYSTEM" in Darwin) ${REZ} ${RFORK} -o ${TARGET_FILE} ;; esac } uqm_pre_install() { : # Nothing to do } uqm_install() { case "$HOST_SYSTEM" in Darwin) uqm_install_osx ;; MINGW32*) echo "No installation procedure available for MinGW." echo "Read the manual for more information." ;; *) generic_install ;; esac } uqm_post_install() { : # Nothing to do } uqm_install_osx() { local VERSION HEADERS HEADER HEADER_FILE FRAMEWORK VERSION=`head -1 content/version` INSTROOT="$BUILD_WORK/The Ur-Quan Masters.app/Contents" # Make directory structure echo "Creating directory structure..." >&2 mkdirhier "$INSTROOT/MacOS" 0755 mkdirhier "$INSTROOT/Frameworks" 0755 mkdirhier "$INSTROOT/Resources/Launcher.nib" 0755 mkdirhier "$INSTROOT/Resources/content/packages/addons" 0755 # Install misc. resources, icons, etc. echo "Installing miscellaneous resources..." >&2 $SED "s/@@VERSION@@/$VERSION/g" src/res/darwin/Info.plist > \ "$INSTROOT/Info.plist" cp src/res/darwin/PkgInfo "$INSTROOT" cp "src/res/darwin/The Ur-Quan Masters.icns" "$INSTROOT/Resources" cp src/res/darwin/Launcher.nib/objects.nib \ "$INSTROOT/Resources/Launcher.nib" # Find Frameworks and copy them into the application. echo "Copying dependancy Frameworks..." >&2 HEADERS="Ogg/Ogg.h SDL/SDL.h SDL_image/SDL_image.h Vorbis/vorbisfile.h" if [ "$uqm_SOUNDMODULE" = openal ]; then HEADERS="$HEADERS OpenAL/al.h" fi for HEADER in $HEADERS; do HEADER_FILE=`basename $HEADER` eval FRAMEWORK=`echo '' | \ $COMPILE -E -D__MACOSX__ -include $HEADER - | \ awk '(/'$HEADER_FILE'/ && $2 == 1) { print $3; exit }' | \ $SED 's/.Headers.*$/"/'` cp -r "$FRAMEWORK" "$INSTROOT/Frameworks" done # Install game content (it should probably make a zipfile) echo "Creating base content package..." >&2 cp content/version "$INSTROOT/Resources/content/" (cd content && \ find . \( -name CVS -o -name packages \) -prune -o \ \! \( -type d -o -name packages -o -name CVS -o \ -name \*.ogg \) -print | $SED 's/^..//' | \ zip -@ uqm-${VERSION}-prv-content.uqm) mv content/uqm-$VERSION-prv-content.uqm "$INSTROOT/Resources/content/packages" echo "Creating voice content package..." >&2 (cd content && \ find . -name \*\[0-9\]\[0-9\]\[0-9\].ogg -print \ | $SED 's/^..//' | zip -0 -@ uqm-${VERSION}-prv-voice.uqm) mv content/uqm-$VERSION-prv-voice.uqm "$INSTROOT/Resources/content/packages" echo "Creating 3do music content package..." >&2 (cd content && \ find . -name \*.ogg -a \! -name \*\[0-9\]\[0-9\]\[0-9\].ogg \ -print | $SED 's/^..//' | zip -0 -@ uqm-${VERSION}-prv-3domusic.uqm) mv content/uqm-$VERSION-prv-3domusic.uqm "$INSTROOT/Resources/content/packages" # Install game binary (and rename it) echo "Installing executable..." >&2 cp $uqm_NAME "$INSTROOT/MacOS/The Ur-Quan Masters" } uqm_clean() { case "$HOST_SYSTEM" in MINGW32*|CYGWIN*) rm -f "$BUILD_WORK/config_win.h" ;; *) rm -f "$BUILD_WORK/config_unix.h" ;; esac }