--- ipv6calc-0.61.0.orig/lib/Makefile +++ ipv6calc-0.61.0/lib/Makefile @@ -11,7 +11,7 @@ # -D__EXTENSIONS__ is for Solaris & strtok_r COPTS = -O2 -Wall -D__EXTENSIONS__ -CFLAGS = $(COPTS) -I../ -I../getopt/ -I../md5/ +CFLAGS = $(COPTS) -I../ $(GETOPT_INCLUDE) -I../md5/ CC = gcc AR = ar --- ipv6calc-0.61.0.orig/lib/ipv6calcoptions.h +++ ipv6calc-0.61.0/lib/ipv6calcoptions.h @@ -35,8 +35,9 @@ * q = be more quiet * p = path to IP2Location database file * g = path to GeoIP database file + * G = enable GeoIP with a default database file */ -/*@unused@*/ static char *ipv6calc_shortopts = "vh?p:g:rmabd:iulqUFCI:O:A:"; +/*@unused@*/ static char *ipv6calc_shortopts = "vh?p:g:Grmabd:iulqUFCI:O:A:"; /* define long options */ /*@unused@*/ static struct option ipv6calc_longopts[] = { @@ -44,6 +45,7 @@ {"debug", 1, 0, (int) 'd'}, {"path", 1, 0, (int) 'p'}, {"path-geoip", 1, 0, (int) 'g'}, + {"default-geoip", 0, 0, (int) 'G'}, /* help options */ {"help", 0, 0, (int) 'h'}, --- ipv6calc-0.61.0.orig/lib/ipv6calchelp.c +++ ipv6calc-0.61.0/lib/ipv6calchelp.c @@ -239,7 +239,13 @@ fprintf(stderr, "\n"); fprintf(stderr, " --showinfo|-i [--machine_readable|-m] : show information about input data\n"); #ifdef SUPPORT_IP2LOCATION - fprintf(stderr, " [-p ] : IP2Location datafile (optional\n"); + fprintf(stderr, " [-p ] : IP2Location datafile (optional)\n"); +#endif +#ifdef SUPPORT_GEOIP + fprintf(stderr, " [-g ] : GeoIP datafile (optional)\n"); +#ifdef GEOIP_DEFAULT_FILE + fprintf(stderr, " [-G] : enable GeoIP (optional)\n"); +#endif #endif fprintf(stderr, " --showinfo|-i --show_types : show available types on '-m'\n"); fprintf(stderr, "\n"); --- ipv6calc-0.61.0.orig/ipv6calc/ipv6calc.c +++ ipv6calc-0.61.0/ipv6calc/ipv6calc.c @@ -45,8 +45,12 @@ #ifdef SUPPORT_GEOIP int use_geoip = 0; /* if set to 1, GeoIP is enabled by option(s) */ +#ifdef GEOIP_DEFAULT_FILE +char file_geoip[NI_MAXHOST] = GEOIP_DEFAULT_FILE; +#else char file_geoip[NI_MAXHOST] = ""; #endif +#endif void printversion(void) { fprintf(stderr, "%s: version %s\n", PROGRAM_NAME, PACKAGE_VERSION); @@ -143,6 +147,11 @@ #endif break; + case 'G': +#ifdef GEOIP_DEFAULT_FILE + use_geoip = 1; +#endif + break; case CMD_printexamples: command = CMD_printexamples; --- ipv6calc-0.61.0.orig/ipv6calc/Makefile.in +++ ipv6calc-0.61.0/ipv6calc/Makefile.in @@ -13,9 +13,9 @@ # Compiler and Linker Options COPTS = -O2 -Wall -g -CFLAGS = $(COPTS) -I../getopt/ -I../ -I../lib/ +CFLAGS = $(COPTS) @GETOPT_INCLUDE@ -I../ -I../lib/ -GETOBJS = ../getopt/getopt.o ../getopt/getopt1.o ../md5/md5.o +GETOBJS = @LIBOBJS@ ../md5/md5.o ifeq (@ENABLE_SUPPORT_IP2LOCATION@, 1) COPTS := $(COPTS) -DSUPPORT_IP2LOCATION @@ -25,8 +25,12 @@ ifeq (@ENABLE_SUPPORT_GEOIP@, 1) COPTS := $(COPTS) -DSUPPORT_GEOIP - CFLAGS := $(CFLAGS) -I../databases/GeoIP/GeoIP-1.3.17/libGeoIP/ - GETOBJS := $(GETOBJS) ../databases/GeoIP/GeoIP-1.3.17/libGeoIP/GeoIP.o ../databases/GeoIP/GeoIP-1.3.17/libGeoIP/GeoIPCity.o + ifeq (@ENABLE_SYSTEM_GEOIP@, 1) + GETOBJS := $(GETOBJS) -lGeoIP + else + CFLAGS := $(CFLAGS) -I../databases/GeoIP/GeoIP-1.3.17/libGeoIP/ + GETOBJS := $(GETOBJS) ../databases/GeoIP/GeoIP-1.3.17/libGeoIP/GeoIP.o ../databases/GeoIP/GeoIP-1.3.17/libGeoIP/GeoIPCity.o + endif endif CC = gcc --- ipv6calc-0.61.0.orig/configure.in +++ ipv6calc-0.61.0/configure.in @@ -27,6 +27,17 @@ AC_FUNC_MEMCMP AC_CHECK_FUNCS(strspn strstr) +dnl Check for getopt +AC_CHECK_FUNC(getopt_long, [], + [ + AC_LIBOBJ(../getopt/getopt) + AC_LIBOBJ(../getopt/getopt1) + GETOPT_INCLUDE=-I../getopt + ENABLE_BUNDLED_GETOPT=1 + ]) +AC_SUBST(GETOPT_INCLUDE) +AC_SUBST(ENABLE_BUNDLED_GETOPT) + AC_ARG_ENABLE([ip2location], AS_HELP_STRING([--enable-ip2location], [Enable IP2Location support (default: disabled)]), @@ -43,6 +54,27 @@ ENABLE_SUPPORT_GEOIP=1 AC_DEFINE(SUPPORT_GEOIP, 1, Define if you want GeoIP support.) fi]) + +AC_ARG_ENABLE([system-geoip], + AS_HELP_STRING([--enable-system-geoip], + [Use the system GeoIP library instead of the bundled one (default: bundled)]), + [if test "x$enable_system_geoip" = "xyes"; then + AC_CHECK_HEADER([GeoIP.h], [], AC_MSG_ERROR([System GeoIP library not found])) + ENABLE_SYSTEM_GEOIP=1 + ENABLE_SUPPORT_GEOIP=1 + AC_DEFINE(SUPPORT_GEOIP, 1, Define if you want to use GeoIP support.) + fi]) + +AC_ARG_ENABLE([default-geoip-file], + AS_HELP_STRING([--enable-default-geoip-file=file], + [Use a default GeoIP database file when ipv6calc is invoked with '-G']), + [if test "x$enable_default_geoip_file" != xno; then + AC_DEFINE_UNQUOTED(GEOIP_DEFAULT_FILE, "$enable_default_geoip_file", Define for a default GeoIP database file.) + ENABLE_SUPPORT_GEOIP=1 + AC_DEFINE(SUPPORT_GEOIP, 1, Define if you want to use GeoIP support.) + fi]) + AC_SUBST(ENABLE_SUPPORT_GEOIP) +AC_SUBST(ENABLE_SYSTEM_GEOIP) AC_OUTPUT([Makefile ipv6calc/Makefile man/Makefile ipv6logconv/Makefile ipv6logstats/Makefile contrib/ipv6calc.spec ipv6calcweb/ipv6calcweb.cgi ]) --- ipv6calc-0.61.0.orig/Makefile.in +++ ipv6calc-0.61.0/Makefile.in @@ -10,36 +10,42 @@ # Compiler and Linker Options COPTS = -O2 -Wall -g -CFLAGS = $(COPTS) -Igetopt/ +ifeq (@ENABLE_BUNDLED_GETOPT@, 1) + GETOPT_MAKE = getopt-make + GETOPT_DIR = getopt +endif -CC = gcc +CFLAGS = $(COPTS) -I$(GETOPT_DIR) -GETOBJS = getopt/getopt.o getopt/getopt1.o md5/md5.o +CC = gcc ifeq (@ENABLE_SUPPORT_IP2LOCATION@, 1) IP2LOCATION_MAKE = ip2location-make endif ifeq (@ENABLE_SUPPORT_GEOIP@, 1) - GEOIP_MAKE = geoip-make + ifeq (, @ENABLE_SYSTEM_GEOIP@) + GEOIP_MAKE = geoip-make + endif endif -all: md5-make getopt-make ipv6calc ipv6logconv ipv6logstats +all: md5-make $(GETOPT_MAKE) ipv6calc ipv6logconv ipv6logstats .c.o: $(CC) $(CFLAGS) -c $< -ipv6logconv: getopt-make lib-make ipv6logconv-make +ipv6logconv: $(GETOPT_MAKE) lib-make ipv6logconv-make -ipv6logstats: getopt-make lib-make ipv6logstats-make +ipv6logstats: $(GETOPT_MAKE) lib-make ipv6logstats-make -ipv6calc: getopt-make lib-make ipv6calc-make ipv6calcweb-make +ipv6calc: $(GETOPT_MAKE) lib-make ipv6calc-make ipv6calcweb-make distclean: ${MAKE} clean rm -f config.cache config.status config.log rm -rf autom4te.cache - for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 getopt databases/ieee-oui databases/ieee-iab databases/ipv4-assignment databases/ipv6-assignment databases/IP2Location/C-IP2Location-1.1.0 databases/GeoIP/GeoIP-1.3.17; do \ + + for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 $(GETOPT_DIR) databases/ieee-oui databases/ieee-iab databases/ipv4-assignment databases/ipv6-assignment databases/IP2Location/C-IP2Location-1.1.0 databases/GeoIP/GeoIP-1.3.17; do \ ocwd=`pwd`; \ cd $$dir; \ ${MAKE} $@ ; \ @@ -52,7 +58,7 @@ rm -f Makefile rm -f contrib/ipv6calc.spec rm config.h - for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 getopt; do \ + for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 $(GETOPT_DIR); do \ ocwd=`pwd`; \ cd $$dir; \ ${MAKE} $@ ; \ @@ -60,7 +66,7 @@ done clean: - for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 getopt databases/IP2Location/C-IP2Location-1.1.0 databases/GeoIP/GeoIP-1.3.17; do \ + for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 $(GETOPT_DIR) databases/IP2Location/C-IP2Location-1.1.0 databases/GeoIP/GeoIP-1.3.17; do \ ocwd=`pwd`; \ cd $$dir; \ ${MAKE} $@ ; \ @@ -72,7 +78,7 @@ ${MAKE} installonly installonly: - for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 getopt; do \ + for dir in ipv6logconv ipv6logstats ipv6calcweb ipv6calc man lib md5 $(GETOPT_DIR); do \ ocwd=`pwd`; \ cd $$dir; \ ${MAKE} install; \ @@ -86,7 +92,7 @@ cd md5 && ${MAKE} lib-make: md5-make db-ieee-oui-make db-ieee-iab-make db-ipv4-assignment-make db-ipv6-assignment-make - cd lib && ${MAKE} + cd lib && ${MAKE} GETOPT_INCLUDE=@GETOPT_INCLUDE@ ipv6logconv-make: lib-make cd ipv6logconv && ${MAKE} --- ipv6calc-0.61.0.orig/ipv6logconv/Makefile.in +++ ipv6calc-0.61.0/ipv6logconv/Makefile.in @@ -13,9 +13,9 @@ # Compiler and Linker Options COPTS = -O2 -Wall -g -D__EXTENSIONS__ -CFLAGS = $(COPTS) -I../getopt/ -I../ -I../lib/ +CFLAGS = $(COPTS) @GETOPT_INCLUDE@ -I../ -I../lib/ -GETOBJS = ../getopt/getopt.o ../getopt/getopt1.o +GETOBJS = @LIBOBJS@ CC = gcc --- ipv6calc-0.61.0.orig/ipv6logstats/Makefile.in +++ ipv6calc-0.61.0/ipv6logstats/Makefile.in @@ -13,9 +13,9 @@ # Compiler and Linker Options COPTS = -O2 -Wall -g -D__EXTENSIONS__ -CFLAGS = $(COPTS) -I../getopt/ -I../ -I../lib/ +CFLAGS = $(COPTS) @GETOPT_INCLUDE@ -I../ -I../lib/ -GETOBJS = ../getopt/getopt.o ../getopt/getopt1.o +GETOBJS = @LIBOBJS@ CC = gcc