-
Notifications
You must be signed in to change notification settings - Fork 112
/
configure
executable file
·1028 lines (916 loc) · 23.1 KB
/
configure
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
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
#
# Some things this script could/should do when finished
#
# * detect whether it's a GNU compiler or not (for compiler settings)
# * command line options to...
# - override the host settings (for cross compiles
# - whether to do a debug build (with -g) or an optimized build (-O3 etc.)
# * detect whether the chosen backend is available (e.g. call sdl2-config)
# * ....
# use environment vars if set
CXXFLAGS="$CXXFLAGS $CPPFLAGS"
if test -n "$CXXFLAGS_TEST"; then
CXXFLAGS_TEST="$CXXFLAGS_TEST $CPPFLAGS"
else
CXXFLAGS_TEST="$CXXFLAGS"
fi
if test -z "$LDFLAGS_TEST"; then
LDFLAGS_TEST="$LDFLAGS"
fi
# default option behaviour yes/no
_build_gui=yes
_build_windowed=yes
_build_sound=yes
_build_debugger=yes
_build_joystick=yes
_build_cheats=yes
_build_httplib=yes
_build_png=yes
_build_sqlite3=yes
_build_zip=yes
_build_static=no
_build_profile=no
_build_debug=no
_build_release=no
_build_mold=no
# more defaults
_ranlib=ranlib
_install=install
_ar="ar cru"
_strip=strip
_mkdir="mkdir -p"
_echo=printf
_cat=cat
_rm="rm -f"
_rm_rec="$_rm -r"
_zip="zip -q"
_cp=cp
_windowspath=""
_sdlconfig=sdl2-config
_sdlpath="$PATH"
_prefix=/usr/local
_srcdir=`dirname $0`
# TODO: We should really use mktemp(1) to determine a random tmp file name.
# However, that tool might not be available everywhere.
TMPO=${_srcdir}/stella-conf
TMPC=${TMPO}.cxx
TMPLOG=${_srcdir}/config.log
# For cross compiling
_host=""
_host_cpu=""
_host_vendor=""
_host_os=""
_host_prefix=""
cc_check() {
echo >> "$TMPLOG"
cat "$TMPC" >> "$TMPLOG"
echo >> "$TMPLOG"
echo "$CXX $TMPC $CXXFLAGS $LDFLAGS -o $TMPO$EXEEXT $@" >> "$TMPLOG"
rm -f "$TMPO$EXEEXT"
( $CXX "$TMPC" $CXXFLAGS $LDFLAGS -o "$TMPO$EXEEXT" "$@" ) >> "$TMPLOG" 2>&1
TMP="$?"
echo >> "$TMPLOG"
return "$TMP"
}
cc_check_define() {
cat > $TMPC << EOF
int main(void) {
#ifndef $1
syntax error
#endif
return 0;
}
EOF
cc_check -c
return $?
}
echocheck () {
echo_n "Checking for $@... "
}
#
# Check whether the given command is a working C++ compiler
#
test_compiler ()
{
cat <<EOF >tmp_cxx_compiler.cpp
#include <memory>
class Foo {
int a;
};
int main(int argc, char* argv[])
{
std::shared_ptr<Foo> a = std::make_shared<Foo>();
return 0;
}
EOF
if test -n "$_host"; then
# In cross-compiling mode, we cannot run the result
eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp 2> /dev/null" && rm -f tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp
else
eval "$1 $CXXFLAGS $LDFLAGS -o tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp 2> /dev/null" && eval "./tmp_cxx_compiler 2> /dev/null" && rm -f tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp
fi
}
# Add a line of data to config.mk.
add_line_to_config_mk() {
_config_mk_data="$_config_mk_data"'
'"$1"
}
#
# Determine sdl2-config
#
# TODO: small bit of code to test sdl useability
find_sdlconfig()
{
echo_n "Looking for sdl2-config... "
sdlconfigs="$_sdlconfig"
_sdlconfig=
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="$SEPARATOR"
done=0
for path_dir in $_sdlpath; do
#reset separator to parse sdlconfigs
IFS=":"
for sdlconfig in $sdlconfigs; do
if test -x "$path_dir/$sdlconfig" ; then
_sdlconfig="$path_dir/$sdlconfig"
done=1
break
fi
done
if test $done -eq 1 ; then
echo $_sdlconfig
break
fi
done
IFS="$ac_save_ifs"
if test -z "$_sdlconfig"; then
echo "none found!"
exit 1
fi
}
#
# Function to provide echo -n for bourne shells that don't have it
#
echo_n()
{
printf "$@"
}
#
# Greet user
#
echo "Running Stella configure..."
echo "Configure run on" `date` > $TMPLOG
#
# Check any parameters we received
#
for parm in "$@" ; do
if test "$parm" = "--help" || test "$parm" = "-help" || test "$parm" = "-h" ; then
cat << EOF
Usage: $0 [OPTIONS]...
Configuration:
-h, --help display this help and exit
Installation directories:
--prefix=DIR use this prefix for installing stella [/usr/local]
--bindir=DIR directory to install the stella binary [PREFIX/bin]
--docdir=DIR directory to install documentation [PREFIX/share/doc/stella]
--datadir=DIR directory to install icons/data files [PREFIX/share]
Optional Features:
--enable-gui enable/disable the entire built-in UI [enabled]
--disable-gui
--enable-sound enable/disable sound support [enabled]
--disable-sound
--enable-debugger enable/disable all debugger options [enabled]
--disable-debugger
--enable-joystick enable/disable joystick support [enabled]
--disable-joystick
--enable-cheats enable/disable cheatcode support [enabled]
--disable-cheats
--enable-png enable/disable PNG image support [enabled]
--disable-png
--enable-zip enable/disable ZIP file support [enabled]
--disable-zip
--enable-windowed enable/disable windowed rendering modes [enabled]
--disable-windowed
--enable-shared build shared binary [enabled]
--enable-static build static binary (if possible) [disabled]
--disable-static
--enable-profile build binary with profiling info [disabled]
--disable-profile
--enable-debug build with debugging symbols [disabled]
--disable-debug
--enable-release build with all optimizations, for final release [disabled]
--disable-release
--use-mold-linker use mold linker (experimental) [disabled]
Optional Libraries:
--with-sdl-prefix=DIR Prefix where the sdl2-config script is installed (optional)
--with-libpng-prefix=DIR Prefix where libpng is installed (optional)
--with-zlib-prefix=DIR Prefix where zlib is installed (optional)
--with-gtest-prefix=DIR Prefix where googletest is installed (optional)
Some influential environment variables:
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPPFLAGS C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>
LDFLAGS_TEST linker flags for unit tests
CXXFLAGS_TEST C++ compiler flags for unit tests
EOF
exit 0
fi
done # for parm in ...
for ac_option in $@; do
case "$ac_option" in
--enable-gui) _build_gui=yes ;;
--disable-gui) _build_gui=no ;;
--enable-sound) _build_sound=yes ;;
--disable-sound) _build_sound=no ;;
--enable-debugger) _build_debugger=yes ;;
--disable-debugger) _build_debugger=no ;;
--enable-joystick) _build_joystick=yes ;;
--disable-joystick) _build_joystick=no ;;
--enable-cheats) _build_cheats=yes ;;
--disable-cheats) _build_cheats=no ;;
--enable-png) _build_png=yes ;;
--disable-png) _build_png=no ;;
--enable-zip) _build_zip=yes ;;
--disable-zip) _build_zip=no ;;
--enable-windowed) _build_windowed=yes ;;
--disable-windowed) _build_windowed=no ;;
--enable-shared) _build_static=no ;;
--enable-static) _build_static=yes ;;
--disable-static) _build_static=no ;;
--enable-profile) _build_profile=yes ;;
--disable-profile) _build_profile=no ;;
--enable-debug) _build_debug=yes ;;
--disable-debug) _build_debug=no ;;
--enable-release) _build_release=yes ;;
--disable-release) _build_release=no ;;
--use-mold-linker) _build_mold=yes ;;
--with-sdl-prefix=*)
arg=`echo $ac_option | cut -d '=' -f 2`
_sdlpath="$arg:$arg/bin"
;;
--with-libpng-prefix=*)
_prefix=`echo $ac_option | cut -d '=' -f 2`
LIBPNG_CFLAGS="-I$_prefix/include"
LIBPNG_LIBS="-L$_prefix/lib"
;;
--with-zlib-prefix=*)
_prefix=`echo $ac_option | cut -d '=' -f 2`
ZLIB_CFLAGS="-I$_prefix/include"
ZLIB_LIBS="-L$_prefix/lib"
;;
--with-gtest-prefix=*)
_prefix=`echo $ac_option | cut -d '=' -f 2`
CXXFLAGS_TEST="$CXXFLAGS_TEST -I$_prefix/include"
LDFLAGS_TEST="$LDFLAGS_TEST -L$_prefix/lib"
;;
--host=*)
_host=`echo $ac_option | cut -d '=' -f 2`
;;
--prefix=*)
_prefix=`echo $ac_option | cut -d '=' -f 2`
;;
--bindir=*)
_bindir=`echo $ac_option | cut -d '=' -f 2`
;;
--docdir=*)
_docdir=`echo $ac_option | cut -d '=' -f 2`
;;
--datadir=*)
_datadir=`echo $ac_option | cut -d '=' -f 2`
;;
*)
echo "warning: unrecognised option: $ac_option"
;;
esac;
done;
CXXFLAGS="$CXXFLAGS $DEBFLAGS"
case $_host in
#linupy)
# _host_os=linux
# _host_cpu=arm
# ;;
#arm-riscos-aof)
# _host_os=riscos
# _host_cpu=arm
# ;;
#ppc-amigaos)
# _host_os=amigaos
# _host_cpu=ppc
# ;;
retron77)
_host_os=retron77
;;
mingw32-cross)
_host_os=mingw32msvc
_host_cpu=i386
_host_prefix=i386-mingw32msvc
;;
*)
guessed_host=`$_srcdir/config.guess`
_host_cpu=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
_host_os=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
_host_vendor=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
;;
esac
#
# Determine extension used for executables
#
case $_host_os in
mingw* | cygwin* |os2-emx*)
EXEEXT=".exe"
;;
arm-riscos-aof)
EXEEXT=",ff8"
;;
psp)
EXEEXT=".elf"
;;
*)
EXEEXT=""
;;
esac
#
# Determine separator used for $PATH
#
case $_host_os in
os2-emx* )
SEPARATOR=";"
;;
* )
SEPARATOR=":"
;;
esac
#
# Determine the C++ compiler
#
echo_n "Looking for C++ compiler... "
if test -n "$CXX"; then
echo $CXX
else
if test -n "$_host"; then
compilers="$_host_prefix-g++ $_host_prefix-c++ $_host_cpu-$_host_os-g++ $_host_cpu-$_host_os-c++ g++ c++"
else
compilers="g++ c++"
fi
for compiler in $compilers; do
if test_compiler "$compiler -std=c++20"; then
CXX=$compiler
echo $CXX
break
fi
done
if test -z "$CXX"; then
echo "none found!"
exit 1
fi
fi
#
# Determine the compiler version
echocheck "compiler version"
have_clang=no
cc_check_define __clang_version__ && have_clang=yes
if test $have_clang = no; then
cc_check_define __clang__ && have_clang=yes
fi
have_gcc=no
cc_check_define __GNUC__ && have_gcc=yes
if test "$have_clang" = yes; then
clang_minor=$( $CXX -dM -E -x c /dev/null | grep __clang_minor__ | sed -E 's/.* ([0-9]+).*/\1/' )
clang_patch=$( $CXX -dM -E -x c /dev/null | grep __clang_patchlevel__ | sed -E 's/.* ([0-9]+).*/\1/' )
clang_major=$( $CXX -dM -E -x c /dev/null | grep __clang_major__ | sed -E 's/.* ([0-9]+).*/\1/' )
cxx_version="$clang_major.$clang_minor.$clang_patch"
is_xcode=$( $CXX -dM -E -x c /dev/null | grep __apple_build_version__ )
# Need at least version 8
if test -n "$is_xcode"; then
cxx_name="XCode $cxx_version"
if test $clang_major -ge 8; then
cxx_version="$cxx_version, ok"
cxx_verc_fail=no
else
cxx_version="$cxx_version, bad"
cxx_verc_fail=yes
fi
_make_def_CLANG_WARNINGS='CLANG_WARNINGS = 1'
else
# Need at least version 3.5
if [ $clang_major -ge 4 ] || [ $clang_major -eq 3 -a $clang_minor -ge 5 ]; then
cxx_version="$cxx_version, ok"
cxx_verc_fail=no
else
cxx_version="$cxx_version, bad"
cxx_verc_fail=yes
fi
# Only clang >= 5.0 supports extra warnings
if [ $clang_major -ge 5 ]; then
_make_def_CLANG_WARNINGS='CLANG_WARNINGS = 1'
fi
fi
CXXFLAGS="$CXXFLAGS"
_make_def_HAVE_CLANG='HAVE_CLANG = 1'
add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP'
echo "$cxx_version"
elif test "$have_gcc" = yes; then
cxx_name=`( $cc -v ) 2>&1 | tail -n 1 | cut -d ' ' -f 1`
cxx_version=`( $CXX -dumpversion ) 2>&1`
if test "$?" -gt 0; then
cxx_version="not found"
fi
case $cxx_version in
[1-9]*)
_cxx_major=`echo $cxx_version | cut -d '.' -f 1`
_cxx_minor=`echo $cxx_version | cut -d '.' -f 2`
# Need at least version 4.7
if [ $_cxx_major -ge 5 ] || [ $_cxx_major -eq 4 -a $_cxx_minor -ge 7 ]; then
cxx_version="$cxx_version, ok"
cxx_verc_fail=no
else
cxx_version="$cxx_version, bad"
cxx_verc_fail=yes
fi
;;
'not found')
cxx_verc_fail=yes
;;
*)
cxx_version="$cxx_version, bad"
cxx_verc_fail=yes
;;
esac
CXXFLAGS="$CXXFLAGS"
add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MMD -MF "$(*D)/$(DEPDIR)/$(*F).d" -MQ "$@" -MP'
_make_def_HAVE_GCC='HAVE_GCC = 1'
echo "$cxx_version"
else
cxx_version=`( $CXX -version ) 2>&1`
if test "$?" -eq 0; then
cxx_version="`echo "${cxx_version}" | sed -ne 's/^.*[^0-9]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$/\1/gp'`"
if test -z "${cxx_version}"; then
cxx_version="not found"
cxx_verc_fail=yes
fi
echo non-gcc compiler version ${cxx_version}
else
cxx_version="not found"
cxx_verc_fail=yes
echo found non-gcc compiler version ${cxx_version}
fi
CXXFLAGS="$CXXFLAGS"
case $_host_os in
irix*)
case $cxx_version in
7.4.4*)
# We just assume this is SGI MIPSpro
_cxx_major=7
_cxx_minor=4
cxx_verc_fail=no
add_line_to_config_mk 'CXX_UPDATE_DEP_FLAG = -MDupdate "$(*D)/$(DEPDIR)/$(*F).d"'
add_line_to_config_mk '-include Makedepend'
;;
*)
cxx_version="$cxx_version, bad"
cxx_verc_fail=yes
;;
esac
;;
*)
cxx_version="$cxx_version, bad"
cxx_verc_fail=yes
;;
esac
fi
if test "$cxx_verc_fail" = yes ; then
echo
echo "The version of your compiler is not supported at this time"
echo "Please ensure you are using GCC 5.0 / Clang 3.8 or above"
exit 1
fi
#
# Do CXXFLAGS now we know the compiler version
#
if test -n "$_host"; then
# Cross-compiling mode - add your target here if needed
case "$_host" in
retron77)
echo "Compiling for $_host, disabling windowed mode, debugger and cheats."
_build_gui=yes
_build_windowed=no
_build_debugger=no
_build_cheats=no
_build_httplib=no
;;
mingw32-cross)
echo "Cross-compiling for Windows using MinGW."
DEFINES="$DEFINES -DWIN32"
_host_os=win32
;;
*linux*)
echo "Cross-compiling to $_host target"
DEFINES="$DEFINES -DUNIX"
_host_os=unix
;;
*)
echo "Cross-compiling to unknown target, please add your target to configure."
exit 1
;;
esac
else
#
# Determine build settings
#
# TODO - also add an command line option to override this?!?
echo_n "Checking hosttype... "
echo $_host_os
case $_host_os in
linux* | openbsd* | freebsd* | kfreebsd* | netbsd* | bsd* | gnu0.* | sunos* | hpux* | beos*)
DEFINES="$DEFINES -DUNIX"
_host_os=unix
;;
darwin*)
DEFINES="$DEFINES -DUNIX -DDARWIN"
_host_os=darwin
;;
irix*)
DEFINES="$DEFINES -DUNIX"
_ranlib=:
_host_os=unix
;;
mingw*)
DEFINES="$DEFINES -DWIN32"
_host_os=win32
;;
os2*)
DEFINES="$DEFINES -DUNIX -DOS2"
_host_os=unix
;;
cygwin*)
DEFINES="$DEFINES -mno-cygwin -DWIN32"
LIBS="$LIBS -mno-cygwin -lmingw32 -lwinmm"
_host_os=win32
;;
os2*)
DEFINES="$DEFINES -DUNIX -DOS2"
_host_os=unix
;;
# given this is a shell script assume some type of unix
*)
echo "WARNING: could not establish system type, assuming unix like"
DEFINES="$DEFINES -DUNIX"
;;
esac
fi
# Cross-compilers use their own commands for the following functions
if test -n "$_host_prefix"; then
_strip="$_host_prefix-$_strip"
fi
#
# Check for ZLib
#
echocheck "zlib"
if test "$_build_zip" = yes ; then
_zlib=no
cat > $TMPC << EOF
#include <string.h>
#include <zlib.h>
int main(void) { return strcmp(ZLIB_VERSION, zlibVersion()); }
EOF
cc_check $LDFLAGS $CXXFLAGS $ZLIB_CFLAGS $ZLIB_LIBS `pkg-config --libs zlib` && _zlib=yes
if test "$_zlib" = yes ; then
echo "$_zlib"
else
echo "disabled"
_build_png=no
_build_zip=no
fi
else
echo "disabled"
_build_png=no
_build_zip=no
fi
#
# Check for libpng
#
echocheck "libpng"
if test "$_build_png" = yes ; then
_libpng=no
cat > $TMPC << EOF
#include <stdio.h>
#include <png.h>
int main(void) { return printf("%s\n", PNG_HEADER_VERSION_STRING); }
EOF
cc_check $LDFLAGS $CXXFLAGS $LIBPNG_CFLAGS $LIBPNG_LIBS `pkg-config --libs libpng` && _libpng=yes
if test "$_libpng" = yes ; then
echo "$_libpng"
else
echo "disabled"
_build_png=no
fi
else
echo "disabled"
_build_png=no
fi
#
# Check for sqlite3
#
echocheck "libsqlite3"
if test "$_build_sqlite3" = yes ; then
_libsqlite3=no
cat > $TMPC << EOF
#include <stdio.h>
#include <sqlite3.h>
int main(void) { return printf("%s\n", SQLITE_VERSION); }
EOF
cc_check $LDFLAGS $CXXFLAGS `pkg-config --libs sqlite3` && _libsqlite3=yes
if test "$_libsqlite3" = yes ; then
echo "$_libsqlite3"
else
echo "built-in"
_build_sqlite3=yes
fi
else
echo "built-in"
_build_sqlite3=yes
fi
#
# figure out installation directories
#
test -z "$_bindir" && _bindir="$_prefix/bin"
test -z "$_docdir" && _docdir="$_prefix/share/doc/stella"
test -z "$_datadir" && _datadir="$_prefix/share"
echo
echo_n "Summary:"
echo
if test "$_build_gui" = "yes" ; then
echo_n " GUI enabled"
echo
else
echo_n " GUI disabled"
echo
_build_debugger=no
_build_cheats=no
fi
if test "$_build_sound" = "yes" ; then
echo_n " Sound support enabled"
echo
else
echo_n " Sound support disabled"
echo
fi
if test "$_build_debugger" = "yes" ; then
echo_n " Debugger support enabled"
echo
else
echo_n " Debugger support disabled"
echo
fi
if test "$_build_joystick" = yes ; then
echo_n " Joystick support enabled"
echo
else
echo_n " Joystick support disabled"
echo
fi
if test "$_build_cheats" = yes ; then
echo_n " Cheatcode support enabled"
echo
else
echo_n " Cheatcode support disabled"
echo
fi
if test "$_build_png" = yes ; then
echo_n " PNG image support enabled"
echo
else
echo_n " PNG image support disabled"
echo
fi
if test "$_build_zip" = yes ; then
echo_n " ZIP file support enabled"
echo
else
echo_n " ZIP file support disabled"
echo
fi
if test "$_build_windowed" = "yes" ; then
echo_n " Windowed rendering modes enabled"
echo
else
echo_n " Windowed rendering modes disabled"
echo
fi
if test "$_build_static" = yes ; then
echo_n " Static binary enabled"
echo
else
echo_n " Static binary disabled"
echo
fi
if test "$_build_profile" = yes ; then
echo_n " Profiling enabled"
echo
_build_debug=yes
else
echo_n " Profiling disabled"
echo
fi
if test "$_build_debug" = yes ; then
echo_n " Debug symbols enabled"
echo
else
echo_n " Debug symbols disabled"
echo
fi
#
# Now, add the appropriate defines/libraries/headers
#
echo
find_sdlconfig
SRC="src"
SRC_OS="$SRC/os"
SRC_LIB="$SRC/lib"
CORE="$SRC/emucore"
COMMON="$SRC/common"
TIA="$SRC/emucore/tia"
ELF="$SRC/emucore/elf"
TIA_FRAME_MANAGER="$SRC/emucore/tia/frame-manager"
TV="$SRC/common/tv_filters"
GUI="$SRC/gui"
DBG="$SRC/debugger"
DBGGUI="$SRC/debugger/gui"
YACC="$SRC/debugger/yacc"
CHEAT="$SRC/cheat"
LIBPNG="$SRC_LIB/libpng"
LIBJPG="$SRC_LIB/nanojpeg"
LIBJPGEXIF="$SRC_LIB/tinyexif"
ZLIB="$SRC_LIB/zlib"
SQLITE_REPO="$SRC/common/repository/sqlite"
SQLITE_LIB="$SRC_LIB/sqlite"
JSON="$SRC_LIB/json"
HTTP_LIB="$SRC_LIB/httplib"
INCLUDES="-I$CORE -I$COMMON -I$TV -I$TIA -I$TIA_FRAME_MANAGER -I$ELF -I$JSON -I$SQLITE_REPO"
INCLUDES="$INCLUDES `$_sdlconfig --cflags`"
if test "$_build_static" = yes ; then
_sdl_conf_libs="--static-libs"
LDFLAGS="-static $LDFLAGS"
else
_sdl_conf_libs="--libs"
fi
LIBS="$LIBS `$_sdlconfig $_sdl_conf_libs`"
LD=$CXX
case $_host_os in
unix)
DEFINES="$DEFINES -DBSPF_UNIX"
MODULES="$MODULES $SRC_OS/unix"
INCLUDES="$INCLUDES -I$SRC_OS/unix"
;;
darwin)
DEFINES="$DEFINES -DBSPF_UNIX -DMACOS_KEYS"
MODULES="$MODULES $SRC_OS/unix"
INCLUDES="$INCLUDES -I$SRC_OS/unix"
if test "$have_clang" == yes; then
CXXFLAGS="$CXXFLAGS -Wno-poison-system-directories"
if test -n "$CXXFLAGS_TEST"; then
CXXFLAGS_TEST="$CXXFLAGS_TEST -Wno-poison-system-directories"
fi
fi
_libsqlite3=no
;;
retron77)
DEFINES="$DEFINES -DBSPF_UNIX -DRETRON77"
MODULES="$MODULES $SRC_OS/unix $SRC_OS/unix/r77"
INCLUDES="$INCLUDES -I$SRC_OS/unix -I$SRC_OS/unix/r77"
;;
win32)
DEFINES="$DEFINES -DBSPF_WINDOWS"
MODULES="$MODULES $SRC_OS/windows"
INCLUDES="$INCLUDES -I$SRC_OS/windows"
LIBS="$LIBS -lmingw32 -lwinmm"
;;
*)
echo "WARNING: host system not currently supported"
exit
;;
esac
if test "$_build_gui" = yes ; then
DEFINES="$DEFINES -DGUI_SUPPORT"
MODULES="$MODULES $GUI"
INCLUDES="$INCLUDES -I$GUI"
fi
if test "$_build_windowed" = yes ; then
DEFINES="$DEFINES -DWINDOWED_SUPPORT"
fi
if test "$_build_sound" = yes ; then
DEFINES="$DEFINES -DSOUND_SUPPORT"
fi
if test "$_build_debugger" = yes ; then
DEFINES="$DEFINES -DDEBUGGER_SUPPORT"
MODULES="$MODULES $DBG $DBGGUI $YACC"
INCLUDES="$INCLUDES -I$DBG -I$DBGGUI -I$YACC"
fi
if test "$_build_joystick" = yes ; then
DEFINES="$DEFINES -DJOYSTICK_SUPPORT"
fi
if test "$_build_cheats" = yes ; then
DEFINES="$DEFINES -DCHEATCODE_SUPPORT"
MODULES="$MODULES $CHEAT"
INCLUDES="$INCLUDES -I$CHEAT"
fi
if test "$_build_httplib" = yes ; then
DEFINES="$DEFINES -DHTTP_LIB_SUPPORT"
INCLUDES="$INCLUDES -I$HTTP_LIB"
fi
if test "$_build_png" = yes ; then
DEFINES="$DEFINES -DIMAGE_SUPPORT"
INCLUDES="$INCLUDES -I$LIBJPG -I$LIBJPGEXIF"
MODULES="$MODULES $LIBJPGEXIF"
if test "$_libpng" = yes ; then
LIBS="$LIBS `pkg-config --libs libpng`"
else
MODULES="$MODULES $LIBPNG"
INCLUDES="$INCLUDES -I$LIBPNG"
fi
fi
if test "$_libsqlite3" = yes ; then
LIBS="$LIBS `pkg-config --libs sqlite3`"
else
MODULES="$MODULES $SQLITE_LIB"
INCLUDES="$INCLUDES -I$SQLITE_LIB"
fi
if test "$_build_zip" = yes ; then
DEFINES="$DEFINES -DZIP_SUPPORT"
if test "$_zlib" = yes ; then
LIBS="$LIBS `pkg-config --libs zlib`"
else
MODULES="$MODULES $ZLIB"
INCLUDES="$INCLUDES -I$ZLIB"
fi
fi
if test "$_build_profile" = no ; then
_build_profile=
fi
if test "$_build_debug" = no ; then
_build_debug=
fi
if test "$_build_release" = no ; then
_build_release=
fi
if test "$_build_mold" = yes ; then
LDFLAGS="-fuse-ld=mold"
fi
# Workaround until we deal with autodetection of C compiler properly
# Or we remove C files from Stella entirely, by making them C++
if test -z "$CC"; then
CC=cc
fi
echo "Creating config.mak"
cat > config.mak << EOF
# -------- Generated by configure -----------
CC := $CC
CXX := $CXX
CXXFLAGS := $CXXFLAGS
CXXFLAGS_TEST := $CXXFLAGS_TEST
LD := $LD
LIBS += $LIBS
RANLIB := $_ranlib
INSTALL := $_install
AR := $_ar
MKDIR := $_mkdir
ECHO := $_echo
CAT := $_cat
RM := $_rm
RM_REC := $_rm_rec
ZIP := $_zip
CP := $_cp
WINDOWSPATH=$_windowspath
STRIP := $_strip
LLVM_PROFDATA := llvm-profdata
BINARY_LOADER :=
MODULES += $MODULES
MODULE_DIRS += $MODULE_DIRS
EXEEXT := $EXEEXT
PREFIX := $_prefix