-
Notifications
You must be signed in to change notification settings - Fork 107
/
configure.ac
3244 lines (2736 loc) · 106 KB
/
configure.ac
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
# configure.ac -- Process this file with autoconf to produce configure
#
# An autoconf script to automatically configure ULib.
#
# Process this file with autoconf to produce a configure script.
#
# The autoconf documentation states that this is the recommended sequence for this file:
#
# AC_INIT
#
# 1. checks for programs
# 2. checks for libraries
# 3. checks for header files
# 4. checks for typedefs
# 5. checks for structures
# 6. checks for compiler characteristics
# 7. checks for library functions
# 8. checks for system services
#
# Read the Autoconf manual for details
# SECTION 1: AC_INIT
#
# This macro must be the very first invoked
AC_PREREQ([2.69])
AC_INIT([ULib],[2.4.2],[[email protected]],[ULib],[http://stefanocasazza.github.io/ULib/])
AC_CONFIG_SRCDIR([src/ulib/string.cpp])
AC_CONFIG_MACRO_DIR([m4])
# Define a msg macro
define(TWOCAN_CONF_MSG,[
AC_MSG_RESULT()
AC_MSG_RESULT(${T_MD}$1:${T_ME})
])
# Scary shtool stuff... borowed from pth-1.0
if test ".`echo dummy $@ | grep help`" = .; then
ac_shtool="$srcdir/shtool"
PLATFORM=`$ac_shtool platform`
T_MD="`$ac_shtool echo -n -e %B 2>/dev/null`"
T_ME="`$ac_shtool echo -n -e %b 2>/dev/null`"
echo "Platform: ${T_MD}${PLATFORM}${T_ME}"
echo "Configuring ${T_MD}ULib${T_ME} (C++ Library)"
fi
TWOCAN_CONF_MSG(Initial phase)
AC_CANONICAL_TARGET
# Pick a newer and better tar implementation like tar-pax
AM_INIT_AUTOMAKE([subdir-objects no-define tar-pax])
AM_MAINTAINER_MODE
AM_SILENT_RULES([yes])
AC_USE_SYSTEM_EXTENSIONS
dnl This is a C++ library after all
AC_LANG([C++])
template=
AC_MSG_CHECKING([which template to use])
case $host_os in
linux*|gnu*|k*bsd*-gnu)
template=linux ;;
mingw*) template=win32 ;;
cygwin*) template=cygwin ;;
darwin*) template=darwin ;;
freebsd*) template=freebsd ;;
# openbsd*) template=openbsd ;;
# netbsd*) template=netbsd ;;
#dragonfly*) template=netbsd ;;
# aix*) template=aix ;;
# hpux*) template=hpux ;;
# sco*) template=sco ;;
# solaris*) template=solaris ;;
# sysv5*) template=unixware ;;
esac
if test x"$template" = x"" ; then
AC_MSG_ERROR([[
***************************************************************************
ULib has apparently not been ported to your platform yet. Try a manual
configuration. Please also contact <[email protected]> to see about
rectifying this. Include the above 'checking host system type...' line.
***************************************************************************
]])
fi
AC_MSG_RESULT([$template])
PORTNAME=$template
AC_SUBST(PORTNAME)
#
# Read the template
#
# . "$srcdir/src/template/$template" || exit
dnl Initial CXX, CFLAGS, CXXFLAGS, CPPFLAGS, LDFLAGS, LIBS
AC_MSG_CHECKING(initial CXX)
AC_MSG_RESULT($CXX)
AC_MSG_CHECKING(initial CFLAGS)
AC_MSG_RESULT($CFLAGS)
AC_MSG_CHECKING(initial CXXFLAGS)
AC_MSG_RESULT($CXXFLAGS)
AC_MSG_CHECKING(initial CPPFLAGS)
AC_MSG_RESULT($CPPFLAGS)
AC_MSG_CHECKING(initial LDFLAGS)
AC_MSG_RESULT($LDFLAGS)
AC_MSG_CHECKING(initial LIBS)
AC_MSG_RESULT($LIBS)
m4_include([m4/m4_ax_python_devel.m4])
# Generate a header file with all settings, a config.h file (Automake will add -DHAVE_CONFIG_H)
AC_CONFIG_HEADERS([include/ulib/internal/config.h])
AC_CANONICAL_HOST
# Check what platform we are running on
AC_MSG_CHECKING([which platform we are running on])
local_os_type="unknown"
is_librt_available="yes"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CXXFLAGS="$CXXFLAGS -I/usr/local/include"
case "$host" in
*-sco*) AC_MSG_ERROR([We do not support SCO's products!]) ;;
*-aix*) local_os_type="aix" ;;
*-osf*) local_os_type="osf" ;;
*-irix*) local_os_type="irix" ;;
*-hpux*) local_os_type="hpux" ;;
*-linux*) local_os_type="linux" ;;
*-cygwin*) local_os_type="cygwin" ;;
*-darwin*)
local_os_type="darwin"
is_librt_available="no"
;;
*-netbsd*)
local_os_type="netbsd"
LDFLAGS="$LDFLAGS -L/usr/local/v6/lib"
;;
*-openbsd*)
local_os_type="openbsd"
LIBS="L/usr/local/lib $LIBS"
;;
*mingw*)
local_os_type="mingw"
is_librt_available="no"
CPPFLAGS="$CPPFLAGS -I/mingw/include -L/mingw/lib -D__USE_MINGW_ANSI_STDIO=1"
CXXFLAGS="$CXXFLAGS -I/mingw/include -L/mingw/lib"
LDFLAGS="$LDFLAGS -L/mingw/lib"
;;
*-sunos*)
local_os_type="sunos"
CXXFLAGS="$CXXFLAGS -pthreads"
LDFLAGS="$LDFLAGS -lsocket -lnsl -lresolv"
;;
*-solaris*)
local_os_type="solaris"
CXXFLAGS="$CXXFLAGS -pthreads"
LDFLAGS="$LDFLAGS -lsocket -lnsl"
;;
*-freebsd*)
local_os_type="freebsd"
CXXFLAGS="$CXXFLAGS -pthread"
LDFLAGS="$LDFLAGS -L/usr/local/v6/lib"
;;
*) local_os_type=unknown ;;
esac
AS_IF([test "x$local_os_type" = xunknown], [AC_MSG_RESULT([unknown])], [test "x$local_os_type" != xunknown], [AC_MSG_RESULT([$local_os_type])])
# Check for architecture for the target
AC_MSG_CHECKING([which architecture the target is])
TARGET_ARCH=
case $target in
x86_64*) TARGET_ARCH=x86_64 ;;
i*86) TARGET_ARCH=i386 ;;
sh*) TARGET_ARCH=sh ;;
mips*) TARGET_ARCH=mips ;;
or1k*) TARGET_ARCH=openrisc ;;
microblaze) TARGET_ARCH=microblaze ;;
powerpc*|ppc*) TARGET_ARCH=powerpc ;;
*netbsd*) TARGET_ARCH=NetBSD
enable_stdcpp="yes" ;;
arm*) TARGET_ARCH=arm
AC_DEFINE([HAVE_NO_UNALIGNED_ACCESSES], 1, [Define to 1 if the target don't allows unaligned reads and write]) ;;
aarch64*) TARGET_ARCH=arm64
AC_DEFINE([HAVE_NO_UNALIGNED_ACCESSES], 1, [Define to 1 if the target don't allows unaligned reads and write]) ;;
*) TARGET_ARCH=unknown ;;
esac
#AC_SUBST(TARGET_ARCH)
AS_IF([test "x$TARGET_ARCH" = xunknown], [AC_MSG_RESULT([unknown])], [test "x$TARGET_ARCH" != xunknown], [AC_MSG_RESULT([$TARGET_ARCH])])
# Check for Operating system and libc to use in $target
AC_MSG_CHECKING([which operating system the target is])
OPERATINGSYSTEM=
TARGET_LIBC=
case $target in
*-*-linux-*) OPERATINGSYSTEM=linux ;;
*netbsd*) OPERATINGSYSTEM=NetBSD ;;
*-none-*) OPERATINGSYSTEM=baremetal ;;
*) OPERATINGSYSTEM=unknown ;;
esac
#AC_SUBST(OPERATINGSYSTEM)
AS_IF([test "x$OPERATINGSYSTEM" = xunknown], [AC_MSG_RESULT([unknown])], [test "x$OPERATINGSYSTEM" != xunknown], [AC_MSG_RESULT([$OPERATINGSYSTEM])])
AC_MSG_CHECKING([which libc is detected for the target])
if test "x$OPERATINGSYSTEM" = xlinux ; then
case $target in
*-*-linux-gnu*) TARGET_LIBC=glibc ;;
*-*-linux-musl*) TARGET_LIBC=musl ;;
*-*-linux-uclibc*) TARGET_LIBC=uclibc ;;
*) TARGET_LIBC=unknown ;;
esac
else
case $target in
*netbsd*) TARGET_LIBC=libc ;;
*) TARGET_LIBC=unknown ;;
esac
fi
#AC_SUBST(TARGET_LIBC)
AS_IF([test "x$TARGET_LIBC" = xunknown], [AC_MSG_RESULT([unknown])], [test "x$TARGET_LIBC" != xunknown], [AC_MSG_RESULT([$TARGET_LIBC])])
# check for cross compiling
if test "$cross_compiling" != "yes"; then
AM_CONDITIONAL(CROSS_COMPILING, false)
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "X$PKG_CONFIG" != "X"; then
PKG_CONFIG_PATH=`pkg-config --variable pc_path pkg-config`
fi
else
AM_CONDITIONAL(CROSS_COMPILING, true)
PKG_CONFIG_PATH=${STAGING_DIR}/usr/lib/pkgconfig
TWOCAN_CONF_MSG(Build for Target <${target}> with Environment <${STAGING_DIR}>)
if test "x$STAGING_DIR" != "x" ; then
CROSS_ENVIRONMENT=$STAGING_DIR
fi
AC_DEFINE([CROSS_COMPILE],[1],[Define if we are cross compiling])
fi
# checks for programs
TWOCAN_CONF_MSG(Checking for programs)
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_C_RESTRICT
AC_C_VOLATILE
AC_C_INLINE
AC_MSG_CHECKING([if compiling with GNU C++])
GCC_COMPILER=$($CXX --version 2>/dev/null | grep -v -E '(llvm|clang)' | grep -i -c -E '(gcc|g\+\+)')
GCC_IS_GNU=no
if [[ "$GCC_COMPILER" -eq 0 ]]; then
AC_MSG_RESULT([no])
else
GCC_IS_GNU=yes
gcc_version=`gcc -dumpversion`
AC_MSG_RESULT([yes ($gcc_version)])
AC_DEFINE([GCC_IS_GNU],[1],[Define if we are using gcc compiler])
fi
AC_MSG_CHECKING([if compiling with clang])
CLANG_COMPILER=$($CXX --version 2>/dev/null | grep -i -c -E '(llvm|clang)')
# AC_COMPILE_IFELSE(
# [AC_LANG_PROGRAM([], [[
# #ifndef __clang__
# not clang
# #endif
# ]])],
# [GCC_IS_CLANG=yes], [GCC_IS_CLANG=no])
GCC_IS_CLANG=no
AM_CONDITIONAL(CLANG, false)
if [[ "$CLANG_COMPILER" -eq 0 ]]; then
AC_MSG_RESULT([no])
else
GCC_IS_CLANG=yes
AM_CONDITIONAL(CLANG, true)
gcc_version=`clang -dumpversion`
AC_MSG_RESULT([yes ($gcc_version)])
fi
#AC_SUBST(GCC_IS_CLANG)
AC_MSG_CHECKING([if compiling with Intel C++])
INTEL_COMPILER=$($CXX --version 2>/dev/null | grep -i -c '\(icc\)')
# AC_COMPILE_IFELSE(
# [AC_LANG_PROGRAM([], [[
# #ifndef __INTEL_COMPILER
# not intel
# #endif
# ]])],
# [GCC_IS_INTEL=yes], [GCC_IS_INTEL=no])
GCC_IS_INTEL=no
AM_CONDITIONAL(INTEL, false)
if [[ "$INTEL_COMPILER" -eq 0 ]]; then
AC_MSG_RESULT([no])
else
GCC_IS_INTEL=yes
AM_CONDITIONAL(INTEL, true)
gcc_version=`icc -dumpversion`
AC_MSG_RESULT([yes ($gcc_version)])
fi
#AC_SUBST(GCC_IS_INTEL)
ULIB_LIBS=
MODULE_LIBTOOL_OPTIONS="-shared -export-dynamic -avoid-version"
os_version=`uname -a`
AC_DEFINE_UNQUOTED(_OS_VERSION, "$os_version", [Operating System version])
AC_MSG_CHECKING([for a supported OS])
case "$target_os" in
*linux*)
AC_MSG_RESULT([ok ($target_os)])
# Ok, this is linux. Check the kernel version
AC_MSG_CHECKING([for the kernel version])
kernel=`uname -r`
case "$kernel" in
0.*)
AC_MSG_RESULT([unsupported ($kernel)])
AC_MSG_ERROR([ULib works on kernels 2.\[4,6\].x,\[3,5\].x.x])
;;
1.*)
AC_MSG_RESULT([unsupported ($kernel)])
AC_MSG_ERROR([ULib works on kernels 2.\[4,6\].x,\[3,5\].x.x])
;;
2.1.*)
AC_MSG_RESULT([unsupported ($kernel)])
AC_MSG_ERROR([ULib works on kernels 2.\[4,6\].x,\[3,5\].x.x])
;;
2.2.*)
AC_MSG_RESULT([unsupported ($kernel)])
AC_MSG_ERROR([ULib works on kernels 2.\[4,6\].x,\[3,5\].x.x])
;;
2.3.*)
AC_MSG_RESULT([unsupported ($kernel)])
AC_MSG_ERROR([ULib works on kernels 2.\[4,6\].x,\[3,5\].x.x])
;;
2.5.*)
AC_MSG_RESULT([unsupported ($kernel)])
AC_MSG_ERROR([ULib works on kernels 2.\[4,6\].x,\[3,5\].x.x])
;;
2.4.*)
AC_MSG_RESULT([2.4 family ($kernel)])
# AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
;;
2.6.*)
AC_MSG_RESULT([2.6 family ($kernel)])
# AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you're using Linux 2.6.x])
;;
3.*)
AC_MSG_RESULT([3 family ($kernel)])
# AC_DEFINE([KERNEL_3], 1, [Define to 1 if you're using Linux 3.x])
;;
4.*)
AC_MSG_RESULT([4 family ($kernel)])
# AC_DEFINE([KERNEL_4], 1, [Define to 1 if you're using Linux 4.x])
;;
5.*)
AC_MSG_RESULT([5 family ($kernel)])
# AC_DEFINE([KERNEL_5], 1, [Define to 1 if you're using Linux 5.x])
;;
6.*)
AC_MSG_RESULT([6 family ($kernel)])
# AC_DEFINE([KERNEL_6], 1, [Define to 1 if you're using Linux 6.x])
;;
7.*)
AC_MSG_RESULT([7 family ($kernel)])
# AC_DEFINE([KERNEL_7], 1, [Define to 1 if you're using Linux 7.x])
;;
8.*)
AC_MSG_RESULT([8 family ($kernel)])
# AC_DEFINE([KERNEL_8], 1, [Define to 1 if you're using Linux 8.x])
;;
9.*)
AC_MSG_RESULT([9 family ($kernel)])
# AC_DEFINE([KERNEL_9], 1, [Define to 1 if you're using Linux 9.x])
;;
*)
AC_MSG_RESULT([1x family ($kernel)])
# AC_DEFINE([KERNEL_1x], 1, [Define to 1 if you're using Linux 1x.x])
;;
esac
enable_stdcpp="yes"
AM_CONDITIONAL(LINUX, true)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
mingw*)
AC_MSG_RESULT([ok ($target_os)])
enable_stdcpp="no"
CPPFLAGS="$CPPFLAGS -D__USE_CRTIMP -Wno-sign-compare"
if test "$enable_static" = "yes"; then
AC_MSG_WARN([Disabling static library build, must build as DLL on Windows])
enable_static=no
fi
if test "$enable_shared" = "no"; then
AC_MSG_WARN([Enabling shared library build, must build as DLL on Windows])
fi
enable_shared=yes
AC_CHECK_TOOL(WINDRES, windres, no)
if test "$WINDRES" = no; then
AC_MSG_ERROR([*** Could not find an implementation of windres in your PATH])
fi
AC_CHECK_PROG(ms_librarian, lib.exe, yes, no)
# We currently use .def files on Windows
MODULE_LIBTOOL_OPTIONS="-export-dynamic -avoid-version -no-undefined"
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, true)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
cygwin*)
AC_MSG_RESULT([ok ($target_os)])
CPPFLAGS="$CPPFLAGS -U__STRICT_ANSI__" # if not, the functions fdopen, fileno and strptime will not available...
MODULE_LIBTOOL_OPTIONS="-shared -no-undefined"
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, true)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
*netbsd*)
AC_MSG_RESULT([ok ($target_os)])
CPPFLAGS="$CPPFLAGS -fpermissive -Wno-sign-compare"
if test "$target_os" = "netbsd"; then
CPPFLAGS="$CPPFLAGS -D__UNIKERNEL__"
## LDFLAGS="${LDFLAGS} -Wl,--no-as-needed -lrump -Wl,--no-as-needed -lrumpuser"
AC_CHECK_HEADERS([rump/rump.h],, AC_MSG_ERROR([rump kernel required]))
else
ULIB_LIBS="$ULIB_LIBS -lexecinfo"
# Disable -ffunction-sections -fdata-sections and accompanying --gc-sections on netbsd because --gc-sections doesn't work with the netbsd-4 and netbsd-5 linker
LDFLAGS="${LDFLAGS} -Wl,--no-gc-sections"
fi
MODULE_LIBTOOL_OPTIONS="-shared -avoid-version -no-undefined"
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, true)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
*solaris*)
AC_MSG_RESULT([ok ($target_os)])
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, true)
;;
darwin*)
AC_MSG_RESULT([maybe ($target_os)])
CPPFLAGS="$CPPFLAGS -D__OSX__ -D__APPLE__ -Wno-deprecated-declarations"
MODULE_LIBTOOL_OPTIONS="-dynamic -bundle -undefined suppress -flat_namespace -read_only_relocs suppress"
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, true)
AM_CONDITIONAL(SOLARIS, false)
;;
osf*)
AC_MSG_RESULT([maybe ($target_os)])
MODULE_LIBTOOL_OPTIONS="-shared -no-undefined"
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
*minix*)
AC_MSG_RESULT([maybe ($target_os)])
enable_stdcpp="no"
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
*)
AC_MSG_RESULT([no ($target_os)])
AM_CONDITIONAL(LINUX, false)
AM_CONDITIONAL(MINGW, false)
AM_CONDITIONAL(CYGWIN, false)
AM_CONDITIONAL(NETBSD, false)
AM_CONDITIONAL(DARWIN, false)
AM_CONDITIONAL(SOLARIS, false)
;;
esac
AM_CONDITIONAL(MS_LIB_AVAILABLE, test x$ms_librarian = xyes)
# Check for the compiler support
gcc_major_4_1="no"
if test "x$GCC_IS_GNU" = xyes -a "x$GCC_IS_CLANG" = xno -a "x$GCC_IS_INTEL" = xno; then
# We don't want gcc 2.7
AC_MSG_CHECKING([for a supported version of gcc])
case "$gcc_version" in
1.*|2.7.*|2.8.*)
AC_MSG_RESULT([no ($gcc_version)])
AC_MSG_ERROR([please use a more recent (>= gcc-2.95) version of gcc])
;;
2.95)
enable_stdcpp="no"
AC_MSG_RESULT([ok ($gcc_version)])
;;
3*|4.0*)
AC_MSG_RESULT([ok ($gcc_version)])
;;
4.1*|4.2*|4.3*|4.4*|4.5*|4.6*|4.7*)
AC_MSG_RESULT([ok ($gcc_version)])
gcc_major_4_1="yes"
;;
*)
AC_MSG_RESULT([ok ($gcc_version)])
gcc_major_4_1="yes"
AC_MSG_CHECKING([whether there are the gcc built-in functions to detect run-time CPU type and ISA])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>]],[[__builtin_cpu_init();if (__builtin_cpu_supports("sse4.2")) return 0; return 1;]])],
[AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_BUILTIN_CPU_INIT],[1],[there are the built-in functions to detect run-time CPU type and ISA])],
[AC_MSG_RESULT([no])])
if test "$cross_compiling" != "yes"; then
AC_MSG_CHECKING([if we have support for crc32 intrinsics])
echo 'void f(){}' >conftest.cpp
if test -z "`$CC -mcrc32 -c conftest.cpp 2>&1`"; then
CPPFLAGS_save=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -mcrc32"
AC_CACHE_VAL(ac_cv_crc32_intrinsics, [
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],[[__builtin_cpu_init();if (__builtin_cpu_supports("sse4.2")) return 0; return 1;]])],
[ac_cv_crc32_intrinsics="yes"], [ac_cv_crc32_intrinsics="no"]) ])
if test "x$ac_cv_crc32_intrinsics" = xyes; then
AC_MSG_RESULT([yes])
AC_DEFINE([USE_HARDWARE_CRC32],[1],[Define if we have support for crc32 intrinsics])
else
AC_MSG_RESULT([no])
CPPFLAGS=$CPPFLAGS_save
fi
fi
fi
;;
esac
fi
# GNUC 4.1.0 and later versions provide built-in functions
# for atomic memory access. see online doc for details at
# http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
if test "$gcc_major_4_1" = "yes"; then
AC_MSG_CHECKING(if you want to enable build of gcc atomic support)
AC_ARG_ENABLE(atomics, [ --enable-atomics enable gcc atomic support [[default=yes]]])
if test -z "$enable_atomics"; then
enable_atomics="yes"
fi
AC_MSG_RESULT([$enable_atomics])
fi
if test "$enable_atomics" = "yes" ; then
AC_DEFINE(HAVE_GCC_ATOMICS, [1], [cannot test in autoconf safely])
fi
# SECTION 2: Configure script command line options
# Shared library versioning
#GENERIC_LIBRARY_VERSION=$PACKAGE_VERSION
# | | |
# +------+ | +---+
# | | |
# current:revision:age
# | | |
# | | +- increment if interfaces have been added
# | | set to zero if interfaces have been removed or changed
# | +- increment if source code has changed
# | set to zero if current is incremented
# +- increment if interfaces have been added, removed or changed
#AC_SUBST(GENERIC_LIBRARY_VERSION)
# ==========================================================================================================
# Updating library version information
# ==========================================================================================================
# If you want to use libtool's versioning system, then you must specify the version information to libtool
# using the -version-info flag during link mode (Note: Link mode)
#
# This flag accepts an argument of the form CURRENT[:REVISION[:AGE]].
# So, passing -version-info 3:12:1 sets CURRENT to 3, REVISION to 12, and AGE to 1
#
# If either REVISION or AGE are omitted, they default to 0. Also note that AGE must be less than or equal to the CURRENT interface number.
#
# Here are a set of rules to help you update your library version information:
#
# 1. Start with version information of 0:0:0 for each libtool library.
#
# 2. Update the version information only immediately before a public
# release of your software. More frequent updates are unnecessary,
# and only guarantee that the current interface number gets larger
# faster.
#
# 3. If the library source code has changed at all since the last
# update, then increment REVISION (C:R:A becomes C:r+1:A).
#
# 4. If any interfaces have been added, removed, or changed since the
# last update, increment CURRENT, and set REVISION to 0.
#
# 5. If any interfaces have been added since the last public release,
# then increment AGE.
#
# 6. If any interfaces have been removed since the last public release,
# then set AGE to 0.
#
# *NEVER* try to set the interface numbers so that they correspond to the release number of your package. This is an abuse that only
# fosters misunderstanding of the purpose of library versions. Instead, use the -release flag (Note: Release numbers), but be warned
# that every release of your package will not be binary compatible with any other release.
# ==========================================================================================================
# By default, this macro turns on shared libraries if they are available, and also enables static libraries
# if they don't conflict with the shared libraries. You can modify these defaults by calling either the
# AC_DISABLE_SHARED or AC_DISABLE_STATIC macros:
dnl Initialize Libtool
m4_ifdef([LT_INIT], [LT_INIT([dlopen shared static win32-dll])], [AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL])
LT_INIT
AC_SUBST(MODULE_LIBTOOL_OPTIONS)
if test "$enable_static" = "yes" -a "$enable_shared" = "no"; then
AM_CONDITIONAL(STATIC_ONLY, true)
AC_DEFINE(U_STATIC_ONLY, [1], [we want only static linking])
if test -z "$enable_stdcpp"; then
enable_stdcpp="no"
fi
else
AM_CONDITIONAL(STATIC_ONLY, false)
fi
AC_MSG_CHECKING([for full c++ support and linking model])
AC_ARG_ENABLE(stdcpp, [ --enable-stdcpp compile with stdc++ runtime overhead [[default=yes]]])
if test -z "$enable_stdcpp"; then
enable_stdcpp="yes"
fi
CXX_save=$CXX
if test "$enable_stdcpp" = "yes"; then
AC_MSG_RESULT(yes)
AM_CONDITIONAL(STDCPP, true)
AC_DEFINE(U_STDCPP_ENABLE, [1], [full c++ support and linking model])
# Be sure to add any -std option to CXXFLAGS before we invoke any AC_COMPILE_IFELSE()
# or similar macros. Any such macros that are invoked before we update CXXFLAGS will
# not be run with the same options that we use during the real build
AX_CXX_COMPILE_STDCXX_11([ext], [optional])
AX_CXX_COMPILE_STDCXX_14([ext], [optional])
AX_CXX_COMPILE_STDCXX_17([ext], [optional])
else
AC_MSG_RESULT(no)
AM_CONDITIONAL(STDCPP, false)
if test "x$GCC_IS_GNU" = xyes ; then
lcflags="-nodefaultlibs -nostdinc++"
else
lcflags="-library=no%Cstd -features=no%except -features=no%rtti"
fi
for flag in $lcflags; do
AC_MSG_CHECKING([whether $CXX supports $flag])
echo 'void f(){}' >conftest.cpp
if test -z "`$CXX $flag -c conftest.cpp 2>&1`"; then
ULIB_LIBS="$flag $ULIB_LIBS"
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
rm -f conftest*
done
fi
ULIB="ulib"
ulib_dbg_msg="no (--enable-debug)"
AC_MSG_CHECKING(for debugging)
AC_ARG_ENABLE(debug, [ --enable-debug compile for debugging [[default=no]]])
if test -z "$enable_debug"; then
enable_debug="no"
fi
AM_CONDITIONAL(DEBUG, false)
if test "$enable_debug" = "yes"; then
AC_MSG_RESULT(yes)
AM_CONDITIONAL(DEBUG, true)
AC_DEFINE(DEBUG, [1], [debugging model])
ULIB="ulib_g"
ulib_dbg_msg="enabled"
CPPFLAGS="$CPPFLAGS -DDEBUG"
else
AC_MSG_RESULT(no)
fi
AC_SUBST(ULIB)
AC_MSG_CHECKING(for target that allows unaligned reads and writes)
AC_ARG_ENABLE(unaligned, [ --enable-unaligned compile for target that allows unaligned reads and writes [[default=yes]]])
if test -z "$enable_unaligned"; then
enable_unaligned="yes"
fi
if test "$enable_unaligned" = "yes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_DEFINE([HAVE_NO_UNALIGNED_ACCESSES], 1, [Define to 1 if the target don't allows unaligned reads and write])
fi
AC_MSG_CHECKING(for apex memcpy/memmove)
AC_ARG_ENABLE(apexmem, [ --enable-apexmem use apex_memmove written by Trevor Herselman in 2014 [[default=no]]])
if test -z "$enable_apexmem"; then
enable_apexmem="no"
fi
AM_CONDITIONAL(APEXMEM, false)
if test "$enable_apexmem" = "yes"; then
AC_MSG_RESULT(yes)
AM_CONDITIONAL(APEXMEM, true)
AC_DEFINE(U_APEX_ENABLE, [1], [use apex_memmove written by Trevor Herselman in 2014])
else
AC_MSG_RESULT(no)
fi
ULIB_LIBC="-lc"
AC_ARG_WITH(libc,
AS_HELP_STRING([--with-libc=path],[specify path to alternate libc [[default=c]]]),
[ if test x$with_libc != x ; then
clib=`echo $with_libc | sed s/[-]l//`
ULIB_LIBC=-l${clib}
fi ])
clib=`echo $ULIB_LIBC | sed s/[-]l//`
AH_BOTTOM([
#include <ulib/internal/platform.h>
])
TWOCAN_CONF_MSG(Checking for headers)
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_MAJOR
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_FUNC_ALLOCA
AC_CHECK_HEADERS([arpa/inet.h asm/mman.h cpuid.h fcntl.h float.h inttypes.h libintl.h limits.h malloc.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h \
string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h sys/timeb.h sys/resource.h syslog.h termios.h unistd.h wchar.h \
assert.h byteswap.h endian.h execinfo.h ifaddrs.h mcheck.h ndir.h dirent.h ndir.h string.h netpacket/packet.h sched.h \
semaphore.h sysexits.h streambuf.h poll.h net/if_arp.h sys/dir.h sys/endian.h sys/ndir.h sys/inotify.h sys/sendfile.h sys/sched.h \
sys/syscall.h linux/netfilter_ipv4/ipt_ACCOUNT.h libnetfilter_conntrack/libnetfilter_conntrack.h \
/usr/src/linux/include/generated/uapi/linux/version.h])
AC_MSG_CHECKING([whether sys/inotify.h actually works])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/inotify.h>]],[[return (-1 == inotify_init());]])],
[AC_MSG_RESULT([yup]); AC_DEFINE([SYS_INOTIFY_H_EXISTS_AND_WORKS],[1],[sys/inotify.h exists and works correctly])],
[AC_MSG_RESULT([nope, using own inotify headers])])
AM_CONDITIONAL(ASSERT, test "$ac_cv_header_assert_h" = "yes")
if test "$ac_cv_header_sys_inotify_h" = "yes"; then
AC_CHECK_FUNCS([inotify_init1])
fi
socket_lib=""
OPENSSL_LINK=""
threading="none"
AC_CHECK_LIB(msvcrt, fopen, [
threading="msw"
clib="msvcrt"
ULIB_LIBC="-lmingwex -lmingw32 -lcrypt32 -luser32 -lwinmm -lws2_32 -lwsock32 -lmsvcrt -lshell32 -ladvapi32 -lkernel32 -lgcc"
ULIB_LIBS="--enable-stdcall-fixup $ULIB_LIBS"
OPENSSL_LINK="-lgdi32"
AC_DEFINE(HAVE_INET_NTOP, [1], [have inet_ntop])
AC_DEFINE(HAVE_GETADDRINFO, [1], [have getaddrinfo]) ],[
AC_CHECK_LIB($clib, socketpair, [
AC_DEFINE(HAVE_SOCKETPAIR, [1], [have socketpair])
],[
AC_CHECK_LIB(socket, socketpair, [AC_DEFINE(HAVE_SOCKETPAIR, [1], [have socketpair])])
])
AC_CHECK_LIB($clib, getaddrinfo, [
AC_DEFINE(HAVE_GETADDRINFO, [1], [have getaddrinfo])
],[
AC_CHECK_LIB(socket, getaddrinfo, [AC_DEFINE(HAVE_GETADDRINFO, [1], [have getaddrinfo])])
])
AC_CHECK_LIB($clib, gethostbyname2, [
AC_DEFINE(HAVE_GETHOSTBYNAME2, [1], [have gethostbyname2])
],[
AC_CHECK_LIB(socket, gethostbyname2, [AC_DEFINE(HAVE_GETHOSTBYNAME2, [1], [have gethostbyname2])])
])
AC_CHECK_LIB($clib, inet_ntop, [
AC_DEFINE(HAVE_INET_NTOP, [1], [have inet ntop])
],[
AC_CHECK_LIB(socket, inet_ntop, [
AC_DEFINE(HAVE_INET_NTOP, [1], [have inet ntop])
],[
AC_CHECK_LIB(nsl, inet_ntop, [
AC_DEFINE(HAVE_INET_NTOP, [1], [have inet_ntop])
socket_lib="-lnsl"
])
])
])
AC_CHECK_LIB(socket, socket,[
AC_CHECK_LIB(socket, socketpair,[
AC_DEFINE(HAVE_SOCKETPAIR, [1], [have socketpair in libsocket])
])
socket_lib="-lsocket"
])
])
AC_CHECK_LIB($clib, lstat, [
AC_DEFINE(HAVE_LSTAT, [1], [have lstat])
])
AC_CHECK_LIB($clib, strcoll, [
AC_DEFINE(HAVE_STRCOLL, [1], [string collation])
])
AC_CHECK_LIB($clib, stricmp, [
AC_DEFINE(HAVE_STRICMP, [1], [string icmp])
])
AC_CHECK_LIB($clib, stristr, [
AC_DEFINE(HAVE_STRISTR, [1], [string istr])
])
AC_CHECK_LIB($clib, sysconf, [
AC_DEFINE(HAVE_SYSCONF, [1], [system config])
])
##AC_CHECK_LIB($clib, localtime_r, [
## AC_DEFINE(HAVE_LOCALTIME_R, [1], [system localtime_r])
##])
##AC_CHECK_LIB($clib, gmtime_r, [
## AC_DEFINE(HAVE_GMTIME_R, [1], [system gmtime_r])
##])
AC_CHECK_LIB($clib, posix_memalign, [
AC_DEFINE(HAVE_POSIX_MEMALIGN, [1], [posix memory alignment])
])
tlib=""
plib=""
PTHREAD_FLAGS=""
AC_MSG_CHECKING(if you want to enable build of thread support)
AC_ARG_ENABLE(thread, [ --enable-thread enable build of thread support [[default=yes]]])
if test -z "$enable_thread" -a "$enable_shared" = "yes"; then
enable_thread="yes"
fi
AC_MSG_RESULT([$enable_thread])
AC_MSG_CHECKING(if you want to always use GNU pth for threading)
AC_ARG_ENABLE(pth, [ --enable-pth always use GNU pth for threading [[default=no]]])
if test -z "$enable_pth"; then
enable_pth="no"
fi
AC_MSG_RESULT([$enable_pth])
if test "$threading" = "none" ; then
if test "$enable_pth" != "yes" ; then
AC_CHECK_HEADER(pthread.h, [
PTHREAD_FLAGS="-mt -pthread -pthreads"
AC_CHECK_LIB(pthread,pthread_create,[ tlib="pthread" ])
if test -z "$tlib" ; then
AC_CHECK_LIB($clib, pthread_create, [tlib="$clib"])
fi
if test -z "$tlib" ; then
AC_CHECK_LIB(c_r, pthread_create, [
tlib="c_r"
if test "$clib" = "c" ; then
AC_CHECK_LIB(c_r, malloc, [clib="c_r"])
fi
])
fi
if test ! -z "$tlib" ; then
AC_CHECK_LIB($tlib,pthread_suspend,[
AC_DEFINE(HAVE_PTHREAD_SUSPEND, [1], [pthread suspend])
])
AC_CHECK_LIB($tlib,pthread_cancel,[
AC_DEFINE(HAVE_PTHREAD_CANCEL, [1], [pthread cancel])
])
AC_CHECK_LIB($tlib,pthread_condattr_setclock,[
AC_DEFINE(HAVE_PTHREAD_CONDATTR_SETCLOCK, [1], [pthread clocking])
])
AC_CHECK_LIB($tlib,pthread_setconcurrency,[
AC_DEFINE(HAVE_PTHREAD_SETCONCURRENCY, [1], [pthread concurrency])
])
AC_CHECK_LIB($tlib,pthread_yield,[
AC_DEFINE(HAVE_PTHREAD_YIELD, [1], [pthread yield],[
AC_CHECK_LIB($tlib,pthread_yield_np,[
AC_DEFINE(HAVE_PTHREAD_YIELD_NP, [1], [pthread yield np])
])
])
])
AC_CHECK_LIB($tlib,pthread_delay,[
AC_DEFINE(HAVE_PTHREAD_DELAY, [1], [pthread delay])
])
AC_CHECK_LIB($tlib,pthread_delay_np,[
AC_DEFINE(HAVE_PTHREAD_DELAY_NP, [1], [pthread delay np])
])
AC_CHECK_LIB($tlib,pthread_setschedprio,[
AC_DEFINE(HAVE_PTHREAD_SETSCHEDPRIO, [1], [pthread scheduling])
])