1# -*- Autoconf -*- 2# This file is part of the aMule Project. 3# 4# Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5# 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 8# respective authors. 9# 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. 14# 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. 19# 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 23# 24 25dnl --------------------------------------------------------------------------- 26dnl MULE_CHECK_GEOIP 27dnl 28dnl Checks if the GeoIP library is requested, exists, and whether it should and 29dnl could be linked statically. 30dnl --------------------------------------------------------------------------- 31AC_DEFUN([MULE_CHECK_GEOIP], 32[ 33 MULE_ARG_ENABLE([geoip], [no], [compile with GeoIP IP2Country library]) 34 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"]) 42 43 MULE_BACKUP([CPPFLAGS]) 44 MULE_APPEND([CPPFLAGS], [$GEOIP_CPPFLAGS]) 45 MULE_BACKUP([LDFLAGS]) 46 MULE_APPEND([LDFLAGS], [$GEOIP_LDFLAGS]) 47 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 53 AC_COMPILE_IFELSE([ 54 AC_LANG_PROGRAM([[ 55 #include <GeoIP.h> 56 #ifdef _WINSOCK2_H 57 I do know it's not the best approach, but at least works with MinGW stock headers. 58 (tested with w32api-3.12) 59 #endif 60 ]]) 61 ], [ 62 GEOIP_WINSOCK_LIB="-lwsock32" 63 ], [ 64 GEOIP_WINSOCK_LIB="-lws2_32" 65 ]) 66 AC_MSG_RESULT([$GEOIP_WINSOCK_LIB]) 67 ]) 68 AC_CHECK_LIB([GeoIP], [GeoIP_open], [ 69 AC_DEFINE([SUPPORT_GEOIP], [1], [Define if you want GeoIP support.]) 70 GEOIP_LIBS="-lGeoIP" 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)]), 74 [ 75 AS_IF([test "$withval" != "no" -a ${enable_static:-no} = no], [ 76 MULE_BACKUP([LIBS]) 77 MULE_PREPEND([LIBS], [-Wl,-Bstatic $GEOIP_LIBS -Wl,-Bdynamic]) 78 AC_LINK_IFELSE([ 79 AC_LANG_PROGRAM([[ 80 #include <GeoIP.h> 81 ]], [[ 82 GeoIP *g = GeoIP_new(GEOIP_STANDARD); 83 ]]) 84 ], [ 85 GEOIP_LIBS="-Wl,-Bstatic $GEOIP_LIBS -Wl,-Bdynamic" 86 ], [ 87 MULE_WARNING([Cannot link GeoIP statically, because your linker ($LD) does not support it.]) 88 ]) 89 MULE_RESTORE([LIBS]) 90 ]) 91 ]) 92 ], [ 93 MULE_ENABLEVAR([geoip])=disabled 94 MULE_WARNING([GeoIP support has been disabled because the GeoIP libraries were not found]) 95 ], [${GEOIP_WINSOCK_LIB:-}]) 96 ], [ 97 MULE_ENABLEVAR([geoip])=disabled 98 MULE_WARNING([GeoIP support has been disabled because the GeoIP header files were not found]) 99 ]) 100 101 MULE_RESTORE([CPPFLAGS]) 102 MULE_RESTORE([LDFLAGS]) 103 ]) 104]) 105AC_SUBST([GEOIP_CPPFLAGS])dnl 106AC_SUBST([GEOIP_LDFLAGS])dnl 107AC_SUBST([GEOIP_LIBS])dnl 108