# Project    : ipv6calc
# File       : mod_ipv6calc/Makefile[.in]
# Version    : $Id: 2bc39df667e28702cef82e6db7bcf633f466d3b1 $
# Copyright  : 2015-2020 by Peter Bieringer <pb (at) bieringer.de>
#
# Information:
#  Makefile for mod_ipv6calc
#
LIBEXECDIR = @HTTPD_LIBEXECDIR@
SYSCONFDIR = @HTTPD_SYSCONFDIR@

APXS	= @APXS@

# Compiler and Linker Options
DEFAULT_CFLAGS ?= -O2 -Wall -g @CFLAGS_EXTRA@

INCLUDES= @MD5_INCLUDE@ @GETOPT_INCLUDE@ @MMDB_INCLUDE_L1@ @IP2LOCATION_INCLUDE_L1@ -I../ -I../lib/ -I../databases/lib/

LIBS = @IPV6CALC_LIB@ @IP2LOCATION_LIB_L1@ @MMDB_LIB_L1@ -lm

GETOBJS = @LIBOBJS@

LDFLAGS_EXTRA = @LDFLAGS_EXTRA_MOD_IPV6CALC@

# splint
SPLINT_OPT_OUTSIDE = -warnposix -nullassign -uniondef -compdef -usedef -formatconst -exportlocal
#SPLINT_OPT_OUTSIDE = -uniondef +matchanyintegral --nullassign +ignoresigns -compdef -usedef -modobserver -formatconst -warnposix -exportlocal
SPLINT_TODO_LATER = -unrecog  -retvalint


all:		mod_ipv6calc

libipv6calc:
		cd ../ && ${MAKE} lib-make

libipv6calc_db_wrapper:
		cd ../ && ${MAKE} lib-make

mod_ipv6calc.la: mod_ipv6calc.slo
		$(SH_LINK) -rpath $(libexecdir) -module -avoid-version  mod_ipv6calc.lo

shared =  mod_ipv6calc.la


mod_ipv6calc:	mod_ipv6calc.c ../lib/libipv6calc.h ../config.h libipv6calc libipv6calc_db_wrapper
		if test -z "$(APXS)"; then echo "no APXS found, can't build module"; exit 1; fi
		$(APXS) $(LIBS) $(INCLUDES) -c mod_ipv6calc.c $(LDFLAGS_EXTRA)

static:		

distclean:
		${MAKE} clean

autoclean:
		${MAKE} distclean

clean:
		rm -f mod_ipv6calc.o mod_ipv6calc.lo mod_ipv6calc.slo mod_ipv6calc.la .libs/*

test:		mod_ipv6calc
		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):@LD_LIBRARY_PATH_BASIC@ ./test_mod_ipv6calc.sh -K
		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):@LD_LIBRARY_PATH_BASIC@ ./test_mod_ipv6calc.sh -W
		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):@LD_LIBRARY_PATH_BASIC@ ./test_mod_ipv6calc.sh -W -P
		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):@LD_LIBRARY_PATH_BASIC@ ./test_mod_ipv6calc.sh -W -E
		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):@LD_LIBRARY_PATH_BASIC@ ./test_mod_ipv6calc.sh -W -P -E

test-minimal:	mod_ipv6calc

test-ldlibpath:	mod_ipv6calc

codecheck:
		${MAKE} splint

splint:		
		splint *.c -I.. -I../lib $(SPLINT_OPT_OUTSIDE) $(SPLINT_TODO_LATER)

$(DESTDIR)$(LIBEXECDIR):
		mkdir -p $@

$(DESTDIR)$(SYSCONFDIR):
		mkdir -p $@

install:	mod_ipv6calc $(DESTDIR)$(LIBEXECDIR) $(DESTDIR)$(SYSCONFDIR)
		if test -z "$(APXS)"; then echo "no APXS found, can't install module"; exit 1; fi
		$(APXS) -i -S LIBEXECDIR=$(DESTDIR)$(LIBEXECDIR) -n 'mod_ipv6calc' mod_ipv6calc.la
		install -m 644 ipv6calc.conf $(DESTDIR)$(SYSCONFDIR)
