SHELL	= /bin/sh
SRCS	= postmap.c 
OBJS	= postmap.o
HDRS	= 
TESTSRC	= 
DEFS	= -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS	= $(DEBUG) $(OPT) $(DEFS)
TESTPROG= 
PROG	= postmap
INC_DIR	= ../../include
LIBS	= ../../lib/lib$(LIB_PREFIX)global$(LIB_SUFFIX) \
	../../lib/lib$(LIB_PREFIX)util$(LIB_SUFFIX)

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

$(PROG):	$(OBJS) $(LIBS)
	$(CC) $(CFLAGS) $(SHLIB_RPATH) -o $@ $(OBJS) $(LIBS) $(SYSLIBS)

$(OBJS): ../../conf/makedefs.out

Makefile: Makefile.in
	cat ../../conf/makedefs.out $? >$@

update: ../../bin/$(PROG)

../../bin/$(PROG): $(PROG)
	cp $(PROG) ../../bin

tests:	test1 test2 fail_test quote_test

root_tests:

test1:	$(PROG) map.in map-abc1.ref map-ghi1.ref map-uABC1.ref
	$(SHLIB_ENV) ./$(PROG) map.in
	for key in abc ghi; \
	do \
	    $(SHLIB_ENV) ./$(PROG) -q $${key} map.in | diff map-$${key}1.ref -; \
	done
	$(SHLIB_ENV) ./$(PROG) -f map.in
	for key in ABC; \
	do \
	    $(SHLIB_ENV) ./$(PROG) -fq $${key} map.in | diff map-u$${key}1.ref -; \
	done
	rm -f map.in.db

test2:	$(PROG) map.in map-abc2.ref map-ghi2.ref map-uABC2.ref
	$(SHLIB_ENV) ./$(PROG) map.in
	for key in abc ghi; \
	do \
	    echo $${key} | $(SHLIB_ENV) ./$(PROG) -q - map.in | diff map-$${key}2.ref -; \
	done
	$(SHLIB_ENV) ./$(PROG) -f map.in
	for key in ABC; \
	do \
	    echo $${key} | $(SHLIB_ENV) ./$(PROG) -fq - map.in | diff map-u$${key}2.ref -; \
	done
	rm -f map.in.db

fail_test: $(PROG) aliases fail_test.in fail_test.ref
	-($(SHLIB_ENV) sh fail_test.in || exit 0) 2>&1 | \
	    sed -e 's/No error:/Unknown error:/' \
		-e 's/Success/Unknown error: 0/' > fail_test.tmp
	diff fail_test.ref fail_test.tmp
	rm -f fail_test.tmp

quote_test: $(PROG) aliases quote_test.in quote_test.ref
	rm -f quote_test_map.*
	$(SHLIB_ENV) sh quote_test.in >quote_test.tmp 2>&1
	diff quote_test.ref quote_test.tmp
	rm -f quote_test.tmp quote_test_map.*

printfck: $(OBJS) $(PROG)
	rm -rf printfck
	mkdir 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 *core $(PROG) $(TESTPROG) *.tmp junk *.db
	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 | grep -v '[<>]' | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \
	    -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' \
	    -e 's/o: \.\//o: /' -e p -e '}' ; \
	done | LANG=C sort -u) | 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'
postmap.o: ../../include/argv.h
postmap.o: ../../include/check_arg.h
postmap.o: ../../include/clean_env.h
postmap.o: ../../include/dict.h
postmap.o: ../../include/dict_proxy.h
postmap.o: ../../include/header_opts.h
postmap.o: ../../include/mail_conf.h
postmap.o: ../../include/mail_dict.h
postmap.o: ../../include/mail_params.h
postmap.o: ../../include/mail_parm_split.h
postmap.o: ../../include/mail_task.h
postmap.o: ../../include/mail_version.h
postmap.o: ../../include/mime_state.h
postmap.o: ../../include/mkmap.h
postmap.o: ../../include/msg.h
postmap.o: ../../include/msg_syslog.h
postmap.o: ../../include/msg_vstream.h
postmap.o: ../../include/myflock.h
postmap.o: ../../include/mymalloc.h
postmap.o: ../../include/readlline.h
postmap.o: ../../include/rec_type.h
postmap.o: ../../include/set_eugid.h
postmap.o: ../../include/split_at.h
postmap.o: ../../include/stringops.h
postmap.o: ../../include/sys_defs.h
postmap.o: ../../include/vbuf.h
postmap.o: ../../include/vstream.h
postmap.o: ../../include/vstring.h
postmap.o: ../../include/vstring_vstream.h
postmap.o: ../../include/warn_stat.h
postmap.o: postmap.c
