|
1 | | -dnl Check for GEOIP Libraries |
2 | | -dnl CHECK_GEOIP(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) |
| 1 | +dnl Check for GeoIP Libraries |
3 | 2 | dnl Sets: |
4 | 3 | dnl GEOIP_CFLAGS |
5 | 4 | dnl GEOIP_LDADD |
6 | 5 | dnl GEOIP_LDFLAGS |
7 | | -dnl GEOIP_LIBS |
8 | 6 | dnl GEOIP_VERSION |
| 7 | +dnl GEOIP_DISPLAY |
| 8 | +dnl GEOIP_FOUND |
9 | 9 |
|
10 | 10 | AC_DEFUN([PROG_GEOIP], [ |
11 | | -
|
12 | | -# Possible names for the geoip library/package (pkg-config) |
13 | | -GEOIP_POSSIBLE_LIB_NAMES="geoip2 geoip GeoIP" |
14 | | -
|
15 | | -# Possible extensions for the library |
16 | | -GEOIP_POSSIBLE_EXTENSIONS="so la sl dll dylib" |
17 | | -
|
18 | | -# Possible paths (if pkg-config was not found, proceed with the file lookup) |
19 | | -GEOIP_POSSIBLE_PATHS="/usr/local/libgeoip /usr/local/geoip /usr/local /opt/libgeoip /opt/geoip /opt /usr /opt/local/include /opt/local /usr/lib /usr/local/lib /usr/lib64 /usr" |
20 | | -
|
21 | | -# Variables to be set by this very own script. |
22 | | -GEOIP_VERSION="" |
23 | | -GEOIP_CFLAGS="" |
24 | | -GEOIP_CPPFLAGS="" |
25 | | -GEOIP_LDADD="" |
26 | | -GEOIP_LDFLAGS="" |
27 | | -
|
28 | | -AC_ARG_WITH( |
29 | | - geoip, |
30 | | - AS_HELP_STRING( |
31 | | - [--with-geoip=PATH], |
32 | | - [Path to GeoIP (including headers). Use 'no' to disable GeoIP support.] |
33 | | - ) |
34 | | -) |
35 | | -
|
36 | | -# AS_HELP_STRING( |
37 | | -# [--without-geoip], |
38 | | -# [Complete dsiables GeoIP support] |
39 | | -# ) |
40 | | -
|
41 | | -
|
42 | | -if test "x${with_geoip}" == "xno"; then |
43 | | - AC_DEFINE(HAVE_GEOIP, 0, [Support for GeoIP was disabled by the utilization of --without-geoip or --with-geoip=no]) |
44 | | - AC_MSG_NOTICE([Support for GeoIP was disabled by the utilization of --without-geoip or --with-geoip=no]) |
45 | | - GEOIP_DISABLED=yes |
46 | | -else |
47 | | - if test "x${with_geoip}" == "xyes"; then |
48 | | - GEOIP_MANDATORY=yes |
49 | | - AC_MSG_NOTICE([GeoIP support was marked as mandatory by the utilization of --with-geoip=yes]) |
50 | | - fi |
51 | | -# for x in ${GEOIP_POSSIBLE_LIB_NAMES}; do |
52 | | -# CHECK_FOR_GEOIP_AT(${x}) |
53 | | -# if test -n "${GEOIP_VERSION}"; then |
54 | | -# break |
55 | | -# fi |
56 | | -# done |
57 | | -
|
58 | | -# if test "x${with_geoip}" != "xyes" or test "x${with_geoip}" == "xyes"; then |
59 | | - if test "x${with_geoip}" == "x" || test "x${with_geoip}" == "xyes"; then |
60 | | - # Nothing about GeoIP was informed, using the pkg-config to figure things out. |
61 | | - if test -n "${PKG_CONFIG}"; then |
62 | | - GEOIP_PKG_NAME="" |
63 | | - for x in ${GEOIP_POSSIBLE_LIB_NAMES}; do |
64 | | - if ${PKG_CONFIG} --exists ${x}; then |
65 | | - GEOIP_PKG_NAME="$x" |
66 | | - break |
67 | | - fi |
68 | | - done |
69 | | - fi |
70 | | - AC_MSG_NOTICE([Nothing about GeoIP was informed during the configure phase. Trying to detect it on the platform...]) |
71 | | - if test -n "${GEOIP_PKG_NAME}"; then |
72 | | - # Package was found using the pkg-config scripts |
73 | | - GEOIP_VERSION="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --modversion`" |
74 | | - GEOIP_CFLAGS="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --cflags`" |
75 | | - GEOIP_LDADD="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --libs-only-l`" |
76 | | - GEOIP_LDFLAGS="`${PKG_CONFIG} ${GEOIP_PKG_NAME} --libs-only-L --libs-only-other`" |
77 | | - GEOIP_DISPLAY="${GEOIP_LDADD}, ${GEOIP_CFLAGS}" |
78 | | - else |
79 | | - # If pkg-config did not find anything useful, go over file lookup. |
80 | | - for x in ${GEOIP_POSSIBLE_PATHS}; do |
81 | | - CHECK_FOR_GEOIP_AT(${x}) |
82 | | - if test -n "${GEOIP_VERSION}"; then |
83 | | - break |
84 | | - fi |
85 | | - done |
86 | | - fi |
87 | | - fi |
88 | | - if test "x${with_geoip}" != "x"; then |
89 | | - # An specific path was informed, lets check. |
90 | | - GEOIP_MANDATORY=yes |
91 | | - CHECK_FOR_GEOIP_AT(${with_geoip}) |
92 | | - fi |
93 | | -# fi |
94 | | -fi |
95 | | -
|
96 | | -if test -z "${GEOIP_CFLAGS}"; then |
97 | | - if test -z "${GEOIP_MANDATORY}"; then |
98 | | - if test -z "${GEOIP_DISABLED}"; then |
99 | | - AC_MSG_NOTICE([GeoIP library was not found]) |
100 | | - GEOIP_FOUND=0 |
101 | | - else |
102 | | - GEOIP_FOUND=2 |
103 | | - fi |
104 | | - else |
105 | | - AC_MSG_ERROR([GeoIP was explicit requested but it was not found]) |
106 | | - GEOIP_FOUND=-1 |
107 | | - fi |
108 | | -else |
109 | | - GEOIP_FOUND=1 |
110 | | - AC_MSG_NOTICE([using GeoIP v${GEOIP_VERSION}]) |
111 | | - GEOIP_CFLAGS="-DWITH_GEOIP ${GEOIP_CFLAGS}" |
112 | | - AC_SUBST(GEOIP_VERSION) |
113 | | - AC_SUBST(GEOIP_LDADD) |
114 | | - AC_SUBST(GEOIP_LIBS) |
115 | | - AC_SUBST(GEOIP_LDFLAGS) |
116 | | - AC_SUBST(GEOIP_CFLAGS) |
117 | | - AC_SUBST(GEOIP_DISPLAY) |
118 | | -fi |
119 | | -
|
120 | | -
|
121 | | -
|
122 | | -AC_SUBST(GEOIP_FOUND) |
123 | | -
|
| 11 | +MSC_CHECK_LIB([GEOIP], [geoip2 geoip GeoIP], [GeoIPCity.h], [GeoIP], [-DWITH_GEOIP]) |
124 | 12 | ]) # AC_DEFUN [PROG_GEOIP] |
125 | | -
|
126 | | -
|
127 | | -AC_DEFUN([CHECK_FOR_GEOIP_AT], [ |
128 | | - path=$1 |
129 | | - for y in ${GEOIP_POSSIBLE_EXTENSIONS}; do |
130 | | - for z in ${GEOIP_POSSIBLE_LIB_NAMES}; do |
131 | | - if test -e "${path}/${z}.${y}"; then |
132 | | - geoip_lib_path="${path}/" |
133 | | - geoip_lib_name="${z}" |
134 | | - geoip_lib_file="${geoip_lib_path}/${z}.${y}" |
135 | | - break |
136 | | - fi |
137 | | - if test -e "${path}/lib${z}.${y}"; then |
138 | | - geoip_lib_path="${path}/" |
139 | | - geoip_lib_name="${z}" |
140 | | - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" |
141 | | - break |
142 | | - fi |
143 | | - if test -e "${path}/lib/lib${z}.${y}"; then |
144 | | - geoip_lib_path="${path}/lib/" |
145 | | - geoip_lib_name="${z}" |
146 | | - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" |
147 | | - break |
148 | | - fi |
149 | | - if test -e "${path}/lib64/lib${z}.${y}"; then |
150 | | - geoip_lib_path="${path}/lib64/" |
151 | | - geoip_lib_name="${z}" |
152 | | - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" |
153 | | - break |
154 | | - fi |
155 | | - if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then |
156 | | - geoip_lib_path="${path}/lib/x86_64-linux-gnu/" |
157 | | - geoip_lib_name="${z}" |
158 | | - geoip_lib_file="${geoip_lib_path}/lib${z}.${y}" |
159 | | - break |
160 | | - fi |
161 | | - done |
162 | | - if test -n "$geoip_lib_path"; then |
163 | | - break |
164 | | - fi |
165 | | - done |
166 | | - if test -e "${path}/include/GeoIPCity.h"; then |
167 | | - geoip_inc_path="${path}/include" |
168 | | - elif test -e "${path}/GeoIPCity.h"; then |
169 | | - geoip_inc_path="${path}" |
170 | | - fi |
171 | | -
|
172 | | -
|
173 | | - if test -n "${geoip_inc_path}" -a -n "${geoip_lib_path}"; then |
174 | | -
|
175 | | - AC_MSG_NOTICE([GeoIP headers found at: ${geoip_inc_path}]) |
176 | | - AC_MSG_NOTICE([GeoIP library found at: ${geoip_lib_file}]) |
177 | | - fi |
178 | | -
|
179 | | - if test -n "${geoip_lib_path}" -a -n "${geoip_inc_path}"; then |
180 | | - # TODO: Compile a piece of code to check the version. |
181 | | - GEOIP_CFLAGS="-I${geoip_inc_path}" |
182 | | - GEOIP_LDADD="-l${geoip_lib_name}" |
183 | | - GEOIP_LDFLAGS="-L${geoip_lib_path}" |
184 | | - GEOIP_DISPLAY="${geoip_lib_file}, ${geoip_inc_path}" |
185 | | - fi |
186 | | -]) # AC_DEFUN [CHECK_FOR_GEOIP_AT] |
0 commit comments