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 MULE_ARG_ENABLE([geoip], [no], [compile with GeoIP IP2Country library])
35 MULE_IF_ENABLED([geoip], [
36 AC_ARG_WITH([geoip-headers],
37 AS_HELP_STRING([--with-geoip-headers=DIR], [GeoIP include files location]),
38 [GEOIP_CPPFLAGS="-I$withval"])
39 AC_ARG_WITH([geoip-lib],
40 AS_HELP_STRING([--with-geoip-lib=DIR], [GeoIP library location]),
41 [GEOIP_LDFLAGS="-L$withval"])
43 MULE_BACKUP([CPPFLAGS])
44 MULE_APPEND([CPPFLAGS], [$GEOIP_CPPFLAGS])
45 MULE_BACKUP([LDFLAGS])
46 MULE_APPEND([LDFLAGS], [$GEOIP_LDFLAGS])
48 AC_CHECK_HEADER([GeoIP.h], [
49 AS_IF([test x$SYS = xwin32], [
50 AC_MSG_CHECKING([for WinSock library needed by GeoIP])
51 # Actually, we might not need any if GeoIP is linked as a .dll
52 # - but that's even harder to check for
57 I do know it's not the best approach, but at least works with MinGW stock headers.
58 (tested with w32api-3.12)
62 GEOIP_WINSOCK_LIB="-lwsock32"
64 GEOIP_WINSOCK_LIB="-lws2_32"
66 AC_MSG_RESULT([$GEOIP_WINSOCK_LIB])
68 AC_CHECK_LIB([GeoIP], [GeoIP_open], [
69 AC_DEFINE([SUPPORT_GEOIP], [1], [Define if you want GeoIP support.])
71 AS_IF([test x$SYS = xwin32], [MULE_APPEND([GEOIP_LIBS], [$GEOIP_WINSOCK_LIB])])
72 MULE_APPEND([GEOIP_CPPFLAGS], [-DENABLE_IP2COUNTRY=1])
73 AC_ARG_WITH([geoip-static], AS_HELP_STRING([--with-geoip-static], [Explicitly link GeoIP statically (default=no)]),
75 AS_IF([test "$withval" != "no" -a ${enable_static:-no} = no], [
77 MULE_PREPEND([LIBS], [-Wl,-Bstatic $GEOIP_LIBS -Wl,-Bdynamic])
82 GeoIP *g = GeoIP_new(GEOIP_STANDARD);
85 GEOIP_LIBS="-Wl,-Bstatic $GEOIP_LIBS -Wl,-Bdynamic"
87 MULE_WARNING([Cannot link GeoIP statically, because your linker ($LD) does not support it.])
93 MULE_ENABLEVAR([geoip])=disabled
94 MULE_WARNING([GeoIP support has been disabled because the GeoIP libraries were not found])
95 ], [${GEOIP_WINSOCK_LIB:-}])
97 MULE_ENABLEVAR([geoip])=disabled
98 MULE_WARNING([GeoIP support has been disabled because the GeoIP header files were not found])
101 MULE_RESTORE([CPPFLAGS])
102 MULE_RESTORE([LDFLAGS])
105 AC_SUBST([GEOIP_CPPFLAGS])dnl
106 AC_SUBST([GEOIP_LDFLAGS])dnl
107 AC_SUBST([GEOIP_LIBS])dnl