SHELL	= /bin/sh
SRCS	= dns_lookup.c dns_rr.c dns_strerror.c dns_strtype.c
OBJS	= dns_lookup.o dns_rr.o dns_strerror.o dns_strtype.o
HDRS	= dns.h
TESTSRC	= test_dns_lookup.c test_alias_token.c
WARN	= -W -Wformat -Wimplicit -Wmissing-prototypes \
	-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
	-Wunused 
DEFS	= -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS	= $(DEBUG) $(OPT) $(DEFS)
INCL	=
LIB	= libdns.a
TESTPROG= test_dns_lookup
LIBS	= ../../lib/libutil.a
LIB_DIR	= ../../lib
INC_DIR	= ../../include

.c.o:;	$(CC) $(CFLAGS) -c $*.c

all: $(LIB)

Makefile: Makefile.in
	(set -e; echo "# DO NOT EDIT"; $(OPTS) $(SHELL) ../../makedefs && cat $?) >$@

test:	$(TESTPROG)

tests:	test

$(LIB):	$(OBJS)
	$(AR) $(ARFL) $(LIB) $?
	$(RANLIB) $(LIB)

$(LIB_DIR)/$(LIB): $(LIB)
	cp $(LIB) $(LIB_DIR)
	$(RANLIB) $(LIB_DIR)/$(LIB)

update: $(LIB_DIR)/$(LIB) $(HDRS)
	-for i in $(HDRS); \
	do \
	  cmp -s $$i $(INC_DIR)/$$i 2>/dev/null || cp $$i $(INC_DIR); \
	done
	cd $(INC_DIR); chmod 644 $(HDRS)

test_dns_lookup: test_dns_lookup.c $(LIB) $(LIBS)
	$(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)

printfck: $(OBJS) $(PROG)
	rm -rf printfck
	mkdir printfck
	cp *.h printfck
	sed '1,/^# do not edit/!d' Makefile >printfck/Makefile
	set -e; for i in *.c; do printfck -f .printfck $$i >printfck/$$i; done
	cd printfck; make "INC_DIR=../../../include" `cd ..; ls *.o`

lint:
	lint $(DEFS) $(SRCS) $(LINTFIX)

clean:
	rm -f *.o $(LIB) *core $(TESTPROG) junk
	rm -rf printfck

tidy:	clean

depend: $(MAKES)
	(sed '1,/^# do not edit/!d' Makefile.in; \
	set -e; for i in [a-z][a-z0-9]*.c; do \
	    $(CC) -E $(DEFS) $(INCL) $$i | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \
	    -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' -e 'p' -e '}'; \
	done) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in
	@$(EXPORT) make -f Makefile.in Makefile 1>&2

# do not edit below this line - it is generated by 'make depend'
dns_lookup.o: dns_lookup.c
dns_lookup.o: ../../include/sys_defs.h
dns_lookup.o: ../../include/mymalloc.h
dns_lookup.o: ../../include/vstring.h
dns_lookup.o: ../../include/vbuf.h
dns_lookup.o: ../../include/msg.h
dns_lookup.o: ../../include/valid_hostname.h
dns_lookup.o: ../../include/stringops.h
dns_lookup.o: dns.h
dns_rr.o: dns_rr.c
dns_rr.o: ../../include/sys_defs.h
dns_rr.o: ../../include/msg.h
dns_rr.o: ../../include/mymalloc.h
dns_rr.o: ../../include/myrand.h
dns_rr.o: dns.h
dns_rr.o: ../../include/vstring.h
dns_rr.o: ../../include/vbuf.h
dns_strerror.o: dns_strerror.c
dns_strerror.o: ../../include/sys_defs.h
dns_strerror.o: ../../include/vstring.h
dns_strerror.o: ../../include/vbuf.h
dns_strerror.o: dns.h
dns_strtype.o: dns_strtype.c
dns_strtype.o: ../../include/sys_defs.h
dns_strtype.o: ../../include/vstring.h
dns_strtype.o: ../../include/vbuf.h
dns_strtype.o: dns.h
test_dns_lookup.o: test_dns_lookup.c
test_dns_lookup.o: ../../include/sys_defs.h
test_dns_lookup.o: ../../include/vstring.h
test_dns_lookup.o: ../../include/vbuf.h
test_dns_lookup.o: ../../include/msg.h
test_dns_lookup.o: ../../include/msg_vstream.h
test_dns_lookup.o: ../../include/vstream.h
test_dns_lookup.o: dns.h
