Skip to content

Commit 5bdfcbf

Browse files
authored
Merge pull request #3494 from fzipi/chore/refactor-autoconf-files
refactor: autotools files
2 parents 5f4880b + 69d04fd commit 5bdfcbf

File tree

13 files changed

+526
-1821
lines changed

13 files changed

+526
-1821
lines changed

build/curl.m4

Lines changed: 20 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,36 @@
11
dnl Check for CURL Libraries
2-
dnl CHECK_CURL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
32
dnl Sets:
43
dnl CURL_CFLAGS
5-
dnl CURL_LIBS
6-
7-
CURL_CONFIG=""
8-
CURL_VERSION=""
9-
CURL_CPPFLAGS=""
10-
CURL_CFLAGS=""
11-
CURL_LDFLAGS=""
12-
CURL_LDADD=""
13-
CURL_MIN_VERSION="7.15.1"
4+
dnl CURL_LDADD
5+
dnl CURL_LDFLAGS
6+
dnl CURL_VERSION
7+
dnl CURL_DISPLAY
8+
dnl CURL_FOUND
149

1510
AC_DEFUN([CHECK_CURL], [
16-
17-
18-
AC_ARG_WITH(
19-
curl,
20-
[AS_HELP_STRING([--with-curl=PATH],[Path to curl prefix or config script])],
21-
[test_paths="${with_curl}"],
22-
[test_paths="/usr/local/libcurl /usr/local/curl /usr/local /opt/libcurl /opt/curl /opt /usr"])
23-
24-
AC_MSG_CHECKING([for libcurl config script])
25-
26-
for x in ${test_paths}; do
27-
dnl # Determine if the script was specified and use it directly
28-
if test ! -d "$x" -a -e "$x"; then
29-
CURL_CONFIG=$x
30-
curl_path="no"
31-
break
32-
fi
33-
34-
dnl # Try known config script names/locations
35-
for CURL_CONFIG in curl-config; do
36-
if test -e "${x}/bin/${CURL_CONFIG}"; then
37-
curl_path="${x}/bin"
38-
break
39-
elif test -e "${x}/${CURL_CONFIG}"; then
40-
curl_path="${x}"
41-
break
42-
else
43-
curl_path=""
44-
fi
45-
done
46-
if test -n "$curl_path"; then
47-
break
48-
fi
49-
done
50-
51-
if test -n "${curl_path}"; then
52-
if test "${curl_path}" != "no"; then
53-
CURL_CONFIG="${curl_path}/${CURL_CONFIG}"
54-
fi
55-
AC_MSG_RESULT([${CURL_CONFIG}])
56-
CURL_VERSION=`${CURL_CONFIG} --version | sed 's/^[[^0-9]][[^[:space:]]][[^[:space:]]]*[[[:space:]]]*//' | tr '\r\n' ' '`
57-
if test ! -z "${CURL_VERSION}"; then AC_MSG_NOTICE(curl VERSION: $CURL_VERSION); fi
58-
CURL_CFLAGS="`${CURL_CONFIG} --cflags`"
59-
if test ! -z "${CURL_CFLAGS}"; then AC_MSG_NOTICE(curl CFLAGS: $CURL_CFLAGS); fi
60-
CURL_LDADD="`${CURL_CONFIG} --libs`"
61-
if test ! -z "${CURL_CONFIG}"; then AC_MSG_NOTICE(curl LDADD: $CURL_LIBS); fi
62-
63-
dnl # Check version is ok
64-
AC_MSG_CHECKING([if libcurl is at least v${CURL_MIN_VERSION}])
65-
curl_min_ver=`echo ${CURL_MIN_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
66-
curl_ver=`echo ${CURL_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
67-
if test "$curl_min_ver" -le "$curl_ver"; then
68-
AC_MSG_RESULT([yes, $CURL_VERSION])
69-
curl_tlsv2_ver=`echo 7.34.0 | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
70-
if test "$curl_tlsv2_ver" -le "$curl_ver"; then
71-
CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL_SSLVERSION_TLSv1_2"
72-
fi
73-
CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL"
11+
MSC_CHECK_LIB([CURL], [libcurl], [curl/curl.h], [curl], [-DWITH_CURL], [7.15.1])
12+
13+
# Post-processing: TLSv1.2 version check
14+
if test "x${CURL_FOUND}" = "x1" && test -n "${CURL_VERSION}"; then
15+
AC_MSG_CHECKING([if libcurl supports TLSv1.2])
16+
_msc_curl_tlsv2_ver=`echo 7.34.0 | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
17+
_msc_curl_ver=`echo ${CURL_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
18+
if test "${_msc_curl_tlsv2_ver}" -le "${_msc_curl_ver}" 2>/dev/null; then
19+
AC_MSG_RESULT([yes])
20+
CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL_SSLVERSION_TLSv1_2"
7421
else
75-
AC_MSG_RESULT([no, $CURL_VERSION])
76-
AC_MSG_NOTICE([NOTE: curl library may be too old])
22+
AC_MSG_RESULT([no])
7723
fi
7824
79-
dnl # Check/warn if GnuTLS is used
25+
# Check/warn if GnuTLS is used
8026
AC_MSG_CHECKING([if libcurl is linked with gnutls])
81-
curl_uses_gnutls=`echo ${CURL_LIBS} | grep gnutls | wc -l`
82-
if test "$curl_uses_gnutls" -ne 0; then
27+
_msc_curl_uses_gnutls=`echo ${CURL_LDADD} | grep gnutls | wc -l`
28+
if test "$_msc_curl_uses_gnutls" -ne 0; then
8329
AC_MSG_RESULT([yes])
8430
AC_MSG_NOTICE([NOTE: curl linked with gnutls may be buggy, openssl recommended])
85-
CURL_USES_GNUTLS=yes
8631
else
8732
AC_MSG_RESULT([no])
88-
CURL_USES_GNUTLS=no
89-
fi
90-
91-
else
92-
AC_MSG_RESULT([no])
93-
fi
94-
95-
AC_SUBST(CURL_CONFIG)
96-
AC_SUBST(CURL_VERSION)
97-
AC_SUBST(CURL_CPPFLAGS)
98-
AC_SUBST(CURL_CFLAGS)
99-
AC_SUBST(CURL_LDFLAGS)
100-
AC_SUBST(CURL_LDADD)
101-
AC_SUBST(CURL_USES_GNUTLS)
102-
103-
if test "x${with_curl}" == "xno"; then
104-
CURL_DISABLED=yes
105-
else
106-
if test "x${with_curl}" != "x"; then
107-
CURL_MANDATORY=yes
108-
fi
109-
fi
110-
111-
if test -z "${CURL_VERSION}"; then
112-
AC_MSG_NOTICE([*** curl library not found.])
113-
if test -z "${CURL_MANDATORY}"; then
114-
if test -z "${CURL_DISABLED}"; then
115-
CURL_FOUND=0
116-
else
117-
CURL_FOUND=2
118-
fi
119-
else
120-
AC_MSG_ERROR([Curl was explicitly referenced but it was not found])
121-
CURL_FOUND=-1
12233
fi
123-
else
124-
CURL_FOUND=1
125-
AC_MSG_NOTICE([using curl v${CURL_VERSION}])
126-
CURL_DISPLAY="${CURL_LDADD}, ${CURL_CFLAGS}"
12734
fi
12835
129-
AC_SUBST(CURL_FOUND)
130-
AC_SUBST(CURL_DISPLAY)
131-
])
36+
]) # AC_DEFUN [CHECK_CURL]

build/libgeoip.m4

Lines changed: 4 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -1,186 +1,12 @@
1-
dnl Check for GEOIP Libraries
2-
dnl CHECK_GEOIP(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
1+
dnl Check for GeoIP Libraries
32
dnl Sets:
43
dnl GEOIP_CFLAGS
54
dnl GEOIP_LDADD
65
dnl GEOIP_LDFLAGS
7-
dnl GEOIP_LIBS
86
dnl GEOIP_VERSION
7+
dnl GEOIP_DISPLAY
8+
dnl GEOIP_FOUND
99

1010
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])
12412
]) # 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

Comments
 (0)