forked from coturn/coturn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1110 lines (953 loc) · 28.5 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
# Proprietary configure script of Coturn project
cleanup() {
rm -rf ${TMPCPROGC}
rm -rf ${TMPCPROGB}
rm -rf ${TH_TMPCPROGC}
rm -rf ${TH_TMPCPROGB}
rm -rf ${GCM_TMPCPROGC}
rm -rf ${GCM_TMPCPROGB}
rm -rf ${D_TMPCPROGC}
rm -rf ${D_TMPCPROGB}
rm -rf ${TMPCADDRPROGO}
}
testlibraw() {
${CC} ${TMPCPROGC} -o ${TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -${1} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Library option -${1} cannot be used"
return 0
else
OSLIBS="${OSLIBS} -${1}"
return 1
fi
}
# testpkg pkg1 pkg2 ...
# If all libraries are found, sets PKG_CFLAGS/PKG_LIBS and returns success.
# Otherwise, returns failure.
testpkg() {
PKG_LIBS="$($PKGCONFIG --libs "$@" 2>/dev/null)"
if [ $? -ne 0 ] ; then
return 1
fi
PKG_CFLAGS="$($PKGCONFIG --cflags "$@")"
}
# testpkg_db pkg1 pkg2 ...
# If all libraries are found, adds them to DBCFLAGS/DBLIBS and returns success.
# Otherwise, returns failure.
testpkg_db() {
testpkg "$@" || return $?
DBCFLAGS="${DBCFLAGS} ${PKG_CFLAGS}"
DBLIBS="${DBLIBS} ${PKG_LIBS}"
}
# support for older mysql version
# if mysql_config is found in path adds librairies to DBCFLAGS/DBLIBS and returns success.
# Otherwise, returns failure.
test_mysql_config() {
which mysql_config &>/dev/null || return $?
DBCFLAGS="${DBCFLAGS} $(mysql_config --cflags)"
DBLIBS="${DBLIBS} $(mysql_config --libs)"
}
# testpkg_common pkg1 pkg2 ...
# If all libraries are found, adds them to OSCFLAGS/OSLIBS and returns success.
# Otherwise, returns failure.
testpkg_common() {
testpkg "$@" || return $?
OSCFLAGS="${OSCFLAGS} ${PKG_CFLAGS}"
OSLIBS="${OSLIBS} ${PKG_LIBS}"
}
testlib() {
testlibraw l${1}
}
pthread_testlib() {
if [ -n "${PTHREAD_LIBS}" ] ; then
OSLIBS="${OSLIBS} ${PTHREAD_LIBS}"
return
fi
if [ "$(uname)" = "DragonFly" ] ; then
OSLIBS="${OSLIBS} -pthread"
TURN_NO_SCTP=1
return
fi
if [ -n "$(uname | grep -i bsd)" ] ; then
OSLIBS="${OSLIBS} -pthread"
return
fi
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
return
fi
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -pthread 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
OSLIBS="${OSLIBS} -pthread"
return
fi
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -lpthread 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
OSLIBS="${OSLIBS} -lpthread"
return
fi
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
return
fi
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -D_GNU_SOURCE 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Older GNU pthread library found"
OSCFLAGS="${OSCFLAGS} -D_GNU_SOURCE"
return
fi
${ECHO_CMD} "Do not use pthreads"
return 1
}
pthread_testbarriers() {
${ECHO_CMD} "pthread_barrier_t barrier;" >> ${TH_TMPCPROGC}
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "pthread barriers not found"
OSCFLAGS="${OSCFLAGS} -DTURN_NO_THREAD_BARRIERS"
fi
}
gcm_testlib() {
if [ -z "${TURN_NO_GCM}" ] ; then
${CC} ${GCM_TMPCPROGC} -o ${GCM_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
return 1
else
return 0
fi
else
return 0
fi
}
testdaemon() {
${CC} ${D_TMPCPROGC} -o ${D_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
OSCFLAGS="${OSCFLAGS} -DTURN_HAS_DAEMON"
fi
}
test_sin_len() {
TMPCADDRPROGC=src/client/ns_turn_ioaddr.c
${CC} -c ${OSCFLAGS} -DTURN_HAS_SIN_LEN -Isrc ${TMPCADDRPROGC} -o ${TMPCADDRPROGO} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
OSCFLAGS="${OSCFLAGS} -DTURN_HAS_SIN_LEN"
${ECHO_CMD} "Sockets code is fine: sin_len field present"
else
${CC} -c ${OSCFLAGS} -Isrc ${TMPCADDRPROGC} -o ${TMPCADDRPROGO} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Sockets code is fine: no sin_len field present"
else
${ECHO_CMD} "WARNING: trial compilation failed: src/client/ns_turn_ioaddr.c"
fi
fi
}
#########################
# Start
#########################
cleanup
#########################
# To be set:
#########################
if [ -z "${ECHO_CMD}" ] ; then
ECHO_CMD=echo
fi
if [ -z "${FIND_CMD}" ] ; then
FIND_CMD=find
fi
if [ -z "${PORTNAME}" ] ; then
PORTNAME=turnserver
fi
#########################
# Installation directory options
ac_prev=
ac_dashdash=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*=) ac_optarg= ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=BINDIR ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
BINDIR=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated | --localstate | --localstat)
ac_prev=LOCALSTATEDIR ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* | --localstate=* | --localstat=*)
LOCALSTATEDIR=$ac_optarg ;;
-turndbdir | --turndbdir | --turndbdi | --turndbd | --turndb | --turnd)
ac_prev=TURNDBDIR ;;
-turndbdir=* | --turndbdir=* | --turndbdi=* | --turndbd=* | --turndb=* | --turnd=*)
TURNDBDIR=$ac_optarg ;;
-datadir | --datadir | --datadi | --datad | -schemadir | --schemadir)
ac_prev=SCHEMADIR ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | -schemadir=* | --schemadir=*)
SCHEMADIR=$ac_optarg ;;
-docdir | --docdir | --docdi | --doc | --do | -docsdir | --docsdir | --docsdi | --docs)
ac_prev=DOCDIR ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=* | -docsdir=* | --docsdir=* | --docsdi=* | --docs=*)
DOCSDIR=$ac_optarg ;;
-examplesdir | --examplesdir | -examples | --examples)
ac_prev=EXAMPLESDIR ;;
-examplesdir=* | --examplesdir=* | -examples=* | --examples=*)
EXAMPLESDIR=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=INCLUDEDIR ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
INCLUDEDIR=$ac_optarg ;;
-turnincludedir | --turnincludedir)
ac_prev=TURNINCLUDEDIR ;;
-turnincludedir=* | --turnincludedir=*)
TURNINCLUDEDIR=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=LIBDIR ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
LIBDIR=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m | -manprefix | --manprefix)
ac_prev=MAXPREFIX ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=* | -manprefix=* | --manprefix=*)
MANPREFIX=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=PREFIX ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
PREFIX=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy | -confdir | --confdir)
ac_prev=CONFDIR ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=* | -confdir=* | --confdir=*)
CONFDIR=$ac_optarg ;;
-disable-rpath | --disable-rpath)
TURN_DISABLE_RPATH=1 ;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
as_fn_error $? "missing argument to $ac_option"
fi
#############################################
if [ -z "${PREFIX}" ] ; then
if [ -z "${prefix}" ] ; then
SYSTEM=`uname`
if [ "${SYSTEM}" = "NetBSD" ] ; then
# A little tough guy
PREFIX=/usr/pkg
elif [ "${SYSTEM}" = "SunOS" ] ; then
# A fat guy
PREFIX=/usr
else
# An ordinary person
PREFIX=/usr/local
fi
else
PREFIX=${prefix}
fi
fi
if [ -z "${BINDIR}" ] ; then
if [ -z "${bindir}" ] ; then
BINDIR=${PREFIX}/bin
else
BINDIR=${bindir}
fi
fi
if [ -z "${LOCALSTATEDIR}" ] ; then
if [ -z "${localstatedir}" ] ; then
if [ "${PREFIX}" = "/usr" ] ; then
LOCALSTATEDIR=/var
else
LOCALSTATEDIR=${PREFIX}/var
fi
else
LOCALSTATEDIR=${localstatedir}
fi
fi
if [ -z "${CONFDIR}" ] ; then
if [ -z "${confdir}" ] ; then
CONFDIR=${PREFIX}/etc
else
CONFDIR=${confdir}
fi
fi
if [ -z "${MANPREFIX}" ] ; then
if [ -z "${manprefix}" ] ; then
MANPREFIX=${PREFIX}
else
MANPREFIX=${manprefix}
fi
fi
if [ -z "${EXAMPLESDIR}" ] ; then
if [ -z "${examplesdir}" ] ; then
EXAMPLESDIR=${PREFIX}/share/examples/${PORTNAME}
else
EXAMPLESDIR=${examplesdir}
fi
fi
if [ -z "${DOCSDIR}" ] ; then
if [ -z "${docsdir}" ] ; then
DOCSDIR=${PREFIX}/share/doc/${PORTNAME}
else
DOCSDIR=${docsdir}
fi
fi
if [ -z "${LIBDIR}" ] ; then
if [ -z "${libdir}" ] ; then
LIBDIR=${PREFIX}/lib
else
LIBDIR=${libdir}
fi
fi
if [ -z "${SCHEMADIR}" ] ; then
if [ -z "${schemadir}" ] ; then
SCHEMADIR=${PREFIX}/share/${PORTNAME}
else
SCHEMADIR=${schemadir}
fi
fi
if [ -z "${INCLUDEDIR}" ] ; then
if [ -z "${includedir}" ] ; then
INCLUDEDIR=${PREFIX}/include
else
INCLUDEDIR=${includedir}
fi
fi
if [ -z "${TURNINCLUDEDIR}" ] ; then
if [ -z "${turnincludedir}" ] ; then
TURNINCLUDEDIR=${INCLUDEDIR}/turn
else
TURNINCLUDEDIR=${turnincludedir}
fi
fi
###############################################
if [ -z "${ARCHIVERCMD}" ] ; then
ARCHIVERCMD="ar -r"
fi
if [ -z "${MORECMD}" ]; then
MORECMD="cat"
fi
OSCFLAGS="${CFLAGS}"
OSLIBS="${LDFLAGS}"
SYSTEM=`uname`
if [ "${SYSTEM}" = "NetBSD" ] ; then
OSCFLAGS="${OSCFLAGS} -I/usr/pkg/include"
OSLIBS="-L/usr/pkg/lib ${OSLIBS}"
if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
TURN_RPATH="${TURN_RPATH} -Wl,-rpath,/usr/pkg/lib"
fi
fi
# If acme_redirect does not work, send_data_from_ioa_socket_nbh() probably
# does not work. Set LIBEV_OK=1 to use a workaround for it.
if [ -z "${LIBEV_OK}" ]; then
LIBEV_OK=1
if [ "${SYSTEM}" = "Linux" ]; then
OS=$( lsb_release -si 2>/dev/null )
[ "${OS}" = "Ubuntu" ] && LIBEV_OK=0
fi
fi
[ "${LIBEV_OK}" = "1" ] && OSCFLAGS="${OSCFLAGS} -DLIBEV_OK"
###########################
# Install shell commands
###########################
type ginstall 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
INSTALL_PROGRAM="ginstall"
INSTALL_MAN="ginstall"
INSTALL_SCRIPT="ginstall"
INSTALL_SHARED_LIB="ginstall"
INSTALL_STATIC_LIB="ginstall"
INSTALL_DATA="ginstall"
MKDIR="ginstall -d"
else
type install 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
INSTALL_PROGRAM="install -p"
INSTALL_MAN="install -p -m 0644"
INSTALL_SCRIPT="install -p"
INSTALL_SHARED_LIB="install -p"
INSTALL_STATIC_LIB="install -p"
INSTALL_DATA="install -p -m 0644"
MKDIR="install -d"
else
INSTALL_PROGRAM="cp -pf"
INSTALL_MAN="cp -pf"
INSTALL_SCRIPT="cp -pf"
INSTALL_SHARED_LIB="cp -pf"
INSTALL_STATIC_LIB="cp -pf"
INSTALL_DATA="cp -pf"
MKDIR="mkdir -p"
fi
fi
type pkill 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
PKILL_PROGRAM="pkill"
else
PKILL_PROGRAM="${ECHO_CMD}"
fi
INSTALL_DIR="cp -rpf"
MKBUILDDIR="mkdir -p"
RMCMD="rm -rf"
type sqlite3 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
SQLITE_CMD="sqlite3"
else
type sqlite 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
SQLITE_CMD="sqlite"
else
SQLITE_CMD=${ECHO_CMD}
fi
fi
#############################
# Adjustments for Solaris
#############################
SYSTEM=`uname`
if [ "${SYSTEM}" = "SunOS" ] ; then
# Solaris ? is this you ?!
OSCFLAGS="${OSCFLAGS} -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 -DTURN_NO_GETDOMAINNAME"
OSLIBS="${OSLIBS} -lnsl"
TURN_NO_SCTP=1
fi
#########################
# Temporary DIR location:
#########################
TMPDIR="."
if [ -d /var/tmp ] ; then
TMPDIR="/var/tmp"
elif [ -d /tmp ] ; then
TMPDIR=/tmp
fi
${ECHO_CMD} Use TMP dir ${TMPDIR}
#########################
# Basic C test programs
#########################
TMPCADDRPROGO=${TMPDIR}/__test__ccomp_addr_$$.o
TMPCPROG=__test__ccomp__$$
TMPCPROGC=${TMPDIR}/${TMPCPROG}.c
TMPCPROGB=${TMPDIR}/${TMPCPROG}
cat > ${TMPCPROGC} <<!
#include <stdlib.h>
int main(int argc, char** argv) {
return (int)(argv[argc][0]);
}
!
TH_TMPCPROG=__test__ccomp__pthread__$$
TH_TMPCPROGC=${TMPDIR}/${TH_TMPCPROG}.c
TH_TMPCPROGB=${TMPDIR}/${TH_TMPCPROG}
cat > ${TH_TMPCPROGC} <<!
#include <stdlib.h>
#include <pthread.h>
int main(int argc, char** argv) {
pthread_mutexattr_settype(0,PTHREAD_MUTEX_RECURSIVE);
return (int)pthread_create(0,0,0,0)+(int)(argv[argc][0]);
}
!
GCM_TMPCPROG=__test__ccomp__gcm__$$
GCM_TMPCPROGC=${TMPDIR}/${GCM_TMPCPROG}.c
GCM_TMPCPROGB=${TMPDIR}/${GCM_TMPCPROG}
cat > ${GCM_TMPCPROGC} <<!
#include <stdlib.h>
#include <openssl/ssl.h>
#include <openssl/evp.h>
int main(int argc, char** argv) {
return (int)EVP_CIPH_GCM_MODE;
}
!
D_TMPCPROG=__test__ccomp__daemon__$$
D_TMPCPROGC=${TMPDIR}/${D_TMPCPROG}.c
D_TMPCPROGB=${TMPDIR}/${D_TMPCPROG}
cat > ${D_TMPCPROGC} <<!
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char** argv) {
return (int)daemon(0,0)+(int)(argv[argc][0]);
}
!
##########################
# What is our compiler ?
##########################
if [ -z "${CC}" ] ; then
for CC in cc gcc clang; do
${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
break
fi
CC=
done
if [ -z "$CC" ] ; then
${ECHO_CMD} "ERROR: failed to a find working C compiler"
cleanup
exit 1
fi
else
CC_OUTPUT=$(${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB})
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "ERROR: cannot use compiler ${CC} properly."
${ECHO_CMD} "${CC_OUTPUT}"
cleanup
exit 1
fi
fi
${ECHO_CMD} "Compiler: ${CC}"
if [ -z "${TURN_ACCEPT_RPATH}" ] ; then
${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} -Wl,-rpath,/usr/lib 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
TURN_ACCEPT_RPATH=1
fi
fi
##########################
# Which pkg-config?
##########################
if [ -z "$PKGCONFIG" ] ; then
for PKGCONFIG in pkgconf pkg-config ; do
if type "$PKGCONFIG" 2>/dev/null ; then
break
fi
PKGCONFIG=
done
if [ -z "$PKGCONFIG" ] ; then
${ECHO_CMD} "ERROR: pkg-config not found"
cleanup
exit 1
fi
else
if ! type "$PKGCONFIG" 2>/dev/null ; then
${ECHO_CMD} "ERROR: cannot use $PKGCONFIG"
cleanup
exit 1
fi
fi
${ECHO_CMD} "pkg-config: $PKGCONFIG"
###########################
# Check if we can use GNU
# or Clang compiler flags
###########################
GNUOSCFLAGS="-g ${GNUOSCFLAGS}"
GNUOSCFLAGS="${GNUOSCFLAGS} -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual"
GNUOSCFLAGS="${GNUOSCFLAGS}"
${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Hm..."
${CC} -Wall ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Not an ordinary GNU or Clang compiler"
else
${ECHO_CMD} "g++ or something..."
GNUOSCFLAGS="-g -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wpointer-arith -Wcast-qual"
${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Not an ordinary g++ compiler"
GNUOSCFLAGS="-x c++ -g -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wpointer-arith -Wcast-qual"
${CC} -Werror ${GNUOSCFLAGS} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Not an ordinary c++ compiler"
else
${ECHO_CMD} "Clang++ compiler ?"
OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
fi
else
OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
fi
fi
else
OSCFLAGS="${GNUOSCFLAGS} ${OSCFLAGS}"
fi
###########################
# Test some general-purpose
# libraries
###########################
testlib socket
testlib rt
testlib wldap32
ER=$?
if ! [ ${ER} -eq 0 ] ; then
echo "CYGWIN ?"
fi
testlib wldap64
testlib nsl
testlib resolv
###########################
# Test sockets compilation
###########################
test_sin_len
###########################
# Can we use multi-threading ?
###########################
pthread_testlib
ER=$?
if [ ${ER} -ne 0 ] ; then
${ECHO_CMD} "ERROR: Cannot find pthread library functions."
exit 1
fi
if [ -z ${TURN_NO_THREAD_BARRIERS} ] ; then
pthread_testbarriers
else
TURN_NO_THREAD_BARRIERS="-DTURN_NO_THREAD_BARRIERS"
fi
if [ -z ${TURN_IP_RECVERR} ] ; then
${ECHO_CMD} "Ignore IP_RECVERR"
else
${ECHO_CMD} "Use IP_RECVERR"
TURN_IP_RECVERR="-DTURN_IP_RECVERR"
OSCFLAGS="${OSCFLAGS} ${TURN_IP_RECVERR}"
fi
###########################
# Can we use daemon ?
###########################
testdaemon
###########################
# Test OpenSSL installation
###########################
if [ -n "${SSL_CFLAGS}" ] && [ -n "${SSL_LIBS}" ]; then
${CC} ${TMPCPROGC} ${SSL_CFLAGS} -o ${TMPCPROGB} ${OSCFLAGS} ${OSLIBS} ${SSL_LIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Private SSL Library option cannot be used"
exit 1
else
OSCFLAGS="${OSCFLAGS} ${SSL_CFLAGS}"
OSLIBS="${OSLIBS} ${SSL_LIBS}"
fi
else
if testpkg_common libcrypto; then
${ECHO_CMD} "OpenSSL Crypto lib found."
else
testlib crypto
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "OpenSSL Crypto lib found."
else
${ECHO_CMD} "ERROR: OpenSSL Crypto development libraries are not installed properly in required location."
${ECHO_CMD} "Abort."
cleanup
exit 1
fi
fi
if testpkg_common libssl; then
${ECHO_CMD} "OpenSSL lib found."
else
testlib ssl
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "OpenSSL lib found."
else
${ECHO_CMD} "ERROR: OpenSSL development libraries are not installed properly in required location."
${ECHO_CMD} "Abort."
cleanup
exit 1
fi
fi
fi
###########################
# Can we use GCM cipher ?
###########################
if [ -z ${TURN_NO_GCM} ] ; then
gcm_testlib
ER=$?
if [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "WARNING: Cannot find GCM support."
${ECHO_CMD} "Turning GCM off."
TURN_NO_GCM="-DTURN_NO_GCM"
fi
else
TURN_NO_GCM="-DTURN_NO_GCM"
fi
###########################
# Test Libevent2 setup
###########################
if [ -n "${EVENT_CFLAGS}" ] && [ -n "${EVENT_LIBS}" ]; then
${CC} ${TMPCPROGC} ${EVENT_CFLAGS} -o ${TMPCPROGB} ${OSCFLAGS} ${OSLIBS} ${EVENT_LIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Private Event Library option cannot be used"
exit 1
else
OSCFLAGS="${OSCFLAGS} ${EVENT_CFLAGS}"
OSLIBS="${OSLIBS} ${EVENT_LIBS}"
fi
else
if testpkg_common libevent_core libevent_extra libevent_openssl libevent_pthreads || testpkg_common libevent libevent_openssl libevent_pthreads; then
${ECHO_CMD} "Libevent2 runtime found."
else
${ECHO_CMD} "ERROR: Libevent2 development libraries are not installed properly in required location."
${ECHO_CMD} "ERROR: may be you have just too old libevent tool - then you have to upgrade it."
${ECHO_CMD} "See the docs/Build.md file."
${ECHO_CMD} "Abort."
cleanup
exit 1
fi
fi
###########################
# Test Prometheus
###########################
if [ -z "${TURN_NO_PROMETHEUS}" ] ; then
testlib prom
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Prometheus lib found."
testlib promhttp
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Prometheus http lib found."
testlib microhttpd
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Microhttpd lib found."
# Adjustments for Debian
# See: https://github.com/coturn/coturn/pull/754#issuecomment-824693226
if [ -f "/etc/debian_version" ] ; then
OSLIBS="${OSLIBS} -latomic"
fi
else
${ECHO_CMD}
${ECHO_CMD} "Warning: microhttpd development libraries are not installed properly in required location."
${ECHO_CMD} "Prometheus support will be disabled."
${ECHO_CMD} "See the docs/Prometheus.md file."
${ECHO_CMD}
OSCFLAGS="${OSCFLAGS} -DTURN_NO_PROMETHEUS"
fi
else
${ECHO_CMD}
${ECHO_CMD} "Warning: Libpromhttp development libraries are not installed properly in required location."
${ECHO_CMD} "Prometheus support will be disabled."
${ECHO_CMD} "See the docs/Prometheus.md file."
${ECHO_CMD}
OSCFLAGS="${OSCFLAGS} -DTURN_NO_PROMETHEUS"
fi
else
${ECHO_CMD}
${ECHO_CMD} "Warning: Libprom development libraries are not installed properly in required location."
${ECHO_CMD} "Prometheus support will be disabled."
${ECHO_CMD} "See the docs/Prometheus.md file."
${ECHO_CMD}
OSCFLAGS="${OSCFLAGS} -DTURN_NO_PROMETHEUS"
fi
else
OSCFLAGS="${OSCFLAGS} -DTURN_NO_PROMETHEUS"
fi
###########################
# Test libsystemd
###########################
if [ -z "${TURN_NO_SYSTEMD}" ] ; then
if testpkg_common libsystemd; then
${ECHO_CMD} "Systemd library found."
else
${ECHO_CMD} "Systemd library not found. Building without systemd support."
TURN_NO_SYSTEMD="-DTURN_NO_SYSTEMD"
fi
else
TURN_NO_SYSTEMD="-DTURN_NO_SYSTEMD"
fi
###########################
# Test SQLite3 setup
###########################
if [ -z "${TURN_NO_SQLITE}" ] ; then
if testpkg_db sqlite3; then
${ECHO_CMD} "SQLite3 library found."
else
${ECHO_CMD} "SQLite3 development library not found. Building without SQLite3 support."
TURN_NO_SQLITE="-DTURN_NO_SQLITE"
fi
else
TURN_NO_SQLITE="-DTURN_NO_SQLITE"
SQLITE_CMD=${ECHO_CMD}
fi
if [ -z "${TURNDBDIR}" ] ; then
TURNDBDIR=${LOCALSTATEDIR}/db
fi
###########################
# Test PostgreSQL
###########################
if [ -z "${TURN_NO_PQ}" ] ; then
if testpkg_db libpq; then
${ECHO_CMD} "PostgreSQL found."
else
${ECHO_CMD} "PostgreSQL not found. Building without PostgreSQL support."
TURN_NO_PQ="-DTURN_NO_PQ"
fi
else
TURN_NO_PQ="-DTURN_NO_PQ"
fi
###########################
# Test MySQL
###########################
if [ -z "${TURN_NO_MYSQL}" ] ; then
if testpkg_db libmariadb || testpkg_db mariadb || testpkg_db mysqlclient || test_mysql_config; then
${ECHO_CMD} "MySQL found."
else
${ECHO_CMD} "MySQL not found. Building without MySQL support."
TURN_NO_MYSQL="-DTURN_NO_MYSQL"
fi
else
TURN_NO_MYSQL="-DTURN_NO_MYSQL"
fi
###########################
# Test MongoDB
###########################
if [ -z "${TURN_NO_MONGO}" ] ; then
if testpkg_db libmongoc-1.0; then
${ECHO_CMD} "MongoDB found."
else
${ECHO_CMD} "MongoDB not found. Building without MongoDB support."
TURN_NO_MONGO="-DTURN_NO_MONGO"
fi
else
TURN_NO_MONGO="-DTURN_NO_MONGO"
fi
###########################
# Test Redis
###########################
if [ -z "${TURN_NO_HIREDIS}" ] ; then
if testpkg_db hiredis; then
${ECHO_CMD} "Hiredis found."
else
${ECHO_CMD} "Hiredis not found. Building without hiredis support."
TURN_NO_HIREDIS="-DTURN_NO_HIREDIS"
fi
else
TURN_NO_HIREDIS="-DTURN_NO_HIREDIS"
fi
###############################
# LDCONFIG
###############################
if [ -z "${LDCONFIG}" ] ; then
ISBSD=`uname | grep -i bsd`
if [ -z "${ISBSD}" ] ; then
ISLINUX=`uname | grep -i linux`
if [ -z "${ISLINUX}" ] ; then
SYSTEM=`uname`
if [ "${SYSTEM}" = "SunOS" ] ; then
LDCONFIG="crle -u -l"
else