###################################################
# Sample Makefile for mail archive maintenance.
#
#  Define variables and Macros
#
###################################################

prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
SUFFIX=@suffix@

#WNOERROR=-Werror
#WARNINGS=$(WNOERROR) -ansi -pedantic -Wall -Wtraditional -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Dlint

CC=@CC@ $(WARNINGS)
CFLAGS=@CFLAGS@
INSTALL_PROG=@INSTALL@

###################################################
#
#  Build the executable images
#
###################################################
#
# List should contain your listnames. All standard names are derived
#	from that base name. 
#  	lists.h needs to check the macro LIST_<basename> 
#
# PLEASE read the README in this directory before continuing.

LISTS = htest 
# LISTS = testmailman polis

# two progs for each list ending with "-mail" and "-rdmsg"
PROGS= $(LISTS:%=%-mail$(SUFFIX)) $(LISTS:%=%-rdmsg$(SUFFIX))

all: $(PROGS) 


#using static pattern rules for this special situation
$(LISTS:%=%-mail$(SUFFIX)): %-mail: msg2archive.c lists.h
	$(CC) $(CFLAGS) -DLIST_$(subst -,_,$*) -o $@ msg2archive.c

$(LISTS:%=%-rdmsg$(SUFFIX)): %-rdmsg: mbox2hypermail.c lists.h
	$(CC) $(CFLAGS) -DLIST_$(subst -,_,$*) -o $@ mbox2hypermail.c


########################################
#
#       Commands
#
########################################

lint:
	lint $(LINT_FLAGS) $(SOURCE) | tee Lint.out

BINARIES=$(PROGS:%=$(bindir)/%)

install: $(PROGS)
	@if [ ! -d $(bindir) ]; then mkdir -p $(bindir); fi
	@for i in $?; do \
		echo $(INSTALL_PROG) -c $$i $(bindir); \
		$(INSTALL_PROG) -c $$i $(bindir); \
	done

clean: 
	rm -f $(OBJS) Lint.out
	rm -f $(PROGS)


uninstall:
	rm -f $(BINARIES)

###################################################
#
#    Object file include dependencies.
#    The object file include dependencies are required.
#
###################################################

depend:
	makedepend -- $(CFLAGS) -- $(SOURCE)

# DO NOT DELETE THIS LINE -- make depend depends on it.

