-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·3508 lines (3086 loc) · 95.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
#
# GPAC configure script
# (c) 2003-2022 Telecom ParisTech
# Authors: Jean Le Feuvre, Romain Bouqueau, Aurelien David
#
#set -v
#set temporary file name
if test ! -z "$TMPDIR" ; then
TMPDIR1="${TMPDIR}"
elif test ! -z "$TEMPDIR" ; then
TMPDIR1="${TEMPDIR}"
else
TMPDIR1="/tmp"
fi
#remember the ./configure command line
GPAC_CONFIGURATION="$@"
TMPC="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}.c"
TMPH="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}.h"
TMPCXX="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}.cpp"
TMPE="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}"
TMPO="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}.o"
TMPS="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}.S"
TMPL="${TMPDIR1}/gpac-conf-${RANDOM}-$$-${RANDOM}.LOG"
#default parameters
DESTDIR=""
prefix="/usr/local"
mandir=""
cross_prefix=""
targetos=""
dxsdk_path=""
moz_path="local"
cc_orig=$CC
if test "$cc_orig" = "" ; then
cc_orig="gcc"
fi
cxx_orig=$CXX
if test "$cxx_orig" = "" ; then
cxx_orig="g++"
fi
ar="ar"
ranlib="ranlib"
make="make"
strip="strip"
pkg_config="pkg-config"
windres="windres"
readelf="readelf"
install="${INSTALL:=install}"
instflags="${INSTFLAGS:=-p}"
cpu=`uname -m`
debuginfo="no"
sdl_path=""
sdl_local="no"
sdl_static="no"
verbose="no"
xulsdk_path="/usr/lib/xulrunner/sdk/include"
xul_flags=""
libdir="lib"
#GPAC module config
static_modules="no"
lm_lib=""
has_mingw_directx="no"
has_js="no"
has_platinum="no"
has_ft="no"
has_jpeg="no"
has_png="no"
has_xvid="no"
has_mad="no"
has_faad="no"
has_ffmpeg="no"
ffmpeg_vvc="no"
has_amr_nb_fixed="no"
has_amr_nb="no"
has_amr_wb="no"
has_ogg="no"
has_vorbis="no"
has_theora="no"
has_a52="no"
has_pulseaudio="no"
has_oss_audio="no"
has_alsa="no"
has_jack="no"
has_directfb="no"
has_x11="no"
has_x11_shm="no"
has_x11_xv="no"
no_gcc_opt="no"
use_fixed_point="no"
use_memory_tracking="no"
has_opengl="no"
has_tinygl="no"
enable_tinygl="no"
has_ssl="no"
has_ipv6="no"
has_dvb4linux="no"
has_openjpeg="no"
gprof_build="no"
static_build="no"
want_pic="no"
want_gcov="no"
has_joystick="no"
has_hid="no"
has_sock_un="no"
has_lzma="no"
has_nghttp2="no"
enable_joystick="no"
static_bin="no"
disable_core_tools="no"
disable_3d="no"
disable_svg="no"
disable_vrml="no"
disable_x3d="no"
disable_od="no"
disable_bifs="no"
disable_bifs_enc="no"
disable_laser="no"
disable_saf="no"
disable_smgr="no"
disable_seng="no"
disable_qtvr="no"
disable_avi="no"
disable_m2ps="no"
disable_m2ts="no"
disable_m2ts_mux="no"
disable_ogg="no"
disable_parsers="no"
disable_import="no"
disable_export="no"
disable_swf="no"
disable_scene_stats="no"
disable_scene_dump="no"
disable_scene_encode="no"
disable_loader_isoff="no"
disable_loader_bt="no"
disable_loader_xmt="no"
disable_od_dump="no"
disable_od_parse="no"
disable_isom_dump="no"
disable_crypto="no"
disable_mpd="no"
disable_dash="no"
disable_isoff="no"
disable_isoff_write="no"
disable_isoff_frag="no"
disable_isoff_hint="no"
disable_isoff_frag="no"
disable_isoff_hds="no"
disable_streaming="no"
disable_player="no"
disable_scenegraph="no"
disable_dvbx="yes"
disable_vobsub="no"
disable_ttxt="no"
disable_ttml="no"
disable_hevc="no"
disable_route="no"
disable_crypto="no"
disable_log="no"
disable_nvdec="no"
enable_qjs="yes"
enable_qjs_libc="yes"
enable_depth_compositor="no"
enable_sanitizer="no"
has_opensvc="no"
has_openhevc="no"
has_vtb="no"
has_strlcpy="no"
disable_codecs="no"
enable_qjs_stack_check="no"
win32="no"
mingw32="no"
cygwin="no"
linux="no"
freebsd="no"
darwin="no"
sunos="no"
alt_macosx_dir=""
Mac_Applications=""
extralibs="-lm"
bigendian="no"
SHFLAGS=-shared
need_inet_aton="no"
CFLAGS=""
CXXFLAGS=""
GPAC_SH_FLAGS=-lpthread
DYN_LIB_SUFFIX=".so"
X11_PATH="/usr/X11R6"
OSS_CFLAGS=""
OSS_LDFLAGS=""
INSTFLAGS=""
is_64="no"
ffmpeg_extra_ldflags=""
has_st_nsec="no"
logs="config.log"
echo "Logs for GPAC configure $GPAC_CONFIGURATION" > $logs
#configure usage
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat << EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
GPAC configuration options:
--help print this message
--prefix=PREFIX install in PREFIX [$prefix]
--mandir=DIR man documentation in DIR [PREFIX/share/man]
--verbose enable verbose building [$verbose]
--source-path=PATH path of source code [$source_path]
--cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
--target-os=TARGETOS use TARGETOS for compile tools [$targetos]
--cc=CC use C compiler CC [$cc]
--cxx=CXX use C++ compiler CXX [$cxx]
--make=MAKE use specified make [$make]
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
--extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
--extra-libs=ELIBS add ELIBS [$ELIBS]
--cpu=CPU force cpu to CPU [$cpu]
--sdl-cfg=SDL_PATH specify path to sdl-config for local install [$sdl_path]
--enable-sdl-static use static SDL linking [default=no]
--X11-path=X11_PATH specify path for X11 includes and libraries [$X11_PATH]
--dxsdk-path=DX_PATH specify directX SDK for MinGW [$dxsdk_path]
--xulsdk-path=XUL_PATH specify Mozilla XUL (Gecko) SDK include path [$xulsdk_path]
--mozdir=MOZ_PATH specify mozilla main directory path for system install
--extra-ff-ldflags=ELDFLAGS add ELDFLAGS to FFMPEG LDFLAGS [$ffmpeg_extra_ldflags]
--enable-debug produce debug version
--enable-gprof enable profiling
--enable-gcov enable coverage
--enable-pic enable Position Independant Code for shared objects
--strip enable strip
--std-allocator uses standard lib memory allocator
--enable-mem-track enable tracking of all memory allocated by gpac
--enable-sanitizer enable address sanitizer
--enable-afl enable instrumentation for American Fuzzy Lop
--enable-afl-clang enable instrumentation for American Fuzzy Lop using afl-clang(++)
--disable-opt disable GCC optimizations
--disable-ipv6 disable IPV6 support
--disable-platinum disable Platinum UPnP support
--disable-alsa disable Alsa audio
--disable-oss-audio disable OSS audio
--enable-jack enable Jack audio
--disable-jack disable Jack audio
--enable-pulseaudio enable Pulse audio
--disable-pulseaudio disable Pulse audio
--disable-x11 disable X11
--disable-x11-shm disable X11 shared memory support
--disable-x11-xv disable X11 Xvideo support
--enable-fixed-point enable fixed-point math
--enable-tinygl enable TinyGL support
--enable-joystick enable joystick support
--disable-ssl disable OpenSSL support
--enable-amr-nb-fixed enable AMR NB fixed-point decoder
--enable-amr-nb enable AMR NB library
--enable-amr-wb enable AMR WB library
--enable-amr enable both AMR NB and WB libraries
--static-modules use static modules in libgpac rather than dynamic library modules
--static-build link statically against libgpac but still allow dependencies to shared libraries (enable --static-modules)
--enable-static-bin old name for --static-build, deprecated
--static-bin enable static linking of MP4Box and gpac only (enable --static-build), disable all libraries not linkable statically.
--static-mp4box old name for --static-bin, deprecated
--enable-depth enables depth handling in the compositor
--enable-qjs-stack enables stack depth checking in QuickJS (WILL CRASH in multithreaded modes)
Configuration options for libgpac - all options can be enabled with --enable-optname
--disable-all disables all features in libgpac
--disable-3d disable 3D rendering
--disable-svg disable SVG
--disable-vrml disable MPEG-4/VRML/X3D
--disable-x3d disable X3D only
--disable-odf disable full support of MPEG-4 OD Framework
--disable-bifs disable BIFS
--disable-bifs-enc disable BIFS coder
--disable-laser disable LASeR coder
--disable-saf disable SAF container
--disable-seng disable scene encoder engine
--disable-qtvr disable import of Cubic QTVR files
--disable-avi disable AVI
--disable-ogg disable OGG
--disable-m2ps disable MPEG2 PS
--disable-m2ts disable MPEG2 TS
--disable-m2ts-mux disable MPEG2 TS Multiplexer
--disable-dvb4linux disable dvb4linux support
--disable-parsers disable AV parsers
--disable-import disable media importers
--disable-export disable media exporters
--disable-swf disable SWF import
--disable-scene-stats disable scene graph statistics
--disable-scene-dump disable scene graph dump
--disable-scene-encode disable BIFS & LASeR to ISO File Format encoding
--disable-loader-isoff disable scene loading from ISO File Format
--disable-loader-bt disable scene loading from ISO File Format
--disable-loader-xmt disable scene loading from ISO File Format
--disable-od-dump disable OD dump
--disable-isom-dump disable ISOM dump
--disable-crypt disable crypto tools
--disable-isoff disable ISO File Format
--disable-isoff-write disable ISO File Format edit/write
--disable-isoff-hint disable ISO File Format hinting
--disable-isoff-frag disable fragments in ISO File Format
--disable-isoff-hds disable HDS support in ISO File Format
--disable-streaming disable RTP/RTSP/SDP
--disable-dvbx disable DVB-specific tools (MPE, FEC, DSM-CC)
--disable-vobsub disable VobSub support
--disable-sman disable scene manager
--disable-ttxt disable TTXT (3GPP / MPEG-4 Timed Text) support
--disable-player disable player (compositor)
--disable-scenegraph disable scenegraph, scene parsers and player (compositor)
--disable-hevc disable HEVC support
--disable-route disable ROUTE (ATSC3) support
--disable-crypto disable crypto support
--disable-nvdec disable NVDec support
--disable-codecs disable all media decoders and encoders
Extra libraries configuration. You can turn a library off or force using the local version in gpac/extra_lib/
--use-ft=OPT force FreeType OPT=[no,local]
--use-zlib=OPT force ZLIB OPT=[no,system,local]
--use-jpeg=OPT force JPEG OPT=[no,local]
--use-png=OPT force PNG OPT=[no,local]
--use-faad=OPT force FAAD OPT=[no,local]
--use-mad=OPT force MAD OPT=[no,local]
--use-xvid=OPT force XVID OPT=[no,local]
--use-ffmpeg=OPT force FFMPEG OPT=[no,local]
--use-ogg=OPT force OGG OPT=[no,system,local]
--use-vorbis=OPT force vorbis OPT=[no,system,local]
--use-theora=OPT force theora OPT=[no,system,local]
--use-openjpeg=OPT force openjpeg OPT=[no,system,local]
--use-a52=OPT force a52 (ac3) OPT=[no,system,local]
NOTE: The object files are built at the place where configure is launched
EOF
exit 1
fi
use_static="no"
for opt do
case "$opt" in
--prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
;;
--libdir=*) libdir=`echo $opt | cut -d '=' -f 2`
;;
--mandir=*) mandir=`echo $opt | cut -d '=' -f 2`
;;
--cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` && echo "cross-prefix detected: $cross_prefix"
;;
--target-os=*) targetos=`echo $opt | cut -d '=' -f 2` && echo "target-os detected: $targetos"
;;
--cc=*) cc_orig=`echo $opt | cut -d '=' -f 2`
;;
--cxx=*) cxx_orig=`echo $opt | cut -d '=' -f 2`
;;
--cpp=*) cxx_orig=`echo $opt | cut -d '=' -f 2`
;;
--make=*) make=`echo $opt | cut -d '=' -f 2`
;;
--extra-cflags=*) CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
;;
--extra-ldflags=*) LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
;;
--extra-ff-ldflags=*) ffmpeg_extra_ldflags=`echo $opt | cut -d '=' -f 2`
;;
--extra-libs=*) extralibs=${opt#--extra-libs=}
;;
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
;;
--enable-debug) debuginfo="yes"; no_gcc_opt="yes"
;;
--disable-opt) no_gcc_opt="yes"
;;
--enable-pic) want_pic="yes";
;;
--enable-gcov) want_gcov="yes";
;;
--enable-afl) cc_orig="afl-gcc"; cxx_orig="afl-g++"
;;
--enable-afl-clang) cc_orig="afl-clang"; cxx_orig="afl-clang++"
;;
--verbose) verbose="yes";
;;
--static-bin) use_static="yes"
;;
--static-mp4box) use_static="yes"
;;
--enable-sanitizer) enable_sanitizer="yes"
;;
esac
done
cc="${cc_orig}"
cxx="${cxx_orig}"
case "$cpu" in
i386|i486|i586|i686|i86pc|BePC)
cpu="x86"
;;
x86_64|amd64)
cpu="x86"
if [ "$linux" = "yes" -o "$darwin" = "yes" ] ; then
is_64="yes"
fi
case `uname -s` in
SunOS)
canon_arch=`isainfo -n`
;;
Darwin)
canon_arch="x86_64"
;;
*)
canon_arch="`$cc -dumpmachine | sed -e 's,\([^-]*\)-.*,\1,'`"
;;
esac
if [ x"$canon_arch" = x"x86_64" -o x"$canon_arch" = x"amd64" ]; then
if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
cpu="x86_64"
want_pic="yes"
is_64="yes"
fi
fi
;;
armv4l|arm)
cpu="armv4l"
;;
alpha)
cpu="alpha"
;;
ppc64)
cpu="powerpc"
;;
"Power Macintosh"|ppc)
cpu="powerpc"
;;
mips)
cpu="mips"
;;
sh4|sh4a|sh)
cpu="sh4"
;;
sun4u|sun4v)
cpu="sparc"
if [ -z "`echo $CFLAGS | grep -- -m32`" ]; then
is_64="yes"
PIC_CFLAGS="-fPIC -DPIC"
want_pic="yes"
fi
;;
*)
cpu="unknown"
;;
esac
#checking for CFLAGS
if test -z "$CFLAGS"; then
CFLAGS=""
fi
cc="${cross_prefix}${cc}"
#for ccache
cc="${cc}"
cxx="${cross_prefix}${cxx}"
ar="${cross_prefix}${ar}"
ranlib="${cross_prefix}${ranlib}"
strip="${cross_prefix}${strip}"
windres="${cross_prefix}${windres}"
if test "$enable_sanitizer" = "yes" ; then
if test "$use_static" = "yes" ; then
echo "Cannot use static bin with sanitizer, disabling static bin"
use_static="no"
fi
fi
if test "$use_static" = "yes" ; then
pkg_config="${pkg_config} --static"
if test "$darwin" != "yes" ; then
LDFLAGS="-static $LDFLAGS"
fi
else
pkg_config="${pkg_config}"
fi
#check pkg_config
if test "$cross_prefix" = "" ; then
if ! $pkg_config --version >/dev/null 2>>$logs ; then
pkg_config="no"
fi
fi
#find source path
source_path="`echo $0 | sed -e 's#/configure##'`"
source_path_used="yes"
if test -z "$source_path" -o "$source_path" = "." ; then
source_path="`pwd`"
source_path_used="no"
build_path=$source_path
else
source_path="`cd \"$source_path\"; pwd`"
build_path="`pwd`"
fi
#OS specific
if test "$targetos" = "" ; then
targetos=`uname -s`
fi
case $targetos in
BeOS)
prefix="/boot/home/config"
CFLAGS="$CFLAGS -DPIC -fomit-frame-pointer"
# 3 gcc releases known for BeOS, each with ugly bugs
gcc_version="$($cc -v 2>>$logs | grep version | cut -d ' ' -f3-)"
case "$gcc_version" in
2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
;;
*20010315*) echo "BeBits gcc"
CFLAGS="$CFLAGS -fno-expensive-optimizations"
;;
esac
SHFLAGS=-nostart
#no need for libm, but the inet stuff
#check for BONE
if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
extralibs="-lbind -lsocket"
else
need_inet_aton="yes"
extralibs="-lnet"
fi
;;
SunOS)
make="gmake"
readelf="greadelf"
LDFLAGS="$LDFLAGS"
instflags=""
#check for 64-bit
cat > $TMPC << EOF
#include <stdio.h>
int main( void ) { return 0; }
EOF
CFLAGS_NO_LTO=$(echo ${CFLAGS} | sed -e 's/\ -flto[-A-Za-z0-9=]*//g')
$cc ${CFLAGS_NO_LTO} -o $TMPO $TMPC 2>>$logs && $($readelf -h $TMPO | grep "Class:.*ELF64$" >/dev/null 2>>$logs)
if test $? -eq 0; then
is_64="yes"
fi
if test "$is_64" = "yes"; then
if test "$cpu" = "x86_64"; then
libdir=lib/amd64
elif test "$cpu" = "sparc"; then
libdir=lib/sparcv9
fi
fi
sunos="yes"
need_inet_aton="yes"
extralibs="$extralibs -lsocket -lnsl"
;;
FreeBSD)
make="gmake"
LDFLAGS="$LDFLAGS -export-dynamic"
CFLAGS="$CFLAGS -pthread"
GPAC_SH_FLAGS=-pthread
freebsd="yes"
;;
BSD/OS)
extralibs="-lpoll -lgnugetopt -lm"
make="gmake"
;;
Darwin)
CFLAGS_DIR="-I$prefix/include"
LDFLAGS="-L$prefix/$libdir"
if test -d /sw/bin ; then
alt_macosx_dir="/sw"
CFLAGS_DIR="-I/sw/include $CFLAGS_DIR"
LDFLAGS="-L/sw/lib $LDFLAGS"
elif test -d /opt/local/bin ; then
alt_macosx_dir="/opt/local"
CFLAGS_DIR="-I/opt/local/include $CFLAGS_DIR"
LDFLAGS="-L/opt/local/lib $LDFLAGS"
fi
Mac_Applications="/Applications"
SHFLAGS="-dynamiclib"
DYN_LIB_SUFFIX=".dylib"
extralibs=""
GPAC_SH_FLAGS=""
strip="strip -x"
if test "$is_64" = "yes" ; then
LDFLAGS="$LDFLAGS"
fi
darwin="yes"
gcc_version=`$cc -v 2>>$logs | grep version | cut -d ' ' -f3`
case "$gcc_version" in
*2.95*)
CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer"
;;
3.*)
CFLAGS="$CFLAGS -no-cpp-precomp -pipe -fomit-frame-pointer -mdynamic-no-pic -fno-common"
;;
4.*)
CFLAGS="$CFLAGS -pipe -fomit-frame-pointer -fno-common"
;;
esac
;;
MINGW32*|mingw32|MINGW64*|mingw64|msys*|MSYS*)
mingw32="yes"
win32="yes"
want_pic="no"
#ugly patch for msys2 mingw32/mingw64 where toolchain is not properly setup
if [ x"$MSYSTEM" = x"MSYS" ] && [ -e /mingw64 ]; then
extralibs="$extralibs -lws2_32 -lwinmm -limagehlp"
CFLAGS="$CFLAGS -I/mingw64/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
LDFLAGS="$LDFLAGS -L/mingw64/lib"
elif [ x"$MSYSTEM" = x"MSYS" ] && [ -e /mingw32 ]; then
extralibs="-L/mingw32/lib $extralibs -lws2_32 -lwinmm -limagehlp"
CFLAGS="$CFLAGS -I/mingw32/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
LDFLAGS="$LDFLAGS -L/mingw32/lib"
else
extralibs="$extralibs -lws2_32 -lwinmm -limagehlp -ldbghelp"
CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
fi
LDFLAGS="$LDFLAGS"
if test "$cross_prefix" != "" ; then
GPAC_SH_FLAGS=""
fi
;;
CYGWIN*|cygwin*)
extralibs="$extralibs -lws2_32 -lwinmm"
cygwin="yes"
win32="yes"
;;
Linux|linux|android)
LDFLAGS="$LDFLAGS -Wl,--warn-common -Wl,-z,defs"
linux="yes"
case "$cpu" in
sh4)
CFLAGS="$CFLAGS -isystem \"$prefix/include\""
;;
esac
cat > $TMPC << EOF
#include <sys/cdefs.h>
#if !defined (__BIONIC__)
#error
#endif
EOF
if $cc -c $CFLAGS $TMPC 0>/dev/null 2>$TMPL ; then
#bionic libc (android)
CFLAGS="$CFLAGS -DPTHREAD_HAS_NO_CANCEL"
GPAC_SH_FLAGS=""
fi
;;
*) ;;
esac
#defines directory for binaries and libs (ex. for TinyGL)
target_bin_dir=""
if test "$cross_prefix" = "" ; then
target_bin_dir=`${cc} -v 2>>$logs | sed -n '2p' | awk ' {print $2}'`-${cc_orig}
else
target_bin_dir=${cross_prefix}${cc_orig}
fi
#if test "$source_path_used" = "yes" ; then
mkdir -p extra_lib
mkdir -p extra_lib/lib
mkdir -p extra_lib/lib/gcc
#fi
#OK check for all local & systems lib
local_inc=$source_path/extra_lib/include
local_lib=$source_path/extra_lib/lib/gcc
execdir=$source_path/bin/gcc
dolog() {
rv=$?
if [ $rv -eq 0 ] ; then
return 0;
fi
echo "*** CC/CXX Test Failed (args $@) : ">>$logs
echo "">>$logs
cat $TMPL >> $logs
echo "">>$logs
echo "Source was: ">>$logs
cat $TMPC >> $logs
echo "">>$logs
echo "">>$logs
return 1;
}
docc() {
$cc -o $TMPO $TMPC $@ 0>/dev/null 2>$TMPL
dolog $@
}
docxx() {
$cc -o $TMPO $TMPCXX $@ 0>/dev/null 2>$TMPL
dolog $@
}
#check GCC flags support
cat > $TMPC << EOF
#include <stdio.h>
int main( void ) { return 0; }
EOF
CFLAGS="$CFLAGS -Wall"
if docc -fno-strict-aliasing ; then
CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
CXXFLAGS="$CFLAGS"
if docc -lz -Wno-pointer-sign ; then
CFLAGS="$CFLAGS -Wno-pointer-sign"
fi
if docc $CFLAGS -std=gnu99 ; then
CFLAGS="$CFLAGS -std=gnu99"
fi
#GCC opt
if test "$no_gcc_opt" = "no"; then
CFLAGS="-O3 $CFLAGS"
else
CFLAGS="-O0 $CFLAGS"
fi
#GCC PIC
if test "$cross_prefix" != "" ; then
want_pic="no"
fi
if test "$want_pic" = "yes" ; then
CFLAGS="$CFLAGS -fPIC -DPIC"
CXXFLAGS="$CXXFLAGS -fPIC -DPIC"
fi
if test "$want_gcov" = "yes" ; then
CFLAGS="$CFLAGS --coverage"
CXXFLAGS="$CXXFLAGS --coverage"
LDFLAGS="$LDFLAGS --coverage"
fi
#force use of cflags with cc
cc_naked=$cc
cxx_naked=$cxx
cc="$cc $CFLAGS"
cxx="$cxx $CXXFLAGS"
#look for zlib
cat > $TMPC << EOF
#include <emmintrin.h>
int main( void ) { return 0; }
EOF
if docc -msse2 $LDFLAGS ; then
CFLAGS="$CFLAGS -msse2"
fi
#look for zlib
cat > $TMPC << EOF
#include <string.h>
#include <stdio.h>
#include <zlib.h>
int main( void ) { if (strcmp(zlibVersion(), ZLIB_VERSION)) { puts("zlib version differs !!!"); return 1; } return 0; }
EOF
has_zlib="no"
if docc -lz $LDFLAGS ; then
has_zlib="system"
fi
if test "$has_zlib" = "no" ; then
if docc -I"$local_inc/zlib" -L$local_lib -lz ; then
has_zlib="local"
fi
fi
#check dlopen
cat > $TMPC << EOF
#include <dlfcn.h>
int main( void ) { dlopen("foo", 0); return 0; }
EOF
if docc ; then
dlopen="yes"
elif docc $LDFLAGS -ldl ; then
GPAC_SH_FLAGS="$GPAC_SH_FLAGS -ldl"
fi
#check st_mtim.tv_nsec
cat > $TMPC << EOF
#include <sys/stat.h>
int main( void ) { struct stat st; st.st_mtim.tv_nsec = 0; return 0; }
EOF
if docc ; then
has_st_nsec="yes"
fi
#look for platinum support
cat > $TMPCXX << EOF
#include <Platinum.h>
int main( void ) { return 0; }
EOF
if docxx -I$local_inc/platinum $LDFLAGS -L$local_lib -lPlatinum -lPltMediaServer -lPltMediaConnect -lPltMediaRenderer -lNeptune -lZlib -lpthread ; then
has_platinum="yes"
fi
#look for opensvc support
if test "$darwin" = "yes" ; then
osvc_cflags="-I/usr/include -I/usr/local/include"
osvc_ldflags="-L/usr/lib -L/usr/local/lib -lOpenSVCDec"
else
osvc_cflags=""
osvc_ldflags="-lOpenSVCDec"
fi
cat > $TMPC << EOF
#include <OpenSVCDecoder/SVCDecoder_ietr_api.h>
int main( void ) { return 0; }
EOF
if docc $osvc_cflags $LDFLAGS $osvc_ldflags ; then
has_opensvc="yes"
else
osvc_cflags="-idirafter $local_inc"
osvc_ldflags="-lOpenSVCDec"
if docc $osvc_cflags $LDFLAGS -L$local_lib $osvc_ldflags ; then
has_opensvc="yes"
osvc_ldflags="-L$local_lib $osvc_ldflags"
fi
fi
#look for openhevc support
if test "$darwin" = "yes" ; then
ohevc_cflags="-I/usr/include -I/usr/local/include"
ohevc_ldflags="-L/usr/lib -L/usr/local/lib -lopenhevc -lm -lpthread "
elif test "$cross_prefix" = "" ; then
ohevc_cflags="-I/usr/include -I/usr/local/include"
ohevc_ldflags="-L/usr/lib -L/usr/local/lib -lopenhevc -lm -lpthread"
else
ohevc_cflags="-I${prefix}include"
ohevc_ldflags="-lopenhevc -lm -lpthread"
fi
cat > $TMPC << EOF
#include <stdio.h>
#include <libopenhevc/openhevc.h>
int main( void ) { oh_init(1, 1); return 0; }
EOF
if docc $ohevc_cflags $ohevc_ldflags $LDFLAGS ; then
has_openhevc="yes"
else
ohevc_cflags="-I$local_inc"
ohevc_ldflags="-lopenhevc -lm -lpthread"
if docc $ohevc_cflags $ohevc_ldflags $LDFLAGS -L$local_lib ; then
has_openhevc="yes"
ohevc_ldflags="-L$local_lib $ohevc_ldflags"
elif docc $ohevc_cflags $ohevc_ldflags $LDFLAGS -L$execdir ; then
has_openhevc="yes"
ohevc_ldflags="-L$execdir $ohevc_ldflags"
fi
fi
#look for freetype support
cat > $TMPC << EOF
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_OUTLINE_H
int main( void ) { return 0; }
EOF
ft_cflags="-I$prefix/include "
ft_lflags="-L$prefix/$libdir -lfreetype"
if docc $CFLAGS_DIR $ft_cflags $ft_lflags $LDFLAGS ; then
has_ft="system"
fi
if test "$has_ft" = "no" ; then
ft_cflags="`$pkg_config --cflags freetype2 2>>$logs`"
ft_lflags="`$pkg_config --libs freetype2 2>>$logs`"
if docc $ft_cflags $ft_lflags $LDFLAGS ; then
has_ft="system"
fi
fi
if test "$has_ft" = "no" ; then
ft_cflags="-I$local_inc/freetype"
ft_lflags="-L$local_lib -lfreetype"
if docc $ft_cflags $ft_lflags $LDFLAGS ; then
has_ft="local"
fi
fi
#end freetype test
#look for OpenSSL support
cat > $TMPC << EOF
#include <openssl/ssl.h>
#include <openssl/x509.h>
#include <openssl/err.h>
#include <openssl/rand.h>
int main( void ) { return 0; }
EOF
if test "$mingw32" = "yes" ; then
LINK_SSL="-lssl -lcrypto"
elif test "$win32" = "yes" ; then
LINK_SSL="-lssleay32 -leay32"
else
LINK_SSL="-lssl -lcrypto"
fi
if docc $CFLAGS_DIR $LINK_SSL $LDFLAGS ; then
has_ssl="yes"
fi
#look for atomic.h
cat > $TMPC << EOF
#include <pthread.h>
#include <stdatomic.h>
int main( void ) { return 0; }
EOF
has_atomic="no"
if docc $CFLAGS_DIR $LDFLAGS ; then
has_atomic="yes"
else
CFLAGS="$CFLAGS -DGPAC_NO_STDATOMIC"
fi
cat > $TMPC << EOF
#include <stdint.h>
int main(void) {
int i4 = 4;
__int64_t i8 = 8;
__sync_add_and_fetch(&i4, 12);
__sync_add_and_fetch(&i8, 12);
}
EOF
has_builtinatomic="no"
if docc ; then
has_builtinatomic="yes"
else
cat > $TMPC << EOF
#include <stdint.h>
int main(void) {
int i4 = 4;
__int64_t i8 = 8;
__atomic_add_fetch(&i4, 12, __ATOMIC_SEQ_CST);
__atomic_add_fetch(&i8, 12, __ATOMIC_SEQ_CST);
}
EOF
if docc -latomic ; then
CFLAGS="$CFLAGS -DGPAC_NEED_LIBATOMIC"
LDFLAGS="$LDFLAGS -latomic"
fi
fi
#look for JPEG support
cat > $TMPC << EOF
#include <stdio.h>
#include <jpeglib.h>
int main( void ) { return 0; }
EOF