prefix=@prefix@
exec_prefix=@exec_prefix@
sbindir=@sbindir@
mandir=@mandir@
sysconfdir=@sysconfdir@
varrun=/var/run/bld

CC= @CC@
PROGNAME= bld
READERNAME= $(PROGNAME)read
SUBMITNAME= $(PROGNAME)submit
QUERYNAME= $(PROGNAME)query
INSERTNAME= $(PROGNAME)insert
DECRNAME= $(PROGNAME)decr
POLICYNAME= $(PROGNAME)-pf_policy
UTILS=utils/bld-mrtg.pl utils/bld-pf_log.pl utils/bld-will_spam_for_food.pl \
	utils/bld-pf_policy.pl
CFLAGS= @CFLAGS@ -DPROGNAME=\"$(PROGNAME)\" -DVARRUN=\"$(varrun)\" -DETC_LOCATION=\"$(sysconfdir)\"
OBJS= main.o net.o cmd.o iptree.o daemon.o netlist.o utils.o parse_args.o \
      parse_config.o options.o client.o
LDFLAGS= @LDFLAGS@
LIBS= @LIBS@
GZIP= gzip -c -9

all: $(PROGNAME) $(READERNAME) $(SUBMITNAME) $(POLICYNAME)

$(PROGNAME): $(OBJS)
	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
$(READERNAME): dumpread.o
	$(CC) -o $@ dumpread.o
$(SUBMITNAME): submit.o net.o client.o utils.o options.o netlist.o
	$(CC) -o $@ $(LDFLAGS) submit.o net.o client.o utils.o options.o \
		netlist.o $(LIBS)
$(POLICYNAME): postfix_policy.o net.o client.o
	$(CC) -o $@ $(LDFLAGS) postfix_policy.o net.o client.o $(LIBS)

links: $(SUBMITNAME)
	-ln -sf $(SUBMITNAME) $(QUERYNAME)
	-ln -sf $(SUBMITNAME) $(INSERTNAME)
	-ln -sf $(SUBMITNAME) $(DECRNAME)

submit.o: submit.c net.h

install: all
	[ -d $(DESTDIR)$(sbindir) ] || mkdir -p $(DESTDIR)$(sbindir)
	cp $(PROGNAME) $(READERNAME) $(POLICYNAME) $(UTILS) $(DESTDIR)$(sbindir)
	strip $(DESTDIR)$(sbindir)/$(PROGNAME)
	strip $(DESTDIR)$(sbindir)/$(READERNAME)
	strip $(DESTDIR)$(sbindir)/$(POLICYNAME)
	cp $(SUBMITNAME) $(DESTDIR)$(sbindir) \
	    && (cd $(DESTDIR)$(sbindir) && ln -s $(SUBMITNAME) $(QUERYNAME)) \
	    && (cd $(DESTDIR)$(sbindir) && ln -s $(SUBMITNAME) $(INSERTNAME)) \
	    && (cd $(DESTDIR)$(sbindir) && ln -s $(SUBMITNAME) $(DECRNAME))
	strip $(DESTDIR)$(sbindir)/$(SUBMITNAME)
	cp utils/bld-pf_policy.pl $(DESTDIR)/$(sbindir)
	cp utils/bld-pf_log.pl $(DESTDIR)/$(sbindir)
	[ -d $(DESTDIR)$(sysconfdir) ] || mkdir -p $(DESTDIR)$(sysconfdir)
	cp bld.conf.sample $(DESTDIR)/$(sysconfdir)
	[ -d $(DESTDIR)$(mandir)/man8 ] || mkdir -p $(DESTDIR)$(mandir)/man8
	$(GZIP) -c bld.8 > $(DESTDIR)$(mandir)/man8/bld.8.gz
	$(GZIP) -c bldread.8 > $(DESTDIR)$(mandir)/man8/bldread.8.gz
	$(GZIP) -c bldquery.8 > $(DESTDIR)$(mandir)/man8/bldquery.8.gz
	$(GZIP) -c bldsubmit.8 > $(DESTDIR)$(mandir)/man8/bldsubmit.8.gz
	$(GZIP) -c bldinsert.8 > $(DESTDIR)$(mandir)/man8/bldinsert.8.gz
	$(GZIP) -c blddecr.8 > $(DESTDIR)$(mandir)/man8/blddecr.8.gz
	$(GZIP) -c bld-pf_policy.8 > $(DESTDIR)$(mandir)/man8/bld-pf_policy.8.gz
	[ -d $(DESTDIR)$(mandir)/man5 ] || mkdir -p $(DESTDIR)$(mandir)/man5
	$(GZIP) -c bld.conf.5 > $(DESTDIR)$(mandir)/man5/bld.conf.5.gz
	$(GZIP) -c bld_acl.conf.5 > $(DESTDIR)$(mandir)/man5/bld_acl.conf.5.gz
	$(GZIP) -c bld_whitelist.conf.5 > $(DESTDIR)$(mandir)/man5/bld_whitelist.conf.5.gz
	$(GZIP) -c utils/bld-pf_log.pl.8 > $(DESTDIR)$(mandir)/man8/bld-pf_log.pl.8.gz
	$(GZIP) -c utils/bld-mrtg.pl.8 > $(DESTDIR)$(mandir)/man8/bld-mrtg.pl.8.gz
	$(GZIP) -c utils/bld-will_spam_for_food.pl.8 > $(DESTDIR)$(mandir)/man8/bld-will_spam_for_food.pl.8.gz


client.o: client.c options.h netlist.h client.h cmd.h iptree.h utils.h \
 net.h
cmd.o: cmd.c options.h netlist.h cmd.h iptree.h ipinfo.h utils.h \
 client.h
daemon.o: daemon.c options.h netlist.h daemon.h
dumpread.o: dumpread.c ipinfo.h
iptree.o: iptree.c ipinfo.h iptree.h options.h netlist.h
main.o: main.c options.h netlist.h parse_args.h parse_config.h net.h \
 cmd.h iptree.h daemon.h utils.h
net.o: net.c net.h
netlist.o: netlist.c netlist.h utils.h
options.o: options.c options.h netlist.h
parse_args.o: parse_args.c options.h netlist.h utils.h parse_args.h
parse_config.o: parse_config.c utils.h options.h netlist.h
postfix_policy.o: postfix_policy.c client.h cmd.h iptree.h options.h \
 netlist.h
submit.o: submit.c options.h netlist.h net.h client.h cmd.h iptree.h
utils.o: utils.c utils.h


clean:
	-rm -f $(PROGNAME) $(READERNAME) $(SUBMITNAME) $(DECRNAME) \
	$(POLICYNAME) $(OBJS) dumpread.o submit.o postfix_policy.o core

distclean: clean
	-rm -f *~ Makefile config.status config.log config.cache config.h \
	$(READERNAME) $(SUBMITNAME) $(QUERYNAME) $(INSERTNAME) $(DECRNAME) \
	$(POLICYNAME) bld.8 bld_acl.conf.5 bld_whitelist.conf.5 bld.conf.5
	-rm -rf autom4te.cache bld.8.html
	-rm -rf mktest/Makefile mktest/config.h mktest/mktest.log \
		mktest/bld_iplist.txt mktest/bld_blacklist.txt \
		mktest/bld_iplist.dump mktest/bld_blacklist.dump



syntax highlighted by Code2HTML, v. 0.9.1