forked from pbiering/ipv6calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
1329 lines (1144 loc) · 40.5 KB
/
configure.in
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
dnl Project : ipv6calc
dnl File : configure.in
dnl Version : $Id$
dnl Copyright: 2001-2017 by Peter Bieringer <pb (at) bieringer.de>
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ipv6calc, 0.99.3, [email protected], ipv6calc, http://www.deepspace6.net/projects/ipv6calc.html)
COPYRIGHT_YEAR=2016
dnl Program/library version (align with version above)
PACKAGE_VERSION_MAJOR=0
PACKAGE_VERSION_MINOR=99
PACKAGE_VERSION_BUGFIX=3
dnl API version
API_VERSION_MAJOR=0
API_VERSION_MINOR=99
API_VERSION_BUGFIX=3
dnl Generic data definitions
AC_SUBST(COPYRIGHT_YEAR)
AC_DEFINE_UNQUOTED(COPYRIGHT_YEAR, "$COPYRIGHT_YEAR", [Copyright year])
dnl Program/library version variants
PACKAGE_VERSION_NUMERIC=$(echo "$PACKAGE_VERSION_MAJOR $PACKAGE_VERSION_MINOR $PACKAGE_VERSION_BUGFIX" | awk '{ print ( $1 * 1000 + $2 ) * 1000 + $3 }')
PACKAGE_VERSION_STRING=$(echo "$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_BUGFIX")
AC_DEFINE_UNQUOTED(IPV6CALC_PACKAGE_VERSION_MAJOR, $PACKAGE_VERSION_MAJOR , "Package version Major")
AC_DEFINE_UNQUOTED(IPV6CALC_PACKAGE_VERSION_MINOR, $PACKAGE_VERSION_MINOR , "Package version Minor")
AC_DEFINE_UNQUOTED(IPV6CALC_PACKAGE_VERSION_BUGFIX, $PACKAGE_VERSION_BUGFIX , "Package version Bugfix")
AC_DEFINE_UNQUOTED(IPV6CALC_PACKAGE_VERSION_STRING, "$PACKAGE_VERSION_STRING", "Package version as string")
AC_DEFINE_UNQUOTED(IPV6CALC_PACKAGE_VERSION_NUMERIC, $PACKAGE_VERSION_NUMERIC , "Package version numeric")
dnl API version variants
API_VERSION_NUMERIC=$(echo "$API_VERSION_MAJOR $API_VERSION_MINOR $API_VERSION_BUGFIX" | awk '{ print ( $1 * 1000 + $2 ) * 1000 + $3 }')
API_VERSION_STRING=$(echo "$API_VERSION_MAJOR.$API_VERSION_MINOR.$API_VERSION_BUGFIX")
AC_DEFINE_UNQUOTED(IPV6CALC_API_VERSION_MAJOR, $API_VERSION_MAJOR , "API version Major")
AC_DEFINE_UNQUOTED(IPV6CALC_API_VERSION_MINOR, $API_VERSION_MINOR , "API version Minor")
AC_DEFINE_UNQUOTED(IPV6CALC_API_VERSION_BUGFIX, $API_VERSION_BUGFIX , "API version Bugfix")
AC_DEFINE_UNQUOTED(IPV6CALC_API_VERSION_STRING, "$API_VERSION_STRING", "API version as string")
AC_DEFINE_UNQUOTED(IPV6CALC_API_VERSION_NUMERIC, $API_VERSION_NUMERIC , "API version numeric")
dnl Define version header
AC_CONFIG_HEADER(config.h)
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
dnl AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET
dnl Checks for header files.
AC_HEADER_STDC
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_C_BIGENDIAN
dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(strspn strstr)
dnl *************************************************
dnl check for compiler options -Werror -Werror=format-security
dnl *************************************************
AC_ARG_ENABLE([compiler-warning-to-error],
AS_HELP_STRING([--disable-compiler-warning-to-error],
[Disable extra CFLAGS for mapping warnings to errors during compilation]),
[
],[
AC_MSG_RESULT([*** check for CFLAGS: -Werror=format-security])
CFLAGS_SAVE="$CFLAGS"
CFLAGS="$CFLAGS -Wformat -Werror -Werror=format-security"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[int a=1;]])
],
[
AC_MSG_RESULT([*** CFLAGS supported: -Werror=format-security])
CFLAGS_EXTRA="-Wformat -Werror -Werror=format-security"
],
[
AC_MSG_WARN([*** missing CFLAGS support: -Werror=format-security])
CFLAGS_EXTRA="-Wformat"
])
CFLAGS="$CFLAGS_SAVE"
AC_MSG_RESULT([*** check for CFLAGS: -Wsizeof-array-argument])
CFLAGS_SAVE="$CFLAGS"
CFLAGS="$CFLAGS -Wsizeof-array-argument"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[int a=1;]])
],
[
AC_MSG_RESULT([*** CFLAGS supported: -Wsizeof-array-argument])
CFLAGS_EXTRA="$CFLAGS_EXTRA -Wsizeof-array-argument"
],
[
AC_MSG_WARN([*** missing CFLAGS support: -Wsizeof-array-argument])
])
CFLAGS="$CFLAGS_SAVE"
AC_MSG_RESULT([*** check for CFLAGS: -Wparentheses-equality])
CFLAGS_SAVE="$CFLAGS"
CFLAGS="$CFLAGS -Wparentheses-equality"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[int a=1;]])
],
[
AC_MSG_RESULT([*** CFLAGS supported: -Wparentheses-equality])
CFLAGS_EXTRA="$CFLAGS_EXTRA -Wparentheses-equality"
],
[
AC_MSG_WARN([*** missing CFLAGS support: -Wparentheses-equality])
])
CFLAGS="$CFLAGS_SAVE"
AC_MSG_RESULT([*** check for CFLAGS: -Wextra])
CFLAGS_SAVE="$CFLAGS"
CFLAGS="$CFLAGS -Wextra"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[int a=1;]])
],
[
AC_MSG_RESULT([*** CFLAGS supported: -Wextra])
CFLAGS_EXTRA="$CFLAGS_EXTRA -Wextra"
],
[
AC_MSG_WARN([*** missing CFLAGS support: -Wextra])
])
CFLAGS="$CFLAGS_SAVE"
])
dnl *************************************************
dnl add -Wno-unused-const-variable if supported
dnl *************************************************
dnl AC_MSG_RESULT([*** check for CFLAGS: -Wno-unused-const-variable])
dnl CFLAGS_SAVE="$CFLAGS"
dnl CFLAGS="$CFLAGS -Wno-unused-const-variable"
dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
dnl [[int a=1;]])
dnl ],
dnl [
dnl AC_MSG_RESULT([*** CFLAGS supported: -Wno-unused-const-variable])
dnl CFLAGS_EXTRA="-Wno-unused-const-variable"
dnl ],
dnl [
dnl AC_MSG_WARN([*** missing CFLAGS support: -Wno-unused-const-variable])
dnl CFLAGS_EXTRA="-Wformat"
dnl ])
dnl CFLAGS="$CFLAGS_SAVE"
dnl *************************************************
dnl getopt library
dnl *************************************************
AC_ARG_ENABLE(
[bundled-getopt],
AS_HELP_STRING([--enable-bundled-getopt],
[Enable bundled getopt library (default: autoselected)]),
[
if test "$enable_bundled_getopt" = "yes"; then
AC_MSG_RESULT([*** use of bundled getopt library forced])
ENABLE_BUNDLED_GETOPT=1
else
AC_MSG_RESULT([*** use of system getopt library forced])
fi
],
[
AC_CHECK_FUNC(getopt_long,
[
AC_MSG_RESULT([*** use of system getopt library autoselected])
],
[
AC_MSG_RESULT([*** use of bundled getopt library autoselected])
ENABLE_BUNDLED_GETOPT=1
])
])
if test "$ENABLE_BUNDLED_GETOPT" = "1"; then
AC_LIBOBJ(../getopt/getopt)
AC_LIBOBJ(../getopt/getopt1)
GETOPT_INCLUDE=-I../getopt
AC_DEFINE(ENABLE_BUNDLED_GETOPT, 1, Define if bundled GETOPT should be used)
fi
AC_SUBST(GETOPT_INCLUDE)
AC_SUBST(ENABLE_BUNDLED_GETOPT)
dnl *************************************************
dnl MD5 library
dnl *************************************************
AC_ARG_ENABLE(
[bundled-md5],
AS_HELP_STRING([--enable-bundled-md5],
[Enable bundled MD5 library (default: autoselected)]),
[
if test "$enable_bundled_md5" = "yes"; then
AC_MSG_RESULT([*** use of bundled MD5 library forced])
ENABLE_BUNDLED_MD5=1
else
AC_MSG_RESULT([*** use of system MD5 library forced])
fi
],
[
AC_CHECK_HEADER(openssl/md5.h, [
AC_MSG_RESULT([*** openssl/md5.h header file found])
AC_CHECK_LIB(crypto, MD5_Init,
[
LDFLAGS="-lcrypto $LDFLAGS"
AC_CHECK_FUNCS(MD5_Init MD5_Update MD5_Final,
[
md5_found="yes"
],
[
ENABLE_BUNDLED_MD5=1
])
if test "$md5_found" = "yes"; then
AC_MSG_RESULT([*** use of system MD5 library autoselected])
else
AC_MSG_RESULT([*** use of bundled MD5 library autoselected])
fi
],
[
AC_MSG_WARN([crypto library header files were found but not supporting required MD5 functions (will use bundled MD5 function).])
ENABLE_BUNDLED_MD5=1
])
], [
AC_MSG_WARN([openssl/md5.h header file not found (will use bundled MD5 function).])
ENABLE_BUNDLED_MD5=1
])
],[
])
if test "$ENABLE_BUNDLED_MD5" = "1"; then
AC_LIBOBJ(../md5/md5)
GETOPT_INCLUDE=-I../md5
AC_DEFINE(ENABLE_BUNDLED_MD5, 1, Define if bundled MD5 should be used)
else
LDFLAGS_EXTRA="-lcrypto $LDFLAGS_EXTRA"
LDFLAGS_EXTRA_STATIC="-lcrypto -lz -ldl $LDFLAGS_EXTRA_STATIC"
fi
AC_SUBST(MD5_INCLUDE)
AC_SUBST(ENABLE_BUNDLED_MD5)
dnl *************************************************
dnl defaults
dnl *************************************************
geoip_db_default="/usr/share/GeoIP"
ip2location_db_default="/usr/share/IP2Location"
dbip_db_default="/usr/share/DBIP"
external_db_default="/usr/share/ipv6calc/db"
geoip_dyn_lib_default="libGeoIP.so.1"
ip2location_dyn_lib_default="libIP2Location.so"
dnl *************************************************
dnl Create binaries ushing shared library
dnl *************************************************
AC_ARG_ENABLE(
[shared],
AS_HELP_STRING([--enable-shared],
[Enable shared library build (default: disabled)])
)
if test "$enable_shared" = "yes"; then
AC_MSG_RESULT([*** Shared library build enabled])
SHARED_LIBRARY="yes"
AC_DEFINE(SHARED_LIBRARY, 1, Define if you want ipv6calc binaries compiled with shared library libipv6calc)
LDFLAGS_EXTRA_MOD_IPV6CALC="-Wl,../lib/libipv6calc.so.$PACKAGE_VERSION -Wl,../databases/lib/libipv6calc_db_wrapper.so.$PACKAGE_VERSION $LDFLAGS_EXTRA"
LDFLAGS_EXTRA="../lib/libipv6calc.so.$PACKAGE_VERSION ../databases/lib/libipv6calc_db_wrapper.so.$PACKAGE_VERSION $LDFLAGS_EXTRA"
LD_LIBRARY_PATH=../lib:../databases/lib:$LD_LIBRARY_PATH
LD_LIBRARY_PATH_BASIC=../lib:../databases/lib:$LD_LIBRARY_PATH_BASIC
else
SHARED_LIBRARY="no"
IPV6CALC_LIB="-L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc"
fi
AC_SUBST(SHARED_LIBRARY)
AC_SUBST(IPV6CALC_LIB)
dnl *************************************************
dnl Check for dynamic loading of libraries capability
dnl *************************************************
AC_CHECK_HEADER(dlfcn.h,
[
AC_MSG_RESULT([*** Dynamic loading of libraries is SUPPORTED])
DYNAMIC_LOAD_SUPPORT="yes"
],
[
DYNAMIC_LOAD_SUPPORT="no"
AC_MSG_WARN(["Dynamic loading of libraries is not supported, no header file found"])
])
AC_ARG_ENABLE(
[dynamic-load],
AS_HELP_STRING([--disable-dynamic-load],
[Disable dynamic load of libraries (default: enabled)])
)
if test "$enable_dynamic_load" = "yes"; then
DYNAMIC_LOAD="no"
else
DYNAMIC_LOAD="yes"
fi
if test "$DYNAMIC_LOAD_SUPPORT" = "yes"; then
if test "$DYNAMIC_LOAD" = "no"; then
AC_MSG_WARN(["Dynamic loading of libraries forced to be disabled"])
fi
fi
dnl *************************************************
dnl disable built-in database IEEE
dnl *************************************************
AC_ARG_ENABLE([db-ieee],
AS_HELP_STRING([--disable-db-ieee],
[Disable built-in IEEE database (default: enabled)]),
[
DB_IEEE="$enable_db_ieee"
],[
DB_IEEE="yes"
BUILTIN="yes"
])
if test "$DB_IEEE" = "yes"; then
AC_DEFINE(SUPPORT_DB_IEEE, 1, Define if you want IEEE database included.)
fi
dnl *************************************************
dnl disable built-in database IPv4
dnl *************************************************
AC_ARG_ENABLE([db-ipv4],
AS_HELP_STRING([--disable-db-ipv4],
[Disable built-in IPv4-to-Registry database (default: enabled)]),
[
DB_IPV4="$enable_db_ipv4"
],[
DB_IPV4="yes"
BUILTIN="yes"
])
if test "$DB_IPV4" = "yes"; then
AC_DEFINE(SUPPORT_DB_IPV4_REG, 1, Define if you want IPv4-to-Registry database included.)
fi
dnl *************************************************
dnl disable built-in database IPv6
dnl *************************************************
AC_ARG_ENABLE([db-ipv6],
AS_HELP_STRING([--disable-db-ipv6],
[Disable built-in IPv6-to-Registry database (default: enabled)]),
[
DB_IPV6="$enable_db_ipv6"
],
[
DB_IPV6="yes"
BUILTIN="yes"
])
if test "$DB_IPV6" = "yes"; then
AC_DEFINE(SUPPORT_DB_IPV6_REG, 1, Define if you want IPv6-to-Registry database included.)
fi
dnl *************************************************
dnl disable built-in database AS->Registry
dnl *************************************************
AC_ARG_ENABLE([db-as-registry],
AS_HELP_STRING([--disable-db-as-registry],
[Disable built-in AS-to-Registry database (default: enabled)]),
[
DB_AS_REG="$enable_db_as_registry"
],
[
DB_AS_REG="yes"
BUILTIN="yes"
])
if test "$DB_AS_REG" = "yes"; then
AC_DEFINE(SUPPORT_DB_AS_REG, 1, Define if you want AS-to-Registry database included.)
fi
dnl *************************************************
dnl disable built-in database CC->Registry
dnl *************************************************
AC_ARG_ENABLE([db-cc-registry],
AS_HELP_STRING([--disable-db-cc-registry],
[Disable built-in CountryCode-to-Registry database (default: enabled)]),
[
DB_CC_REG="$enable_db_cc_registry"
],
[
DB_CC_REG="yes"
BUILTIN="yes"
])
if test "$DB_CC_REG" = "yes"; then
AC_DEFINE(SUPPORT_DB_CC_REG, 1, Define if you want CC-to-Registry database included.)
fi
dnl *************************************************
dnl enable built-in database support in general
dnl *************************************************
if test "$BUILTIN" = "yes"; then
AC_DEFINE(SUPPORT_BUILTIN, 1, Define if you want general BuiltIn database included.)
fi
dnl *************************************************
dnl DB-IP.com support
dnl *************************************************
AC_ARG_ENABLE([dbip],
AS_HELP_STRING([--enable-dbip],
[Enable db-ip.com support (default: disabled)]),
[
DBIP="$enable_dbip"
],
[
DBIP="no"
])
dnl defaults for database directories
AC_ARG_WITH([dbip-db],
AS_HELP_STRING([--with-dbip-db=DIR],
[Use specified db-ip.com database directory, default: /usr/share/DBIP]),
[
dbip_db="$with_dbip_db"
],
[
dbip_db=$dbip_db_default
])
if test "$DBIP" = "yes"; then
require_libdb="yes"
AC_DEFINE(SUPPORT_DBIP, 1, Define if you want db-ip.com support included.)
AC_MSG_RESULT([*** db-ip.com db dir: $dbip_db])
AC_DEFINE_UNQUOTED(DBIP_DB, "$dbip_db", Define db-ip.com database directory.)
fi
DBIP_DB=$dbip_db
AC_SUBST(DBIP_DB)
dnl *************************************************
dnl External ipv6calc db support
dnl *************************************************
AC_ARG_ENABLE([external],
AS_HELP_STRING([--enable-external],
[Enable external db support (default: disabled)]),
[
EXTERNAL="$enable_external"
],
[
EXTERNAL="no"
])
dnl defaults for database directories
AC_ARG_WITH([external-db],
AS_HELP_STRING([--with-external-db=DIR],
[Use specified external database directory, default: /usr/share/ipv6calc/db]),
[
external_db="$with_external_db"
],
[
external_db=$external_db_default
])
if test "$EXTERNAL" = "yes"; then
require_libdb="yes"
AC_DEFINE(SUPPORT_EXTERNAL, 1, Define if you want external support included.)
AC_MSG_RESULT([*** external db dir: $dbip_db])
AC_DEFINE_UNQUOTED(EXTERNAL_DB, "$external_db", Define external database directory.)
fi
EXTERNAL_DB=$external_db
AC_SUBST(EXTERNAL_DB)
dnl *************************************************
dnl IP2Location support
dnl *************************************************
IP2LOCATION_LIB_NAME="IP2Location"
IP2LOCATION_INCLUDE_VERSION=""
AC_ARG_ENABLE([ip2location],
AS_HELP_STRING([--enable-ip2location],
[Enable IP2Location support (default: disabled)]),
[
IP2LOCATION="$enable_ip2location"
],[
IP2LOCATION="no"
])
AC_ARG_WITH([ip2location-dynamic],
AS_HELP_STRING([--with-ip2location-dynamic],
[Enable use of dynamic loading of IP2Location library (default=no)]),
[
if test "$enable_ip2location_dynamic" != "no"; then
IP2LOCATION_DYN="yes"
fi
],[
true
])
AC_ARG_WITH([ip2location-headers],
AS_HELP_STRING([--with-ip2location-headers=DIR],
[IP2Location include files location]),
[
IP2LOCATION_INCLUDE_DIR="$with_ip2location_headers"
])
AC_ARG_WITH([ip2location-headers-fallback],
AS_HELP_STRING([--with-ip2location-headers-fallback],
[IP2Location include files from internal fallback location (only usable with dynamic load option)]),
[
if test "$IP2LOCATION_DYN" != "yes"; then
AC_MSG_ERROR([IP2Location fallback headers are only usable with dynamic load option set: --with-ip2location-dynamic])
fi
if test -n "$IP2LOCATION_INCLUDE_DIR"; then
AC_MSG_ERROR([IP2Location include files location already set by --with-ip2location-headers, skip fallback])
else
AC_MSG_RESULT([*** IP2Location fallback headers activated])
IP2LOCATION_INCLUDE_DIR="external-fallback/IP2Location"
IP2LOCATION_INCLUDE_VERSION=$(cat external-fallback/IP2Location/VERSION-IP2Location)
fi
])
if test -n "$IP2LOCATION_INCLUDE_DIR"; then
IP2LOCATION_INCLUDE="-I$IP2LOCATION_INCLUDE_DIR"
if test -d "$IP2LOCATION_INCLUDE_DIR/iMath"; then
# include iMath where existing (API < 7.0.0)
IP2LOCATION_INCLUDE="$IP2LOCATION_INCLUDE -I$IP2LOCATION_INCLUDE_DIR/iMath"
fi
if echo "$IP2LOCATION_INCLUDE_DIR" | grep -q "^/"; then
# absolute path
IP2LOCATION_INCLUDE_L1="-I$IP2LOCATION_INCLUDE_DIR"
IP2LOCATION_INCLUDE_L2="-I$IP2LOCATION_INCLUDE_DIR"
if test -d "$IP2LOCATION_INCLUDE_DIR/iMath"; then
# include iMath where existing (API < 7.0.0)
IP2LOCATION_INCLUDE_L1="$IP2LOCATION_INCLUDE_L1 -I$IP2LOCATION_INCLUDE_DIR/iMath"
IP2LOCATION_INCLUDE_L2="$IP2LOCATION_INCLUDE_L2 -I$IP2LOCATION_INCLUDE_DIR/iMath"
fi
else
IP2LOCATION_INCLUDE_L1="-I../$IP2LOCATION_INCLUDE_DIR"
IP2LOCATION_INCLUDE_L2="-I../../$IP2LOCATION_INCLUDE_DIR"
if test -d "$IP2LOCATION_INCLUDE_DIR/iMath"; then
# include iMath where existing (API < 7.0.0)
IP2LOCATION_INCLUDE_L1="$IP2LOCATION_INCLUDE_L1 -I../$IP2LOCATION_INCLUDE_DIR/iMath"
IP2LOCATION_INCLUDE_L2="$IP2LOCATION_INCLUDE_L2 -I../../$IP2LOCATION_INCLUDE_DIR/iMath"
fi
fi
fi
AC_ARG_WITH([ip2location-lib],
AS_HELP_STRING([--with-ip2location-lib=FILE],
[IP2Location library location]),
[
if test -d "$with_ip2location_lib"; then
IP2LOCATION_LIB_DIR="$with_ip2location_lib"
IP2LOCATION_LIB="-L$IP2LOCATION_LIB_DIR $IP2LOCATION_LIB"
AC_MSG_RESULT([IP2Location library directory given: $IP2LOCATION_LIB_DIR])
else
AC_MSG_ERROR([IP2Location library directory not found: $with_ip2location_lib])
fi
if echo "$IP2LOCATION_LIB_DIR" | grep -q "^/"; then
# absolute path
IP2LOCATION_LIB_L1="-L$IP2LOCATION_LIB_DIR"
IP2LOCATION_LIB_L2="-L$IP2LOCATION_LIB_DIR"
if test -n "$LD_LIBRARY_PATH"; then
LD_LIBRARY_PATH=$IP2LOCATION_LIB_DIR:$LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=$IP2LOCATION_LIB_DIR
fi
else
IP2LOCATION_LIB_L1="-L../$IP2LOCATION_LIB_DIR"
IP2LOCATION_LIB_L2="-L../../$IP2LOCATION_LIB_DIR"
if test -n "$LD_LIBRARY_PATH"; then
LD_LIBRARY_PATH=../$IP2LOCATION_LIB_DIR:$LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=$IP2LOCATION_LIB_DIR
fi
fi
])
# must be tested
#AC_ARG_WITH([ip2location-lib-name],
# AS_HELP_STRING([--with-ip2location-lib-name=NAME],
# [IP2Location library name]),
# [
# IP2LOCATION_LIB_NAME="$with_geoip_lib_name"
# IP2LOCATION_LIB="-l$IP2LOCATION_LIB_NAME $IP2LOCATION_LIB"
# AC_MSG_RESULT([IP2Location library name given: $IP2LOCATION_LIB_NAME])
# ],[
# ])
AC_ARG_WITH([ip2location-static],
AS_HELP_STRING([--with-ip2location-static],
[Explicitly link IP2Location statically (default=no)]),
[
if test "$with_ip2location_static" != "no"; then
IP2LOCATION_LIB="-Wl,-Bstatic $IP2LOCATION_LIB -Wl,-Bdynamic"
fi
])
dnl defaults for database directories
AC_ARG_WITH([ip2location-db],
AS_HELP_STRING([--with-ip2location-db=DIR],
[Use specified IP2Location database directory, default: /usr/share/IP2Location]),
[
ip2location_db="$with_ip2location_db"
],
[
ip2location_db=$ip2location_db_default
])
AC_ARG_WITH([ip2location-dyn-lib],
AS_HELP_STRING([--with-ip2location-dyn-lib=NAME],
[Use specified IP2Location dynamic library, default: libIP2Location.so]),
[
ip2location_dyn_lib="$with_ip2location_dyn_lib"
],
[
ip2location_dyn_lib=$ip2location_dyn_lib_default
])
if test "$IP2LOCATION" = "yes"; then
if test "$IP2LOCATION_DYN" != "yes"; then
IP2LOCATION_LIB="-l$IP2LOCATION_LIB_NAME $IP2LOCATION_LIB"
IP2LOCATION_LIB_L1="-l$IP2LOCATION_LIB_NAME $IP2LOCATION_LIB_L1"
IP2LOCATION_LIB_L2="-l$IP2LOCATION_LIB_NAME $IP2LOCATION_LIB_L2"
else
AC_MSG_RESULT([**** IP2Location dynamic load support enabled, disable IP2Location linker options])
fi
CPPFLAGS="$CPPFLAGS $IP2LOCATION_INCLUDE"
AC_MSG_RESULT([*** IP2Location support requested])
AC_MSG_RESULT([***** CPPFLAGS=$CPPFLAGS])
AC_MSG_RESULT([***** CFLAGS =$CFLAGS])
AC_MSG_RESULT([***** LDFLAGS =$LDFLAGS])
AC_CHECK_HEADER(IP2Location.h, [
if test -n "$IP2LOCATION_INCLUDE_DIR"; then
if test -e "$IP2LOCATION_INCLUDE_DIR/IP2Location.h"; then
CPPFLAGS="$CPPFLAGS -include $IP2LOCATION_INCLUDE_DIR/IP2Location.h"
else
AC_MSG_ERROR([IP2Location library header file not found: $IP2LOCATION_INCLUDE_DIR/IP2Location.h])
fi
else
CPPFLAGS="$CPPFLAGS -include IP2Location.h"
fi
AC_CHECK_DECL([IP2Location_open],,
AC_MSG_ERROR([IP2Location library header file misses IP2Location_open]))
AC_CHECK_DECLS([IP2Location_close,
IP2Location_get_country_short,
IP2Location_get_country_long])
AC_CHECK_DECLS([API_VERSION])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <IP2Location.h>
IP2Location loc;
void test() {
loc.ipv6databaseaddr = 1;
};
]])],[
AC_MSG_RESULT([IP2Location has full IPv6 support (API >= 7.0.0)])
IP2LOCATION_IPV6_COMPAT="no"
],[
AC_MSG_WARN([IP2Location has only compat IPv6 support (API < 7.0.0) which is no longer supported])
IP2LOCATION_IPV6_COMPAT="yes"
]
)
AC_CHECK_DECLS([USAGETYPE],
[
IP2LOCATION_ALL_COMPAT="no"
],
[
AC_MSG_WARN([IP2Location library header file misses USAGETYPE (library < 6.0.0)])
IP2LOCATION_ALL_COMPAT="yes"
]
)
],
[
AC_MSG_ERROR([IP2Location library header files not found])
])
AC_MSG_RESULT([*** IP2location db dir: $ip2location_db])
AC_DEFINE_UNQUOTED(IP2LOCATION_DB, "$ip2location_db", Define IP2Location database directory.)
if test "$IP2LOCATION_DYN" != "yes"; then
if test "$IP2LOCATION_STATIC" = "yes"; then
AC_DEFINE(SUPPORT_IP2LOCATION_STATIC, 1, Define if you want IP2Location support statically linked - requires also additional linker options.)
fi
CPPFLAGS="$CFLAGS"
if test -n "$IP2LOCATION_LIB_DIR"; then
if test -e "$IP2LOCATION_LIB_DIR/lib$IP2LOCATION_LIB_NAME.so"; then
LDFLAGS="$LDFLAGS -L$IP2LOCATION_LIB_DIR"
CFLAGS="$CFLAGS -L$IP2LOCATION_LIB_DIR"
LIBS="-L$IP2LOCATION_LIB_DIR"
else
AC_MSG_ERROR([IP2Location library file not found: $IP2LOCATION_INCLUDE_DIR/lib$IP2LOCATION_LIB_NAME.so])
fi
fi
AC_MSG_RESULT([***** CPPFLAGS=$CPPFLAGS])
AC_MSG_RESULT([***** CFLAGS =$CFLAGS])
AC_MSG_RESULT([***** LDFLAGS =$LDFLAGS])
AC_CHECK_LIB($IP2LOCATION_LIB_NAME, IP2Location_open,
[
AC_DEFINE(SUPPORT_IP2LOCATION, 1, Define if you want IP2Location support.)
AC_MSG_RESULT([*** IP2Location support enabled])
],
[
AC_MSG_ERROR([IP2Location library header files were found but the library was not found, LDFLAGS=$LDFLAGS, CFLAGS=$CFLAGS])
])
else
# wrapper detects by itself the real support
AC_MSG_RESULT([*** IP2Location dyn lib: $ip2location_dyn_lib])
AC_DEFINE_UNQUOTED(IP2LOCATION_DYN_LIB, "$ip2location_dyn_lib", Define IP2Location dynamic library.)
AC_MSG_RESULT([*** IP2Location support will be implemented by using dynamic load of library])
AC_DEFINE(SUPPORT_IP2LOCATION, 1, Define if you want IP2Location support.)
AC_DEFINE(SUPPORT_IP2LOCATION_DYN, 1, Define if you want IP2Location support with dynamic loading support - requires also additional linker options.)
fi
fi
if test "$IP2LOCATION_IPV6_COMPAT" = "yes"; then
AC_DEFINE(SUPPORT_IP2LOCATION_IPV6_COMPAT, 1, Define if your IP2Location supports IPv6 only in old manner.)
fi
if test "$IP2LOCATION_ALL_COMPAT" = "yes"; then
AC_DEFINE(SUPPORT_IP2LOCATION_ALL_COMPAT, 1, Define if your IP2Location supports only reduced set of databases.)
fi
IP2LOCATION_DB=$ip2location_db
AC_SUBST(IP2LOCATION_INCLUDE)
AC_SUBST(IP2LOCATION_INCLUDE_L1)
AC_SUBST(IP2LOCATION_INCLUDE_L2)
AC_SUBST(IP2LOCATION_LIB)
AC_SUBST(IP2LOCATION_LIB_L1)
AC_SUBST(IP2LOCATION_LIB_L2)
AC_SUBST(IP2LOCATION_DB)
AC_SUBST(IP2LOCATION_DYN_LIB)
if test -n "$IP2LOCATION_INCLUDE_VERSION"; then
AC_DEFINE_UNQUOTED(IP2LOCATION_INCLUDE_VERSION, "$IP2LOCATION_INCLUDE_VERSION", IP2Location include file version.)
fi
dnl *************************************************
dnl GeoIP support
dnl *************************************************
GEOIP_LIB_NAME="GeoIP"
GEOIP_INCLUDE_VERSION=""
AC_ARG_ENABLE([geoip],
AS_HELP_STRING([--enable-geoip],
[Enable GeoIP support (default: disabled)]),
[
if test "$enable_geoip" != "no"; then
GEOIP="$enable_geoip"
fi
],[
GEOIP="no"
])
AC_ARG_WITH([geoip-dynamic],
AS_HELP_STRING([--with-geoip-dynamic],
[Enable use of dynamic loading of GeoIP library (default=no)]),
[
if test "$with_geoip_dynamic" != "no"; then
GEOIP_DYN="yes"
fi
],[
true
])
AC_ARG_WITH([geoip-headers],
AS_HELP_STRING([--with-geoip-headers=DIR],
[GeoIP include files location]),
[
GEOIP_INCLUDE_DIR="$with_geoip_headers"
])
AC_ARG_WITH([geoip-headers-fallback],
AS_HELP_STRING([--with-geoip-headers-fallback],
[GeoIP include files from internal fallback location (only usable with dynamic load option)]),
[
if test "$GEOIP_DYN" != "yes"; then
AC_MSG_ERROR([GeoIP fallback headers are only usable with dynamic load option set: --with-geoip-dynamic])
fi
if test -n "$GEOIP_INCLUDE_DIR"; then
AC_MSG_ERROR([GeoIP include files location already set by --with-geoip-headers, skip fallback])
else
AC_MSG_RESULT([*** GeoIP fallback headers activated])
GEOIP_INCLUDE_DIR="external-fallback/GeoIP"
GEOIP_INCLUDE_VERSION=$(cat external-fallback/GeoIP/VERSION-GeoIP)
fi
])
if test -n "$GEOIP_INCLUDE_DIR"; then
GEOIP_INCLUDE="-I$GEOIP_INCLUDE_DIR"
if echo "$GEOIP_INCLUDE_DIR" | grep -q "^/"; then
# absolute path
GEOIP_INCLUDE_L1="-I$GEOIP_INCLUDE_DIR"
GEOIP_INCLUDE_L2="-I$GEOIP_INCLUDE_DIR"
else
GEOIP_INCLUDE_L1="-I../$GEOIP_INCLUDE_DIR"
GEOIP_INCLUDE_L2="-I../../$GEOIP_INCLUDE_DIR"
fi
fi
AC_ARG_WITH([geoip-lib],
AS_HELP_STRING([--with-geoip-lib=DIR],
[GeoIP library location]),
[
if test -d "$with_geoip_lib"; then
GEOIP_LIB_DIR="$with_geoip_lib"
GEOIP_LIB="-L$GEOIP_LIB_DIR $GEOIP_LIB"
AC_MSG_RESULT([GeoIP library directory given: $GEOIP_LIB_DIR])
else
AC_MSG_ERROR([GeoIP library directory not found: $with_geoip_lib])
fi
if echo "$GEOIP_LIB_DIR" | grep -q "^/"; then
# absolute path
GEOIP_LIB_L1="-L$GEOIP_LIB_DIR"
GEOIP_LIB_L2="-L$GEOIP_LIB_DIR"
LD_LIBRARY_PATH=$GEOIP_LIB_DIR:$LD_LIBRARY_PATH
else
GEOIP_LIB_L1="-L../$GEOIP_LIB_DIR"
GEOIP_LIB_L2="-L../../$GEOIP_LIB_DIR"
LD_LIBRARY_PATH=../$GEOIP_LIB_DIR:$LD_LIBRARY_PATH
fi
])
# must be tested
#AC_ARG_WITH([geoip-lib-name],
# AS_HELP_STRING([--with-geoip-lib-name=NAME],
# [GeoIP library name]),
# [
# GEOIP_LIB_NAME="$with_geoip_lib_name"
# GEOIP_LIB="-l$GEOIP_LIB_NAME $GEOIP_LIB"
# AC_MSG_RESULT([GeoIP library name given: $GEOIP_LIB_NAME])
# ],[
# ])
AC_ARG_WITH([geoip-static],
AS_HELP_STRING([--with-geoip-static],
[Explicitly link GeoIP statically (default=no)]),
[
if test "$with_geoip_static" != "no"; then
GEOIP_STATIC="$with_geoip_static"
GEOIP_LIB="-Wl,-Bstatic $GEOIP_LIB -Wl,-Bdynamic"
fi
],[
GEOIP_STATIC="no"
])
AC_ARG_WITH([geoip-db],
AS_HELP_STRING([--with-geoip-db=DIR],
[Use specified GeoIP database directory, default: /usr/share/GeoIP]),
[
geoip_db="$with_geoip_db"
],
[
geoip_db=$geoip_db_default
])
AC_ARG_WITH([geoip-dyn-lib],
AS_HELP_STRING([--with-geoip-dyn-lib=NAME],
[Use specified GeoIP dynamic library, default: libGeoIP.so.1]),
[
geoip_dyn_lib="$with_geoip_dyn_lib"
],
[
geoip_dyn_lib=$geoip_dyn_lib_default
])
AC_ARG_WITH([geoip-ipv6-compat],
AS_HELP_STRING([--with-geoip-ipv6-compat],
[Use IPv6 interface of GeoIP in compatibility mode (supporting 1.4.5)]),
[
if test "$with_geoip_ipv6_compat" != "no"; then
GEOIP_COMPAT="yes",
fi
],[
GEOIP_COMPAT="no"
])
# Automagic enable GeoIP if dynamic load is available (TODO: enable later by default??)
#if test "$DYNAMIC_LOAD" = "yes"; then
# if test "$GEOIP_DYN" = "no"; then
# true
# else
# AC_CHECK_HEADER(GeoIP.h,
# [
# AC_MSG_RESULT(["*** GeoIP library header files found and dynamic library support enabled, enable GeoIP"])
# GEOIP="yes"
# GEOIP_DYN="yes"
# ],
# [
# ])
# fi
#fi
if test "$GEOIP" = "yes"; then
if test "$GEOIP_DYN" != "yes"; then
GEOIP_LIB="-l$GEOIP_LIB_NAME $GEOIP_LIB"
GEOIP_LIB_L1="-l$GEOIP_LIB_NAME $GEOIP_LIB_L1"
GEOIP_LIB_L2="-l$GEOIP_LIB_NAME $GEOIP_LIB_L2"
else
AC_MSG_RESULT([*** GeoIP dynamic load support enabled, disable GeoIP linker options])
fi
CPPFLAGS="$CPPLAGS $GEOIP_INCLUDE"
AC_MSG_RESULT([*** GeoIP support requested])
AC_MSG_RESULT([***** CPPFLAGS=$CPPFLAGS])
AC_MSG_RESULT([***** CFLAGS =$CFLAGS])
AC_MSG_RESULT([***** LDFLAGS =$LDFLAGS])
AC_CHECK_HEADER(GeoIP.h, [
if test -n "$GEOIP_INCLUDE_DIR"; then
if test -e "$GEOIP_INCLUDE_DIR/GeoIP.h"; then
CPPFLAGS="$CPPFLAGS -include $GEOIP_INCLUDE_DIR/GeoIP.h"
else
AC_MSG_ERROR([GeoIP library header file not found: $GEOIP_INCLUDE_DIR/GeoIP.h])
fi
else
CPPFLAGS="$CPPFLAGS -include GeoIP.h"
fi
AC_CHECK_DECL([GeoIP_open],,
AC_MSG_ERROR([GeoIP library header file misses GeoIP_open]))
AC_CHECK_DECLS([GeoIP_country_code_by_ipnum_v6,
GeoIP_lib_version,
GeoIP_country_code_by_addr_v6,
GeoIP_country_name_by_addr_v6,
GeoIP_cleanup])
AC_CHECK_DECLS([GEOIP_LARGE_COUNTRY_EDITION,
GEOIP_LARGE_COUNTRY_EDITION_V6,
GEOIP_CITY_EDITION_REV0_V6,
GEOIP_CITY_EDITION_REV1_V6,
GEOIP_ASNUM_EDITION,
GEOIP_ASNUM_EDITION_V6,
GEOIP_COUNTRY_EDITION_V6])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[geoipv6_t a;]])
],
[
AC_MSG_RESULT([typedef geoipv6_t defined])
AC_DEFINE(SUPPORT_GEOIP_IPV6_STRUCT, 1, Define if GeoIP support IPv6 structure.)
],
[
AC_MSG_WARN([typedef geoipv6_t missing, enable workaround])
])
],
[
AC_MSG_ERROR([GeoIP library header files not found])
])
AC_MSG_RESULT([*** GeoIP database directory: $geoip_db])