# Copyright 2000, 2001, 2003, 2006-2012  Nominum, Inc.  All Rights Reserved.

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
datarootdir = @datarootdir@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ 
INSTALL_DATA = @INSTALL_DATA@ 
RANLIB = @RANLIB@

CC = @PTHREAD_CC@
CFLAGS = @CFLAGS@ @DNSCFLAGS@ @DEFS@ @PTHREAD_CFLAGS@
LIBS = libperf.a @LIBS@ @DNSLIBS@ @PTHREAD_LIBS@ -lm
LIBOBJS = @LIBOBJS@
LDFLAGS = @LDFLAGS@ @PTHREAD_CFLAGS@

PERFOBJS = datafile.o dns.o log.o net.o opt.o os.o

all: dnsperf resperf

libperf.a: ${PERFOBJS}
	${AR} ${ARFLAGS} $@ ${PERFOBJS}
	${RANLIB} $@

dnsperf: dnsperf.o libperf.a $(LIBOBJS)
	$(CC) $(LDFLAGS) dnsperf.o $(LIBOBJS) $(LIBS) -o dnsperf

resperf: resperf.o libperf.a $(LIBOBJS)
	$(CC) $(LDFLAGS) resperf.o $(LIBOBJS) $(LIBS) -o resperf

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

installdirs:
	mkdir -p ${DESTDIR}${bindir}
	mkdir -p ${DESTDIR}${mandir}/man1

install: all installdirs
	${INSTALL_PROGRAM} dnsperf ${DESTDIR}${bindir}
	${INSTALL_PROGRAM} resperf ${DESTDIR}${bindir}
	${INSTALL_PROGRAM} resperf-report ${DESTDIR}${bindir}
	${INSTALL_DATA} dnsperf.1 ${DESTDIR}${mandir}/man1
	${INSTALL_DATA} resperf.1 ${DESTDIR}${mandir}/man1

clean:
	rm -f *.o dnsperf resperf libperf.a

distclean: clean
	rm -f config.log
	rm -f config.cache
	rm -f config.status
	rm -f Makefile
