forked from coturn/coturn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·1256 lines (1081 loc) · 32.3 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 ${PQ_TMPCPROGC}
rm -rf ${PQ_TMPCPROGB}
rm -rf ${MYSQL_TMPCPROGC}
rm -rf ${MYSQL_TMPCPROGB}
rm -rf ${MONGO_TMPCPROGC}
rm -rf ${MONGO_TMPCPROGB}
rm -rf ${D_TMPCPROGC}
rm -rf ${D_TMPCPROGB}
rm -rf ${SQL_TMPCPROGC}
rm -rf ${SQL_TMPCPROGO}
rm -rf ${E_TMPCPROGC}
rm -rf ${E_TMPCPROGO}
rm -rf ${HR_TMPCPROGC}
rm -rf ${HR_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
}
testsqlite_comp() {
SQLITE_LIBS=-lsqlite3
${CC} -c ${SQL_TMPCPROGC} -o ${SQL_TMPCPROGO} ${OSCFLAGS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "SQLite development is not installed properly"
return 0
else
DBLIBS="${DBLIBS} ${SQLITE_LIBS}"
return 1
fi
}
testlibevent2_comp() {
${CC} -c ${E_TMPCPROGC} -o ${E_TMPCPROGO} ${OSCFLAGS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Libevent2 development is not installed properly"
return 0
else
return 1
fi
}
testhiredis() {
for inc in ${INCLUDEDIR}/hiredis /usr/local/include/hiredis /usr/hiredis /usr/include/hiredis
do
if [ -d ${inc} ] ; then
HIREDISCFLAGS="${HIREDISCFLAGS} -I${inc}"
fi
done
HIREDISLIBS=-lhiredis
${CC} ${HR_TMPCPROGC} -o ${HR_TMPCPROGB} ${OSCFLAGS} ${DBLIBS} ${HIREDISCFLAGS} ${HIREDISLIBS} ${OSLIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD}
${ECHO_CMD} "HIREDIS DEVELOPMENT LIBRARY (libhiredis.*) AND/OR HEADERS (hiredis/*.h)"
${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT REDIS SUPPORT."
${ECHO_CMD}
return 0
else
DBCFLAGS="${DBCFLAGS} ${HIREDISCFLAGS}"
DBLIBS="${DBLIBS} ${HIREDISLIBS}"
return 1
fi
}
testlibpq() {
POSTCFLAGS="-I${PREFIX}/pgsql/include -I${PREFIX}/include/pgsql/ -I${PREFIX}/include/postgres/ -I${PREFIX}/postgres/include/ -I${PREFIX}/include/postgresql/ -I${PREFIX}/postgresql/include/"
POSTCFLAGS="${POSTCFLAGS} -I/usr/local/pgsql/include -I/usr/local/include/pgsql/ -I/usr/local/include/postgres/ -I/usr/local/postgres/include/ -I/usr/local/include/postgresql/ -I/usr/local/postgresql/include/"
POSTCFLAGS="${POSTCFLAGS} -I/usr/pgsql/include -I/usr/include/pgsql/ -I/usr/include/postgres/ -I/usr/postgres/include/ -I/usr/include/postgresql/ -I/usr/postgresql/include/"
for ilib in ${PREFIX}/pgsql/lib ${PREFIX}/lib/pgsql ${PREFIX}/lib64/pgsql /usr/local/pgsql/lib /usr/local/lib/pgsql /usr/local/lib64/pgsql /usr/pgsql/lib /usr/lib/pgsql /usr/lib64/pgsql ${PREFIX}/postgres/lib ${PREFIX}/lib/postgres ${PREFIX}/lib64/postgres /usr/local/postgres/lib /usr/local/lib/postgres /usr/local/lib64/postgres /usr/postgres/lib /usr/lib/postgres /usr/lib64/postgres ${PREFIX}/postgresql/lib ${PREFIX}/lib/postgresql ${PREFIX}/lib64/postgresql /usr/local/postgresql/lib /usr/local/lib/postgresql /usr/local/lib64/postgresql /usr/postgresql/lib /usr/lib/postgresql /usr/lib64/postgresql
do
if [ -d ${ilib} ] ; then
POSTLIBS="${POSTLIBS} -L${ilib}"
if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
fi
fi
done
POSTLIBS="${OSLIBS} ${POSTLIBS} -lpq"
${CC} ${PQ_TMPCPROGC} -o ${PQ_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${POSTCFLAGS} ${DBLIBS} ${POSTLIBS} ${OSLIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD}
${ECHO_CMD} "POSTGRESQL DEVELOPMENT LIBRARY (libpq.a) AND/OR HEADER (libpq-fe.h)"
${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT POSTGRESQL DATABASE SUPPORT."
${ECHO_CMD}
return 0
else
DBCFLAGS="${DBCFLAGS} ${POSTCFLAGS}"
DBLIBS="${DBLIBS} ${POSTLIBS}"
return 1
fi
}
testlibmysql() {
MYSQL_CFLAGS="-I${PREFIX}/mysql/include -I${PREFIX}/include/mysql/"
MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/local/mysql/include -I/usr/local/include/mysql/"
MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/mysql/include -I/usr/include/mysql/"
for ilib in ${PREFIX}/mysql/lib ${PREFIX}/lib/mysql ${PREFIX}/lib64/mysql /usr/local/mysql/lib /usr/local/lib/mysql /usr/local/lib64/mysql /usr/mysql/lib /usr/lib/mysql /usr/lib64/mysql
do
if [ -d ${ilib} ] ; then
MYSQL_LIBS="${MYSQL_LIBS} -L${ilib}"
if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
fi
fi
done
MYSQL_LIBS="${OSLIBS} ${MYSQL_LIBS} -lmysqlclient"
${CC} ${MYSQL_TMPCPROGC} -o ${MYSQL_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${DBLIBS} ${MYSQL_CFLAGS} ${MYSQL_LIBS} ${OSLIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD}
${ECHO_CMD} "MYSQL DEVELOPMENT LIBRARY (libmysqlclient) AND/OR HEADER (mysql.h)"
${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MYSQL DATABASE SUPPORT."
${ECHO_CMD}
return 0
else
DBCFLAGS="${DBCFLAGS} ${MYSQL_CFLAGS}"
DBLIBS="${DBLIBS} ${MYSQL_LIBS}"
return 1
fi
}
testlibmongoc() {
for inc in ${INCLUDEDIR}/libmongoc-1.0 ${INCLUDEDIR}/libbson-1.0 /usr/local/include/libmongoc-1.0 /usr/local/include/libbson-1.0 /usr/libmongoc-1.0 /usr/libbson-1.0 /usr/include/libbson-1.0/ /usr/include/libmongoc-1.0/
do
if [ -d ${inc} ] ; then
MONGO_CFLAGS="${MONGO_CFLAGS} -I${inc}"
fi
done
MONGO_LIBS="-lmongoc-1.0 -lbson-1.0"
${CC} ${MONGO_TMPCPROGC} -o ${MONGO_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${DBLIBS} ${MONGO_CFLAGS} ${MONGO_LIBS} ${OSLIBS} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD}
${ECHO_CMD} "MONGODB DEVELOPMENT LIBRARIES (libmongoc-1.0 and libbson-1.0) AND/OR HEADER (mongoc.h)"
${ECHO_CMD} " ARE NOT INSTALLED PROPERLY ON THIS SYSTEM."
${ECHO_CMD} " THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MONGODB SUPPORT."
${ECHO_CMD}
return 0
else
DBCFLAGS="${DBCFLAGS} ${MONGO_CFLAGS}"
DBLIBS="${DBLIBS} ${MONGO_LIBS}"
return 1
fi
}
testlib() {
testlibraw l${1}
}
pthread_testlib() {
SYSTEM=`uname`
if [ "${SYSTEM}" = "DragonFly" ] ; then
OSLIBS="${OSLIBS} -pthread"
TURN_NO_SCTP=1
fi
ISBSD=`uname | grep -i bsd`
if ! [ -z "${ISBSD}" ] ; then
OSLIBS="${OSLIBS} -pthread"
fi
if [ -z "${PTHREAD_LIBS}" ] ; then
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
return 1
else
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -pthread 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
OSLIBS="${OSLIBS} -pthread"
return 1
else
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} -lpthread 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
OSLIBS="${OSLIBS} -lpthread"
return 1
fi
fi
fi
else
OSLIBS="${OSLIBS} ${PTHREAD_LIBS}"
fi
${CC} ${TH_TMPCPROGC} -o ${TH_TMPCPROGB} ${OSCFLAGS} ${OSLIBS} 2>>/dev/null
ER=$?
if [ ${ER} -eq 0 ] ; then
return 1
else
${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 1
else
${ECHO_CMD} "Do not use pthreads"
fi
fi
return 0
}
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="-I${INCLUDEDIR} -I${PREFIX}/include/ -I/usr/local/include ${CFLAGS}"
OSLIBS="${LDFLAGS}"
for ilib in ${PREFIX}/lib/event2/ ${PREFIX}/lib/ /usr/local/lib/event2/ /usr/local/lib/ ${PREFIX}/lib64/event2/ ${PREFIX}/lib64/ /usr/local/lib64/event2/ /usr/local/lib64/
do
if [ -d ${ilib} ] ; then
OSLIBS="${OSLIBS} -L${ilib}"
TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
fi
done
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
###########################
# 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"
INSTALL_MAN="install"
INSTALL_SCRIPT="install"
INSTALL_SHARED_LIB="install"
INSTALL_STATIC_LIB="install"
INSTALL_DATA="install"
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]);
}
!
E_TMPCPROG=__test__ccomp__libevent2__$$
E_TMPCPROGC=${TMPDIR}/${E_TMPCPROG}.c
E_TMPCPROGO=${TMPDIR}/${E_TMPCPROG}.o
cat > ${E_TMPCPROGC} <<!
#include <stdlib.h>
#include <event2/event.h>
int main(int argc, char** argv) {
return (int)(argv[argc][0]);
}
!
SQL_TMPCPROG=__test__ccomp__sqlite__$$
SQL_TMPCPROGC=${TMPDIR}/${SQL_TMPCPROG}.c
SQL_TMPCPROGO=${TMPDIR}/${SQL_TMPCPROG}.o
cat > ${SQL_TMPCPROGC} <<!
#include <stdlib.h>
#include <sqlite3.h>
int main(int argc, char** argv) {
return (int)(argv[argc][0]);
}
!
HR_TMPCPROG=__test__ccomp__hiredis__$$
HR_TMPCPROGC=${TMPDIR}/${HR_TMPCPROG}.c
HR_TMPCPROGB=${TMPDIR}/${HR_TMPCPROG}
cat > ${HR_TMPCPROGC} <<!
#include <stdlib.h>
#include <hiredis/hiredis.h>
#include <hiredis/async.h>
int main(int argc, char** argv) {
redisAsyncHandleRead(NULL);
return (int)(argv[argc][0]);
}
!
PQ_TMPCPROG=__test__ccomp__libpq__$$
PQ_TMPCPROGC=${TMPDIR}/${PQ_TMPCPROG}.c
PQ_TMPCPROGB=${TMPDIR}/${PQ_TMPCPROG}
cat > ${PQ_TMPCPROGC} <<!
#include <stdlib.h>
#include <libpq-fe.h>
int main(int argc, char** argv) {
return (argc+(PQprotocolVersion(NULL))+(int)(argv[0][0]));
}
!
MYSQL_TMPCPROG=__test__ccomp__libmysql__$$
MYSQL_TMPCPROGC=${TMPDIR}/${MYSQL_TMPCPROG}.c
MYSQL_TMPCPROGB=${TMPDIR}/${MYSQL_TMPCPROG}
cat > ${MYSQL_TMPCPROGC} <<!
#include <stdlib.h>
#include <mysql.h>
int main(int argc, char** argv) {
return (argc+
(int)(mysql_real_connect(NULL, NULL, NULL, NULL, NULL, 0, NULL, 0)!=0)+
(int)(argv[0][0]));
}
!
MONGO_TMPCPROG=__test__ccomp__libmongoc__$$
MONGO_TMPCPROGC=${TMPDIR}/${MONGO_TMPCPROG}.c
MONGO_TMPCPROGB=${TMPDIR}/${MONGO_TMPCPROG}
cat > ${MONGO_TMPCPROGC} <<!
#include <mongoc.h>
int main(int argc, char** argv) {
return (argc+
(int)(mongoc_client_new("mongodb://localhost:27017")!=0)+
(int)(argv[0][0]));
}
!
##########################
# What is our compiler ?
##########################
if [ -z "${CC}" ] ; then
CC=cc
${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
CC=gcc
${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
CC=clang
${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
CC=unknown
fi
fi
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
${CC} ${TMPCPROGC} ${OSCFLAGS} -o ${TMPCPROGB} 2>>/dev/null
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "ERROR: cannot use compiler ${CC} properly"
cleanup
exit
fi
###########################
# 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 intl
testlib nsl
testlib resolv
###########################
# Test sockets compilation
###########################
test_sin_len
###########################
# Can we use multi-threading ?
###########################
pthread_testlib
ER=$?
if [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "ERROR: Cannot find pthread library functions."
exit
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
###########################
testlib crypto
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Crypto SSL lib found."
else
${ECHO_CMD} "ERROR: OpenSSL Crypto development libraries are not installed properly in required location."
${ECHO_CMD} "Abort."
cleanup
exit
fi
testlib ssl
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "SSL lib found."
else
${ECHO_CMD} "ERROR: OpenSSL development libraries are not installed properly in required location."
${ECHO_CMD} "Abort."
cleanup
exit
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
###########################
testlibevent2_comp
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Libevent2 development 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 INSTALL file."
${ECHO_CMD} "Abort."
cleanup
exit
fi
testlib event_core
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Libevent2 runtime found."
testlib event_extra
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Libevent2 runtime 'extra' found."
else
${ECHO_CMD} "ERROR: Libevent2 'extra' runtime library is not installed properly in required location."
${ECHO_CMD} "See the INSTALL file."
${ECHO_CMD} "Abort."
cleanup
exit
fi
else
testlib event
ER=$?
if ! [ ${ER} -eq 0 ] ; then
${ECHO_CMD} "Libevent2 runtime found (old style)."
else
${ECHO_CMD} "ERROR: Libevent2 runtime libraries are not installed properly in required location."
${ECHO_CMD} "See the INSTALL file."
${ECHO_CMD} "Abort."
cleanup
exit
fi
fi
if [ -z "${TURN_NO_TLS}" ] ; then
testlib event_openssl