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

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

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

$(TESTPROG):	$(OBJS) fake_strcmp.o $(LIBS)
	$(CC) $(CFLAGS) $(SHLIB_RPATH) -o $@ $(OBJS) fake_strcmp.o $(LIBS) $(SYSLIBS)

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

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

test:	$(TESTPROG)

tests: single_test json_tests config_dir_test

# Single instance, original output format.
single_test: $(TESTPROG)
	@echo RUN single_test
	rm -f main.cf single_test.tmp
	echo config_directory = . >>main.cf
	echo command_directory = ../../bin >> main.cf
	echo daemon_directory = ../../libexec >> main.cf
	echo meta_directory = . >> main.cf
	echo shlib_directory = ../../lib >> main.cf
	touch -t 197101010000 main.cf
	printf "%-15s %-15s %-9s %s\n" - - y . >single_test.tmp
	MAIL_CONFIG=. $(SHLIB_ENV) ${VALGRIND} \
	    ./$(TESTPROG) -l | diff single_test.tmp -
	rm -f main.cf single_test.tmp
	@echo PASS single_test; echo 

json_tests: json_single_test

# Single instance, JSON output format.
json_single_test: $(TESTPROG)
	@echo RUN json_single_test
	rm -f main.cf json_single_test.tmp
	echo config_directory = . >>main.cf
	echo command_directory = ../../bin >> main.cf
	echo daemon_directory = ../../libexec >> main.cf
	echo meta_directory = . >> main.cf
	echo shlib_directory = ../../lib >> main.cf
	touch -t 197101010000 main.cf
	echo "{\"name\": \"-\",\"group\": \"-\",\"enabled\": \"y\",\"config_directory\": \".\"}" >> json_single_test.tmp
	MAIL_CONFIG=. $(SHLIB_ENV) ${VALGRIND} \
	    ./$(TESTPROG) -lj | diff json_single_test.tmp -
	rm -f main.cf json_single_test.tmp
	@echo PASS json_single_test; echo

# Reject non-default config_directory.
config_dir_test:  $(PROG)
	@echo RUN config_dir_test
	rm -f main.cf config_dir_test.tmp
	echo config_directory = . >>main.cf
	echo command_directory = ../../bin >> main.cf
	echo daemon_directory = ../../libexec >> main.cf
	echo meta_directory = . >> main.cf
	echo shlib_directory = ../../lib >> main.cf
	touch -t 197101010000 main.cf
	echo "postmulti: fatal: Non-default configuration directory: MAIL_CONFIG=." > config_dir_test.tmp
	(MAIL_CONFIG=. $(SHLIB_ENV) ${VALGRIND} ./$(PROG) -l 2>&1 || exit 0) \
	    | diff config_dir_test.tmp -
	rm -f config_dir_test.tmp
	@echo PASS config_dir_test; echo

root_tests:

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

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

clean:
	rm -f *.o *core $(PROG) $(TESTPROG) $(TESTOBJ) *.tmp main.cf junk

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'
fake_strcmp.o: ../../include/mail_params.h
fake_strcmp.o: ../../include/msg.h
fake_strcmp.o: ../../include/sys_defs.h
fake_strcmp.o: fake_strcmp.c
postmulti.o: ../../include/argv.h
postmulti.o: ../../include/check_arg.h
postmulti.o: ../../include/clean_env.h
postmulti.o: ../../include/htable.h
postmulti.o: ../../include/mail_conf.h
postmulti.o: ../../include/mail_params.h
postmulti.o: ../../include/mail_parm_split.h
postmulti.o: ../../include/mail_version.h
postmulti.o: ../../include/maillog_client.h
postmulti.o: ../../include/msg.h
postmulti.o: ../../include/msg_vstream.h
postmulti.o: ../../include/mymalloc.h
postmulti.o: ../../include/name_code.h
postmulti.o: ../../include/ring.h
postmulti.o: ../../include/safe.h
postmulti.o: ../../include/stringops.h
postmulti.o: ../../include/sys_defs.h
postmulti.o: ../../include/vbuf.h
postmulti.o: ../../include/vstream.h
postmulti.o: ../../include/vstring.h
postmulti.o: ../../include/vstring_vstream.h
postmulti.o: ../../include/warn_stat.h
postmulti.o: postmulti.c
