summaryrefslogtreecommitdiff
path: root/configure
blob: 6fb1b662cffcafbd5b26e0adb892e43160f32be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
#!/bin/sh

# Copyright (C) 2008 Andrey Nazarov
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
#
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# -----------------------------
# Q2PRO configuration script
# -----------------------------

die() {
    echo "ERROR: $1"
    exit 1
}

# build directories
sources=`dirname $0`
[ "$sources" != "." ] || sources=`pwd`
[ -f $sources/src/common.c ] || die "this does not look like Q2PRO source tree"
if [ -f $sources/VERSION ] ; then
    version=`cat $sources/VERSION`
    revision=`tr -d -c [:digit:] < $sources/VERSION`
else
    [ -x `which git` ] || die "VERSION is missing and git suite is not installed"
    [ -d "$sources/.git" ] || die "VERSION is missing and this is not a git working tree"
    version=`git --git-dir "$sources/.git" describe --match "r[0-9]*" --abbrev=4 HEAD`
    revision=`git --git-dir "$sources/.git" describe --match "r[0-9]*" --abbrev=0 HEAD | tr -d -c [:digit:]`
fi
echo "$revision" | grep -q -E "^[[:digit:]]+$" || die "invalid revision"
outdir=`pwd`
config_mk="config.mk"
config_h="config.h"

# defaults
help="no"
exesuffix=""
libsuffix=".so"
targets=""
cpu=""
singleuser="no"
asmflags=""
mingw="no"
wince="no"
[ ! -z "$CFLAGS" ] || CFLAGS="-O2 -g -Wall -Wstrict-prototypes"
have_endian_h="no"
curl_cflags=""

# build tools
cross_prefix=""
cc="gcc"
make="make"
windres="windres"
strip="strip"
pngconfig="libpng-config"
sdlconfig="sdl-config"

# install paths
prefix="/usr/local"
datadir="share/games/q2pro"
libdir="lib/games/q2pro"
bindir="games"
mandir="share/man/man6"
appdir="share/applications"
pixdir="share/pixmaps"
homedir="~/.q2pro"
sitecfg="/etc/default/q2pro"

# use flags
use_snddma="yes"
use_openal="no"
use_dsound="no"
use_dinput="no"
use_udev="no"
use_lirc="no"
use_zlib="yes"
use_curl="no"
use_tga="yes"
use_png="no"
use_jpg="no"
use_md3="yes"
use_sdl="yes"
use_dl="no"
use_x11="yes"
use_client="yes"
use_ref="gl"
use_ui="yes"
use_server="no"
use_anticheat="no"
use_mvd_server="yes"
use_mvd_client="yes"
use_asm="???"
use_baseq2="no"
use_syscon="yes"
use_winsvc="no"
use_dbghelp="no"
use_icmp="???"
use_fps="no"

# constants
basegame="baseq2"
defgame=""
cfgfile="config.cfg"
defcfg="default.cfg"
autocfg="autoexec.cfg"
histfile=".conhistory"
democache=".democache"
screenshots="screenshots"
scoreshots="scoreshots"
gldriver="libGL.so.1"
aldriver="libopenal.so.1"
indriver=""
vid_modelist="640x480 800x600 1024x768"
vid_geometry="640x480"

#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"
    ;;
    --enable-wince) wince="yes"
    ;;
    --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
    ;;
    --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`
    ;;
    --disable-client) use_client="no"
    ;;
    --enable-server) use_server="yes"
    ;;
    --enable-baseq2) use_baseq2="yes"
    ;;
    --enable-dbghelp) use_dbghelp="yes"
    ;;
    --disable-snddma) use_snddma="no"
    ;;
    --enable-openal) use_openal="yes"
    ;;
    --enable-dsound) use_dsound="yes"
    ;;
    --enable-dinput) use_dinput="yes"
    ;;
    --enable-lirc) use_lirc="yes"
    ;;
    --disable-zlib) use_zlib="no"
    ;;
    --enable-curl) use_curl="yes"
    ;;
    --disable-tga) use_tga="no"
    ;;
    --enable-png) use_png="yes"
    ;;
    --enable-jpg) use_jpg="yes"
    ;;
    --disable-md3) use_md3="no"
    ;;
    --disable-ui) use_ui="no"
    ;;
    --use-ref=*) use_ref=`echo $opt | cut -d '=' -f 2`
    ;;
    --disable-asm) use_asm="no"
    ;;
    --enable-anticheat) use_anticheat="yes"
    ;;
    --disable-mvd-server) use_mvd_server="no"
    ;;
    --disable-mvd-client) use_mvd_client="no"
    ;;
    --disable-icmp) use_icmp="no"
    ;;
    --enable-fps) use_fps="yes"
    ;;
    --single-user) singleuser="yes"
    ;;
    --datadir=*) datadir=`echo $opt | cut -d '=' -f 2`
    ;;
    --libdir=*) libdir=`echo $opt | cut -d '=' -f 2`
    ;;
    --bindir=*) bindir=`echo $opt | cut -d '=' -f 2`
    ;;
    --mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
    ;;
    --appdir=*) appdir=`echo $opt | cut -d '=' -f 2`
    ;;
    --pixdir=*) pixdir=`echo $opt | cut -d '=' -f 2`
    ;;
    --homedir=*) homedir=`echo $opt | cut -d '=' -f 2`
    ;;
    *) die "Unknown option: $opt (try --help)"
    ;;
    esac
done

if [ "$help" = "yes" ]; then
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo "  --help                 print this message"
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 "  --disable-client       do not build graphical client"
echo "  --enable-server        build dedicated server"
echo "  --enable-baseq2        build baseq2 game module"
echo "  --enable-mingw         enable Windows build"
echo "  --enable-dbghelp       enable Windows crash dumps"
echo "  --disable-snddma       disable DMA sound engine"
echo "  --enable-openal        enable OpenAL sound engine"
echo "  --enable-dsound        enable direct sound driver"
echo "  --enable-dinput        enable direct input driver"
echo "  --enable-lirc          enable LIRC input interface"
echo "  --disable-zlib         disable linking with zlib"
echo "  --enable-curl          enable linking with libcurl"
echo "  --disable-tga          disable TGA images support"
echo "  --enable-png           enable PNG images support"
echo "  --enable-jpg           enable JPG images support"
echo "  --disable-md3          disable MD3 models support"
echo "  --disable-ui           disable menu user interface"
echo "  --disable-asm          disable i386 assembly optimizations"
echo "  --enable-anticheat     enable r1ch.net anticheat server interface"
echo "  --disable-mvd-server   disable MVD/GTV server"
echo "  --disable-mvd-client   disable MVD/GTV client"
echo "  --disable-icmp         disable ICMP error handling"
echo "  --enable-fps           enable variable server FPS support"
echo "  --single-user          assume to be installed in home dir"
echo "  --prefix=PREFIX        install in PREFIX [$prefix]"
echo "  --datadir=DIR          path to game data tree [$datadir]"
echo "  --libdir=DIR           path to game libs tree [$libdir]"
echo "  --bindir=DIR           executables directory [$bindir]"
echo "  --mandir=DIR           manpages directory [$mandir]"
echo "  --appdir=DIR           directory for .desktop files [$appdir]"
echo "  --pixdir=DIR           directory for pixmaps [$pixdir]"
echo "  --homedir=DIR          home directory [$homedir]"
echo ""
echo "Object files are built in the directory from which configure is run."
exit 1
fi

# detect host CPU
[ ! -z "$cpu" ] || cpu=`uname -m`
case $cpu in
i?86)
cpu="i386"
[ "$use_asm" = "no" ] || use_asm="yes"
;;
amd64)
cpu="x86_64"
;;
arm*)
cpu="arm"
;;
ppc*)
cpu="powerpc"
;;
mips*)
cpu="mips"
;;
esac

# detect host OS
targetos=`uname -s`
case $targetos in
CYGWIN*)
mingw="yes"
CFLAGS="-mno-cygwin $CFLAGS"
;;
MINGW*)
mingw="yes"
;;
*BSD)
make="gmake"
;;
Linux)
use_dl="yes"
have_endian_h="yes"
[ "$use_icmp" = "no" ] || use_icmp="yes"
[ "$use_dinput" = "yes" ] && use_udev="yes"
;;
esac

if [ "$mingw" = "yes" ]; then
    if [ "$cpu" = "i386" ]; then
        cpu="x86"
        targetos="Win32"
    else
        targetos="Win64"
    fi
    pathsep='\\'
    exesuffix=".exe"
    libsuffix=".dll"
    use_sdl="no"
    gldriver="opengl32"
    aldriver="openal32"
    exported="__attribute__((dllexport))"
    homedir=""
    asmflags="-DUNDERSCORES"
    cfgfile="q2config.cfg"
    [ ! -z "$LDFLAGS" ] || LDFLAGS="-static"
    curl_cflags="-DCURL_STATICLIB"

    if [ "$wince" = "yes" ]; then
        vid_modelist="240x320"
        vid_geometry="240x320"
        targetos="WinCE"
        use_syscon="no"
        use_winsvc="no"
        use_dbghelp="no"
    else
        use_winsvc="yes"
        [ "$use_icmp" = "no" ] || use_icmp="yes"
    fi
    have_endian_h="no"
else
    pathsep="/"
    exported="__attribute__((visibility(\"default\")))"

    if [ "$singleuser" = "yes" ]; then
        prefix=""
        datadir="."
        libdir="."
        bindir=""
        mandir=""
        appdir=""
        pixdir=""
        homedir=""
    elif [ ! -z "$prefix" ]; then
        datadir="$prefix/$datadir"
        libdir="$prefix/$libdir"
        bindir="$prefix/$bindir"
        mandir="$prefix/$mandir"
        appdir="$prefix/$appdir"
        pixdir="$prefix/$pixdir"
    fi

# check if -fvisibility is supported
    tmpc=`mktemp /tmp/q2pro-XXXXXXXXXX`
    tmpo=`mktemp /tmp/q2pro-XXXXXXXXXX`
    echo "$tmpc" | grep -q "^/tmp/q2pro-" || die "mktemp failed"
    echo "$tmpo" | grep -q "^/tmp/q2pro-" || die "mktemp failed"
    echo "int main(){return 0;}" > $tmpc
    $cc -o $tmpo -x c -fvisibility\=hidden $tmpc 2>/dev/null && \
        CFLAGS="-fvisibility=hidden $CFLAGS"
    rm -f $tmpc $tmpo

    LDFLAGS="-Wl,--no-undefined $LDFLAGS"
fi

if [ "$use_ref" = "soft" ]; then
    use_tga="no"
    use_png="no"
    use_jpg="no"
    use_md3="no"
fi

if [ "$use_snddma" = "no" ]; then
    use_dsound="no"
    use_openal="yes" # FIXME
fi

gamelib="game$cpu$libsuffix"

vpath="\$(SRCDIR)/src"
[ "$use_asm" = "yes" ] && vpath="$vpath \$(SRCDIR)/src/i386"

if [ ! -z "$cross_prefix" ]; then
    cc="$cross_prefix-$cc"
    windres="$cross_prefix-$windres"
    strip="$cross_prefix-$strip"
    pngconfig="$cross_prefix-$pngconfig"
fi

# echo configuration info
echo "Build client       $use_client"
echo "Build server       $use_server"
echo "Build baseq2       $use_baseq2"
if [ "$mingw" = "no" ]; then
    if [ "$singleuser" = "yes" ]; then
        echo "Single user        $singleuser"
    else
        echo "Data directory     $datadir"
        echo "Game libraries     $libdir"
        echo "Binaries           $bindir"
        echo "Man pages          $mandir"
        echo "Desktop files      $appdir"
        echo "Pixmap files       $pixdir"
        echo "Home directory     $homedir"
    fi
fi
echo "zlib support       $use_zlib"
if [ "$use_client" = "yes" ]; then
    echo "Refresh type       $use_ref"
    echo "Direct input       $use_dinput"
    echo "Direct sound       $use_dsound"
    echo "DMA sound engine   $use_snddma"
    echo "OAL sound engine   $use_openal"
    [ "$mingw" = "no" ] && echo "LIRC support       $use_lirc"
    echo "CURL support       $use_curl"
    if [ "$use_ref" = "gl" ]; then
        echo "TGA support        $use_tga"
        echo "JPG support        $use_jpg"
        echo "PNG support        $use_png"
        echo "MD3 support        $use_md3"
    fi
    echo "UI support         $use_ui"
fi
[ "$cpu" = "i386" ] && echo "i386 assembly      $use_asm"

CFLAGS="-I\$(OUTDIR) -MF \$*.d -MMD -pipe $CFLAGS -Wno-strict-aliasing"
#LDFLAGS="$LDFLAGS"

# determine what needs to be built
if [ "$use_client" = "yes" ]; then
    targets="$targets q2pro"
else
    use_snddma="no"
    use_openal="no"
    use_dsound="no"
    use_dinput="no"
    use_udev="no"
    use_lirc="no"
    use_curl="no"
    use_tga="no"
    use_png="no"
    use_jpg="no"
    use_md3="no"
    use_sdl="no"
    use_ref="no"
    use_ui="no"
fi

if [ "$use_server" = "yes" ]; then
    targets="$targets q2proded"
else
    use_anticheat="no"
fi

if [ "$use_baseq2" = "yes" ]; then
    targets="$targets baseq2"
fi

if [ "$use_png" = "yes" ]; then
    [ -x `which $pngconfig` ] || die "$pngconfig not found"
    png_ldflags=`$pngconfig --libs`
    png_cflags=`$pngconfig --cflags`
fi

if [ "$use_sdl" = "yes" ]; then
    [ -x `which $sdlconfig` ] || die "$sdlconfig not found"
    sdl_ldflags=`$sdlconfig --libs`
    sdl_cflags=`$sdlconfig --cflags`
fi

# build configuration files
echo "# Generated by configure - do not modify" > $config_mk
echo "// Generated by configure - do not modify" > $config_h

[ "$mingw" = "yes" ] && echo "MINGW=$mingw" >> $config_mk
[ "$wince" = "yes" ] && echo "WINCE=$wince" >> $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=$vpath" >> $config_mk
echo "CFLAGS=$CFLAGS" >> $config_mk
echo "LDFLAGS=$LDFLAGS" >> $config_mk
[ "$mingw" = "yes" ] && echo "RESFLAGS=-I\$(OUTDIR) -I\$(SRCDIR)/src" >> $config_mk
[ "$use_asm" = "yes" ] && echo "ASMFLAGS=$asmflags" >> $config_mk

echo "TARGETS=$targets" >> $config_mk

echo "REVISION=$revision" >> $config_mk
echo "#define REVISION $revision" >> $config_h
echo "#define VERSION \"$version\"" >> $config_h

if [ "$mingw" = "no" ]; then
    echo "#define PRIz \"zu\"" >> $config_h

    echo "DATADIR=$datadir" >> $config_mk
    echo "#define DATADIR \"$datadir\"" >> $config_h

    echo "LIBDIR=$libdir" >> $config_mk
    echo "#define LIBDIR \"$libdir\"" >> $config_h

    echo "#define HOMEDIR \"$homedir\"" >> $config_h

    if [ "$singleuser" = "yes" ]; then
        echo "SINGLEUSER=$singleuser" >> $config_mk
    else
        echo "BINDIR=$bindir" >> $config_mk
        echo "MANDIR=$mandir" >> $config_mk
        echo "APPDIR=$appdir" >> $config_mk
        echo "PIXDIR=$pixdir" >> $config_mk
    fi
else
    echo "#define PRIz \"u\"" >> $config_h # FIXME: change this for x86_64
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 BASEGAME \"$basegame\"" >> $config_h
echo "#define DEFGAME \"$defgame\"" >> $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

if [ "$use_client" = "yes" ]; then
    echo "#define COM_DEMOCACHE_NAME \"$democache\"" >> $config_h
    echo "#define SCREENSHOTS_DIRECTORY \"$screenshots\"" >> $config_h
    echo "#define SCORESHOTS_DIRECTORY \"$scoreshots\"" >> $config_h
fi

if [ "$mingw" = "no" ]; then
    echo "#define SYS_SITECFG_NAME \"$sitecfg\"" >> $config_h
    echo "SITECFG=$sitecfg" >> $config_mk
fi

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

[ "$use_dl" = "yes" ] && echo "USE_DL=yes" >> $config_mk

if [ "$use_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
    [ "$wince" = "yes" ] && echo "#define NO_ERRNO_H" >> $config_h
else
    echo "#define USE_ZLIB 0" >> $config_h
fi

if [ "$use_ref" != "no" ]; then
    echo "USE_REF=$use_ref" >> $config_mk
    echo "#define REF_SOFT 1" >> $config_h
    echo "#define REF_GL 2" >> $config_h
    if [ "$use_ref" = "gl" ]; then
        echo "#define DEFAULT_OPENGL_DRIVER \"$gldriver\"" >> $config_h
    fi
    echo "#define USE_LIGHTSTYLES 1" >> $config_h
    echo "#define USE_DLIGHTS 1" >> $config_h
    echo "#define VID_REF \"$use_ref\"" >> $config_h
    echo "#define VID_MODELIST \"$vid_modelist\"" >> $config_h
    echo "#define VID_GEOMETRY \"$vid_geometry\"" >> $config_h
fi

[ "$use_tga" = "yes" ] && echo "#define USE_TGA 1" >> $config_h

if [ "$use_png" = "yes" ]; then
    echo "USE_PNG=yes" >> $config_mk
    echo "PNG_LDFLAGS=$png_ldflags" >> $config_mk
    echo "PNG_CFLAGS=$png_cflags" >> $config_mk
    echo "#define USE_PNG 1" >> $config_h
fi

if [ "$use_jpg" = "yes" ]; then
    echo "USE_JPG=yes" >> $config_mk
    echo "JPG_LDFLAGS=-ljpeg" >> $config_mk
    echo "JPG_CFLAGS=" >> $config_mk
    echo "#define USE_JPG 1" >> $config_h
fi

[ "$use_md3" = "yes" ] && echo "#define USE_MD3 1" >> $config_h

if [ "$use_ui" = "yes" ]; then
    echo "USE_UI=yes" >> $config_mk
    echo "#define USE_UI 1" >> $config_h
fi

if [ "$use_sdl" = "yes" ]; then
    echo "USE_SDL=yes" >> $config_mk
    echo "SDL_LDFLAGS=$sdl_ldflags" >> $config_mk
    echo "SDL_CFLAGS=$sdl_cflags" >> $config_mk
    echo "#define USE_SDL 1" >> $config_h
    if [ "$use_x11" = "yes" ]; then
        echo "USE_X11=yes" >> $config_mk
        echo "X11_LDFLAGS=-lX11" >> $config_mk
        echo "X11_CFLAGS=" >> $config_mk
        echo "#define USE_X11 1" >> $config_h
    fi
fi

if [ "$use_snddma" = "yes" ]; then
    echo "USE_SNDDMA=yes" >> $config_mk
    echo "#define USE_SNDDMA 1" >> $config_h
fi

if [ "$use_openal" = "yes" ]; then
    echo "USE_OPENAL=yes" >> $config_mk
    echo "#define DEFAULT_OPENAL_DRIVER \"$aldriver\"" >> $config_h
    echo "#define USE_OPENAL 1" >> $config_h
fi

if [ "$use_dsound" = "yes" ]; then
    echo "USE_DSOUND=yes" >> $config_mk
    echo "#define USE_DSOUND 1" >> $config_h
fi

if [ "$use_dinput" = "yes" ]; then
    echo "USE_DINPUT=yes" >> $config_mk
    echo "#define USE_DINPUT 1" >> $config_h
fi

if [ "$use_udev" = "yes" ]; then
    echo "USE_UDEV=yes" >> $config_mk
    echo "#define USE_UDEV 1" >> $config_h
fi

if [ "$use_lirc" = "yes" ]; then
    echo "USE_LIRC=yes" >> $config_mk
    echo "#define USE_LIRC 1" >> $config_h
fi

if [ "$use_curl" = "yes" ]; then
    echo "USE_CURL=yes" >> $config_mk
    echo "CURL_LDFLAGS=-lcurl" >> $config_mk
    echo "CURL_CFLAGS=$curl_cflags" >> $config_mk
    echo "#define USE_CURL 1" >> $config_h
fi

if [ "$use_asm" = "yes" ]; then
    echo "USE_ASM=yes" >> $config_mk
    echo "#define USE_ASM 1" >> $config_h
fi

if [ "$use_anticheat" = "yes" ]; then
    echo "USE_AC_SERVER=yes" >> $config_mk
    echo "#define USE_AC_SERVER !USE_CLIENT" >> $config_h
fi

if [ "$use_mvd_server" = "yes" ]; then
    echo "USE_MVD_SERVER=yes" >> $config_mk
    echo "#define USE_MVD_SERVER 1" >> $config_h
fi

if [ "$use_mvd_client" = "yes" ]; then
    echo "USE_MVD_CLIENT=yes" >> $config_mk
    echo "#define USE_MVD_CLIENT 1" >> $config_h
fi

if [ "$use_dbghelp" = "yes" ]; then
    echo "USE_DBGHELP=yes" >> $config_mk
    echo "#define USE_DBGHELP 1" >> $config_h
fi

[ "$use_syscon" = "yes" ] && echo "#define USE_SYSCON 1" >> $config_h
[ "$use_winsvc" = "yes" ] && echo "#define USE_WINSVC !USE_CLIENT" >> $config_h
[ "$use_icmp" = "yes" ] && echo "#define USE_ICMP 1" >> $config_h
[ "$use_fps" = "yes" ] && echo "#define USE_FPS 1" >> $config_h
echo "#define USE_MAPCHECKSUM 1" >> $config_h
echo "#define USE_AUTOREPLY 1" >> $config_h
[ "$have_endian_h" = "yes" ] && echo "#define HAVE_ENDIAN_H 1" >> $config_h
echo "#define HAVE_STDINT_H 1" >> $config_h
echo "#define HAVE_INTTYPES_H 1" >> $config_h

for t in $targets ; do
    mkdir -p .$t ;
done