2 # This file is part of the aMule Project.
4 # Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
6 # Any parts of this program derived from the xMule, lMule or eMule project,
7 # or contributed by third-party developers are copyrighted by their
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 dnl ---------------------------------------------------------------------------
28 dnl Checks if the GeoIP library is requested, exists, and whether it should and
29 dnl could be linked statically.
30 dnl ---------------------------------------------------------------------------
31 AC_DEFUN([MULE_CHECK_GEOIP],
33 AC_ARG_ENABLE([geoip],
34 [AS_HELP_STRING([--enable-geoip], [compile with GeoIP IP2Country library])],
35 [ENABLE_IP2COUNTRY=$enableval], [ENABLE_IP2COUNTRY=no])
37 AS_IF([test ${ENABLE_IP2COUNTRY:-no} = yes], [
38 AC_ARG_WITH([geoip-headers],
39 AS_HELP_STRING([--with-geoip-headers=DIR], [GeoIP include files location]),
40 [GEOIP_CPPFLAGS="-I$withval"])
41 AC_ARG_WITH([geoip-lib],
42 AS_HELP_STRING([--with-geoip-lib=DIR], [GeoIP library location]),
43 [GEOIP_LDFLAGS="-L$withval"])
45 MULE_BACKUP([CPPFLAGS])
46 MULE_APPEND([CPPFLAGS], [$GEOIP_CPPFLAGS])
47 MULE_BACKUP([LDFLAGS])
48 MULE_APPEND([LDFLAGS], [$GEOIP_LDFLAGS])
50 AC_CHECK_HEADER([GeoIP.h], [
51 AS_IF([test x$SYS = xwin32], [
52 AC_MSG_CHECKING([for WinSock library needed by GeoIP])
53 # Actually, we might not need any if GeoIP is linked as a .dll
54 # - but that's even harder to check for
59 I do know it's not the best approach, but at least works with MinGW stock headers.
60 (tested with w32api-3.12)
64 GEOIP_WINSOCK_LIB="-lwsock32"
66 GEOIP_WINSOCK_LIB="-lws2_32"
68 AC_MSG_RESULT([$GEOIP_WINSOCK_LIB])
70 AC_CHECK_LIB([GeoIP], [GeoIP_open], [
71 AC_DEFINE([SUPPORT_GEOIP], [1], [Define if you want GeoIP support.])
73 AS_IF([test x$SYS = xwin32], [MULE_APPEND([GEOIP_LIBS], [$GEOIP_WINSOCK_LIB])])
74 MULE_APPEND([GEOIP_CPPFLAGS], [-DENABLE_IP2COUNTRY=1])
75 AC_ARG_WITH([geoip-static], AS_HELP_STRING([--with-geoip-static], [Explicitly link GeoIP statically (default=no)]),
77 AS_IF([test "$withval" != "no" -a ${enable_static:-no} = no], [
79 MULE_PREPEND([LIBS], [-Wl,-Bstatic $GEOIP_LIBS -Wl,-Bdynamic])
84 GeoIP *g = GeoIP_new(GEOIP_STANDARD);
87 GEOIP_LIBS="-Wl,-Bstatic $GEOIP_LIBS -Wl,-Bdynamic"
89 MULE_WARNING([Cannot link GeoIP statically, because your linker ($LD) does not support it.])
95 ENABLE_IP2COUNTRY=disabled
96 MULE_WARNING([GeoIP support has been disabled because the GeoIP libraries were not found])
97 ], [${GEOIP_WINSOCK_LIB:-}])
99 ENABLE_IP2COUNTRY=disabled
100 MULE_WARNING([GeoIP support has been disabled because the GeoIP header files were not found])
103 MULE_RESTORE([CPPFLAGS])
104 MULE_RESTORE([LDFLAGS])
107 AC_SUBST([GEOIP_CPPFLAGS])dnl
108 AC_SUBST([GEOIP_LDFLAGS])dnl
109 AC_SUBST([GEOIP_LIBS])dnl