SHELL	= /bin/sh
SRCS	= milter.c milter8.c milter_macros.c
OBJS	= milter.o milter8.o milter_macros.o
HDRS	= milter.h
TESTSRC	= 
DEFS	= -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS	= $(DEBUG) $(OPT) $(DEFS)
INCL	=
LIB	= libmilter.a
TESTPROG= milter test-milter

LIBS	= ../../$(LIB_PREFIX)global$(LIB_SUFFIX) \
	../../$(LIB_PREFIX)util$(LIB_SUFFIX)
LIB_DIR	= ../../lib
INC_DIR	= ../../include
MAKES	=

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

all: $(LIB)

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

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

test:	$(TESTPROG)

tests:

root_tests:

$(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)

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

milter:	milter.c $(LIB) $(LIBS)
	mv $@.o junk
	$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
	mv junk $@.o

test-milter: test-milter.c
	cc -g -I/usr/local/include -o $@ $? -L/usr/local/lib -lmilter -lpthread

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 | 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'
milter.o: ../../include/argv.h
milter.o: ../../include/attr.h
milter.o: ../../include/attr_override.h
milter.o: ../../include/check_arg.h
milter.o: ../../include/htable.h
milter.o: ../../include/iostuff.h
milter.o: ../../include/mail_params.h
milter.o: ../../include/mail_proto.h
milter.o: ../../include/msg.h
milter.o: ../../include/mymalloc.h
milter.o: ../../include/nvtable.h
milter.o: ../../include/rec_type.h
milter.o: ../../include/record.h
milter.o: ../../include/stringops.h
milter.o: ../../include/sys_defs.h
milter.o: ../../include/vbuf.h
milter.o: ../../include/vstream.h
milter.o: ../../include/vstring.h
milter.o: milter.c
milter.o: milter.h
milter8.o: ../../include/argv.h
milter8.o: ../../include/attr.h
milter8.o: ../../include/check_arg.h
milter8.o: ../../include/compat_va_copy.h
milter8.o: ../../include/connect.h
milter8.o: ../../include/header_opts.h
milter8.o: ../../include/htable.h
milter8.o: ../../include/iostuff.h
milter8.o: ../../include/is_header.h
milter8.o: ../../include/mail_params.h
milter8.o: ../../include/mail_proto.h
milter8.o: ../../include/mime_state.h
milter8.o: ../../include/msg.h
milter8.o: ../../include/mymalloc.h
milter8.o: ../../include/name_code.h
milter8.o: ../../include/name_mask.h
milter8.o: ../../include/nvtable.h
milter8.o: ../../include/rec_type.h
milter8.o: ../../include/record.h
milter8.o: ../../include/split_at.h
milter8.o: ../../include/stringops.h
milter8.o: ../../include/sys_defs.h
milter8.o: ../../include/vbuf.h
milter8.o: ../../include/vstream.h
milter8.o: ../../include/vstring.h
milter8.o: milter.h
milter8.o: milter8.c
milter_macros.o: ../../include/argv.h
milter_macros.o: ../../include/attr.h
milter_macros.o: ../../include/check_arg.h
milter_macros.o: ../../include/htable.h
milter_macros.o: ../../include/iostuff.h
milter_macros.o: ../../include/mail_proto.h
milter_macros.o: ../../include/msg.h
milter_macros.o: ../../include/mymalloc.h
milter_macros.o: ../../include/nvtable.h
milter_macros.o: ../../include/sys_defs.h
milter_macros.o: ../../include/vbuf.h
milter_macros.o: ../../include/vstream.h
milter_macros.o: ../../include/vstring.h
milter_macros.o: milter.h
milter_macros.o: milter_macros.c
test-milter.o: test-milter.c
