# Project    : ipv6calc/ipv6logstats
# File       : Makefile
# Version    : $Id: 388d5431008bd4bd661ac53e5e706bed7e95b049 $
# Copyright  : 2003-2022 by Peter Bieringer <pb (at) bieringer.de>
#
# Information:
#  Makefile for ipv6logstats
#

prefix          = @prefix@
exec_prefix     = @exec_prefix@
bindir		= @bindir@

# Compiler and Linker Options
#  -D__EXTENSIONS__ is for Solaris & strtok_r
DEFAULT_CFLAGS ?= -O2 -Wall -g @CFLAGS_EXTRA@
CFLAGS += -D__EXTENSIONS__

LDFLAGS += @LDFLAGS@

INCLUDES= $(COPTS) @MD5_INCLUDE@ @GETOPT_INCLUDE@ @MMDB_INCLUDE_L1@ @IP2LOCATION_INCLUDE_L1@ -I../ -I../lib/ -I../databases/lib/

LIBS = @IPV6CALC_LIB@ @MMDB_LIB_L1@ @IP2LOCATION_LIB_L1@ @DYNLOAD_LIB@

GETOBJS = @LIBOBJS@

CC	= @CC@

LDFLAGS_EXTRA = @LDFLAGS_EXTRA@
LDFLAGS_EXTRA_STATIC = @LDFLAGS_EXTRA_STATIC@

OBJS	= ipv6logstats.o ipv6logstatshelp.o

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

all:		ipv6logstats

.c.o:
		$(CC) -c $< $(DEFAULT_CFLAGS) $(CFLAGS) $(INCLUDES)

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

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

$(OBJS):	ipv6logstatsoptions.h ipv6logstatshelp.h ipv6logstats.h

ipv6logstats:	$(OBJS) libipv6calc.a libipv6calc_db_wrapper.a
		$(CC) -o ipv6logstats $(OBJS) $(GETOBJS) $(LDFLAGS) $(LIBS) $(LDFLAGS_EXTRA) -lm

static:		ipv6logstats
		$(CC) -o ipv6logstats-static $(OBJS) $(GETOBJS) $(LDFLAGS) $(LIBS) $(LDFLAGS_EXTRA_STATIC) -lm -static

distclean:
		${MAKE} clean

autoclean:
		${MAKE} distclean

clean:
		rm -f ipv6logstats ipv6logstats-static *.o

test:		ipv6logstats
		LD_LIBRARY_PATH=@LD_LIBRARY_PATH@ ./test_ipv6logstats.sh

test-minimal:
		${MAKE} test

test-ldlibpath:	ipv6logstats
		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):@LD_LIBRARY_PATH_BASIC@ ./test_ipv6logstats.sh

codecheck:
		${MAKE} splint
	
splint:
		splint *.c ../lib/*.c -I.. -I../lib $(SPLINT_OPT_OUTSIDE) $(SPLINT_TODO_LATER)

install:
		mkdir -p $(DESTDIR)$(bindir)
		install -m 755 ipv6logstats $(DESTDIR)$(bindir)

