#!/bin/sh # ----------------------------- # q2pro configuration script by [SkulleR] # ----------------------------- # defaults sources=$(dirname $0) if [ "$sources" = "." ]; then sources=`pwd` fi outdir=`pwd` prefix="/usr/local" cross_prefix="" cc="gcc" make="make" windres="windres" strip="strip" mingw="no" pngconfig="libpng-config" exesuffix="" libsuffix=".so" dsound="no" wave="???" dinput="no" oss="no" evdev="no" zlib="yes" png="no" jpeg="no" sdl="yes" client="yes" ref_soft="yes" ref_gl="yes" mod_ui="yes" server="no" openffa="no" help="no" targets="" executables="" libraries="" hardlink="no" asm="no" gldriver="libGL.so" indriver="" homedir=".q2pro" defcfg="/etc/default/q2pro" asmflags="" logfile="console.log" cfgfile="config.cfg" defcfg="default.cfg" autocfg="autoexec.cfg" histfile="history.txt" revision="165" tmpc="/tmp/q2pro-${RANDOM}.c" tmpo="/tmp/q2pro-${RANDOM}.o" if [ -z "$CFLAGS" ]; then CFLAGS="-ffast-math -O2" fi # detect host CPU cpu=`uname -m` case $cpu in i386|i486|i586|i686) cpu="i386" asm="yes" ;; ia64) cpu="ia64" ;; x86_64|amd64) cpu="x86_64" ;; *) cpu="unknown" ;; esac # detect host OS targetos=`uname -s` case $targetos in CYGWIN*) targetos="Windows" mingw="yes" sdl="no" wave="yes" CFLAGS="-mno-cygwin $CFLAGS" ;; MINGW*) targetos="Windows" mingw="yes" sdl="no" wave="yes" ;; *BSD) make="gmake" oss="yes" ;; Linux) oss="yes" evdev="yes" ;; esac #parse options for opt do case $opt in --help|-h) help="yes" ;; --sources=*) sources=`echo $opt | cut -d '=' -f 2` ;; --prefix=*) prefix=`echo $opt | cut -d '=' -f 2` ;; --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` ;; --enable-mingw) mingw="yes" ; sdl="no" ;; --cc=*) cc=`echo $opt | cut -d '=' -f 2` ;; --make=*) make=`echo $opt | cut -d '=' -f 2` ;; --windres=*) windres=`echo $opt | cut -d '=' -f 2` ;; --strip=*) strip=`echo $opt | cut -d '=' -f 2` ;; --hardlink) hardlink="yes" ;; --disable-client) client="no" ;; --enable-server) server="yes" ;; --enable-openffa) openffa="yes" ;; --enable-dsound) dsound="yes" ;; --enable-dinput) dinput="yes" ;; --disable-wave) wave="no" ;; --disable-oss) oss="no" ;; --disable-zlib) zlib="no" ;; --enable-png) png="yes" ;; --enable-jpeg) jpeg="yes" ;; --disable-asm) asm="no" ;; *) echo "Unknown option: $opt (try --help)" && exit 1 ;; esac done if [ "$help" = "yes" ]; then echo "Usage: $0 [options]" echo "" echo "Options:" echo " --help print this message" echo " --prefix=PREFIX install in PREFIX [$prefix]" echo " --cross-prefix=PREFIX add PREFIX to compile tools [$cross_prefix]" echo " --cc=CC use C compiler [$cc]" echo " --make=MAKE use MAKE processor [$make]" echo " --windres=WINDRES use RC compiler [$windres]" echo " --hardlink build hard linked client" echo " --disable-client do not build client" echo " --enable-server build dedicated server" echo " --enable-openffa build OpenFFA deathmatch mod" echo " --enable-mingw enable Windows build" echo " --enable-dsound enable DirectSound driver" echo " --enable-dinput enable DirectInput driver" echo " --disable-wave disable WAVE sound driver" echo " --disable-oss disable OSS driver" echo " --disable-evdev disable Evdev driver" echo " --disable-zlib disable linking with zlib" echo " --enable-png enable linking with PNG library" echo " --enable-jpeg enable linking with JPEG library" echo " --disable-asm disable i386 assembly optimizations" echo "" echo "Object files are built in the directory from which configure is run." exit 1 fi if [ "$mingw" = "yes" ]; then targetos="Windows" pathsep='\\' exesuffix=".exe" libsuffix=".dll" oss="no" evdev="no" gldriver="opengl32" gamelib="gamex86.dll" exported="__attribute__((dllexport))" homedir="" asmflags="-DUNDERSCORES" cfgfile="q2config.cfg" if [ "$wave" = "???" ]; then wave="yes" fi else pathsep="/" gamelib="game$cpu.so" exported="__attribute__((visibility(\"default\")))" datadir="$prefix/share/games/quake2" libdir="$prefix/lib/games/quake2" refdir="$prefix/lib/games/q2pro" bindir="$prefix/games" mandir="$prefix/share/man/man6" # check if -fvisibility is supported echo "int main(){return 0;}" > $tmpc if $cc -o $tmpo -fvisibility\=hidden $tmpc 2>/dev/null ; then CFLAGS="-fvisibility=hidden $CFLAGS" fi rm -f $tmpc $tmpo LDFLAGS="-Wl,--no-undefined $LDFLAGS" fi if [ ! -z "$cross_prefix" ]; then cc="$cross_prefix-$cc" windres="$cross_prefix-$windres" strip="$cross_prefix-$strip" pngconfig="$cross_prefix-$pngconfig" fi echo "Build client $client" if [ "$client" = "yes" ]; then if [ "$hardlink" = "yes" ]; then echo "Hard linked $hardlink" else echo "Software refresh $ref_soft" echo "OpenGL refresh $ref_gl" echo "Build UI module $mod_ui" fi fi echo "Build server $server" echo "Build OpenFFA $openffa" if [ "$mingw" = "no" ]; then echo "Install prefix $prefix" echo "Data directory $datadir" echo "Game libraries $libdir" if [ "$client" = "yes" ]; then echo "Refresh libraries $refdir" fi echo "Binaries $bindir" echo "Man pages $mandir" fi echo "zlib support $zlib" if [ "$client" = "yes" ]; then echo "PNG support $png" echo "JPEG support $jpeg" if [ "$mingw" = "yes" ]; then echo "DInput support $dinput" echo "DSound support $dsound" echo "WAVE sound support $wave" else echo "OSS support $oss" echo "Evdev support $evdev" fi fi test "$cpu" = "i386" && echo "i386 assembly $asm" CFLAGS="-I\$(OUTDIR) -MF \$*.d -MMD -Wall -Wno-missing-braces -Wstrict-prototypes -pipe -ffloat-store -fno-strict-aliasing $CFLAGS" #LDFLAGS="$LDFLAGS" config_mk="config.mk" config_h="config.h" echo "# Generated by configure - do not modify" > $config_mk echo "// Generated by configure - do not modify" > $config_h test "$mingw" = "yes" && echo "MINGW=$mingw" >> $config_mk echo "CC=$cc" >> $config_mk echo "WINDRES=$windres" >> $config_mk echo "STRIP=$strip" >> $config_mk echo "MAKE=$make" >> $config_mk echo "SRCDIR=$sources" >> $config_mk echo "OUTDIR=$outdir" >> $config_mk echo "EXESUFFIX=$exesuffix" >> $config_mk echo "LIBSUFFIX=$libsuffix" >> $config_mk echo "#define LIBSUFFIX \"$libsuffix\"" >> $config_h echo "VPATH=\$(SRCDIR)/source \$(SRCDIR)/asm" >> $config_mk echo "CFLAGS=$CFLAGS" >> $config_mk echo "LDFLAGS=$LDFLAGS" >> $config_mk test "$mingw" = "yes" && echo "RESFLAGS=-I\$(OUTDIR) -I\$(SRCDIR)/source" >> $config_mk test "$asm" = "yes" && echo "ASMFLAGS=$asmflags" >> $config_mk if [ "$client" = "yes" ]; then targets="$targets q2pro" executables="$executables q2pro$exesuffix" if [ "$hardlink" = "no" ]; then if [ "$ref_soft" = "yes" ]; then targets="$targets ref_soft" libraries="$libraries ref_soft$libsuffix" fi if [ "$ref_gl" = "yes" ]; then targets="$targets ref_gl" libraries="$libraries ref_gl$libsuffix" fi if [ "$mod_ui" = "yes" ]; then targets="$targets mod_ui" libraries="$libraries mod_ui$libsuffix" fi fi else sdl="no" fi if [ "$server" = "yes" ]; then targets="$targets q2proded" executables="$executables q2proded$exesuffix" fi if [ "$openffa" = "yes" ]; then targets="$targets openffa" libraries="$libraries $gamelib" fi echo "TARGETS=$targets" >> $config_mk echo "BINARIES=$executables $libraries" >> $config_mk echo "EXECUTABLES=$executables" >> $config_mk echo "LIBRARIES=$libraries" >> $config_mk echo "REVISION=$revision" >> $config_mk echo "#define REVISION $revision" >> $config_h echo "#define VERSION \"r$revision\"" >> $config_h if [ "$mingw" = "no" ]; then echo "DATADIR=$datadir" >> $config_mk echo "#define DATADIR \"$datadir\"" >> $config_h echo "LIBDIR=$libdir" >> $config_mk echo "#define LIBDIR \"$libdir\"" >> $config_h echo "REFDIR=$refdir" >> $config_mk echo "#define REFDIR \"$refdir\"" >> $config_h echo "BINDIR=$bindir" >> $config_mk echo "#define BINDIR \"$bindir\"" >> $config_h echo "MANDIR=$mandir" >> $config_mk echo "#define HOMEDIR \"$homedir\"" >> $config_h fi echo "#define EXPORTED $exported" >> $config_h echo "#define QDECL" >> $config_h echo "GAMELIB=$gamelib" >> $config_mk echo "#define GAMELIB \"$gamelib\"" >> $config_h echo "#define COM_LOGFILE_NAME \"$logfile\"" >> $config_h echo "#define COM_CONFIG_NAME \"$cfgfile\"" >> $config_h echo "#define COM_DEFAULTCFG_NAME \"$defcfg\"" >> $config_h echo "#define COM_AUTOEXECCFG_NAME \"$autocfg\"" >> $config_h echo "#define COM_HISTORYFILE_NAME \"$histfile\"" >> $config_h test "$mingw" = "no" && echo "#define DEFCFG \"$defcfg\"" >> $config_h echo "#define CPUSTRING \"$cpu\"" >> $config_h echo "#define BUILDSTRING \"$targetos\"" >> $config_h echo "#define PATH_SEP_CHAR '$pathsep'" >> $config_h echo "#define PATH_SEP_STRING \"$pathsep\"" >> $config_h echo "#define DEFAULT_OPENGL_DRIVER \"$gldriver\"" >> $config_h echo "#define DEFAULT_INPUT_DRIVER \"$indriver\"" >> $config_h if [ "$zlib" = "yes" ]; then echo "USE_ZLIB=yes" >> $config_mk echo "ZLIB_LDFLAGS=-lz" >> $config_mk echo "ZLIB_CFLAGS=" >> $config_mk echo "#define USE_ZLIB 1" >> $config_h fi if [ "$png" = "yes" ]; then echo "USE_PNG=yes" >> $config_mk echo "PNG_LDFLAGS=$($pngconfig --libs)" >> $config_mk echo "PNG_CFLAGS=$($pngconfig --cflags)" >> $config_mk echo "#define USE_PNG 1" >> $config_h fi if [ "$jpeg" = "yes" ]; then echo "USE_JPEG=yes" >> $config_mk echo "JPEG_LDFLAGS=-ljpeg" >> $config_mk echo "JPEG_CFLAGS=" >> $config_mk echo "#define USE_JPEG 1" >> $config_h fi if [ "$sdl" = "yes" ]; then echo "USE_SDL=yes" >> $config_mk echo "SDL_LDFLAGS=`sdl-config --libs`" >> $config_mk echo "SDL_CFLAGS=`sdl-config --cflags`" >> $config_mk echo "#define USE_SDL 1" >> $config_h fi if [ "$oss" = "yes" ]; then echo "USE_OSS=yes" >> $config_mk echo "#define USE_OSS 1" >> $config_h fi if [ "$evdev" = "yes" ]; then echo "USE_EVDEV=yes" >> $config_mk echo "#define USE_EVDEV 1" >> $config_h fi if [ "$wave" = "yes" ]; then echo "USE_WAVE=yes" >> $config_mk echo "#define USE_WAVE 1" >> $config_h fi if [ "$dsound" = "yes" ]; then echo "USE_DSOUND=yes" >> $config_mk echo "#define USE_DSOUND 1" >> $config_h fi if [ "$dinput" = "yes" ]; then echo "USE_DINPUT=yes" >> $config_mk echo "#define USE_DINPUT 1" >> $config_h fi if [ "$asm" = "yes" ]; then echo "USE_ASM=yes" >> $config_mk echo "#define USE_ASM 1" >> $config_h fi echo "#define USE_MAPCHECKSUM 1" >> $config_h echo "#define USE_AUTOREPLY 1" >> $config_h if [ "$hardlink" = "yes" ]; then echo "REF_HARD_LINKED=yes" >> $config_mk echo "#define REF_HARD_LINKED 1" >> $config_h echo "UI_HARD_LINKED=yes" >> $config_mk echo "#define UI_HARD_LINKED 1" >> $config_h echo "#define OPENGL_RENDERER 1" >> $config_h echo "#define TRUECOLOR_RENDERER 1" >> $config_h echo "#define DEFAULT_REFRESH_DRIVER \"gl\"" >> $config_h else echo "#define DEFAULT_REFRESH_DRIVER \"soft\"" >> $config_h fi for t in $targets ; do mkdir -p .$t ; done