# Makefile,v 1.2 1997/07/02 18:48:07 woods Exp
#-------------------------------------------------------------------------
#  TULP - Unix Mailing List manager (sub-set of FRECP's
#         Bitnet Listserv tool).
#
#  Copyright (C) 1991-1994  Kimmo Suominen, Christophe Wolfhugel
#
#  Please read the files COPYRIGHT and AUTHORS for the extended
#  copyrights refering to this file.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 1, or (at your option)
#  any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#----------------------------------------------------------------------
#
# Generic flags
CC	=       cc

OPTIM	=#	-O
DEBUG	=	-g

# AIX does not require any special LIB. Use the standard cc also.
#
# Apple A/UX 3 (junk Unix) needs Posix options and you'll have to replace
# a u_int by unsigned int in popen.c, I forgot that on the patch. Another
# good solution would be to get a real Unix system.
#CFLAGS =	-ZP
#
# On HP-UX
#CFLAGS	=	-Aa -D_HPUX_SOURCE -O
#
CFLAGS	=       $(OPTIM) $(DEBUG) $(CPPFLAGS) $(INCDIRS)
LDFLAGS	=	$(OPTIM) $(DEBUG) $(LIBDIRS)

# SVR4 requires following libraries
#
#LIBS	=	-lsocket -lnsl

# Directory where the binaries and other stuff will reside
QUEUE_DIR =	/local/var/spool/tulp-queue
ETCDIR	=	/local/etc/listserv
SBINDIR	=	/local/sbin
EXECDIR	=	/local/libexec
MAN5	=	/local/share/man/man5
MAN8	=	/local/share/man/man8

LISTSERV =	tulp-listserv
ENQUEUE	=	tulp-enqueue
FILTER	=	tulp-filter

# what becomes the FILTER?
#DELIVER =	deliver
DELIVER =	deliver.pl

# User and group to whome INSTDIR should belong, USER must be the
# user under which TULP will be running.
USER	=	listserv
GROUP	=	listserv

# Path to your system's Berkeley install program 
#INSTALL =	/usr/ucb/install	# AIX3, ...
#INSTALL =	installbsd		# DEC OSF/1
INSTALL	=	/usr/bin/install

#---- Stop you should not need to modify anything below ---

EXE	=	$(LISTSERV) $(ENQUEUE) $(FILTER)
UTILS	=	Makefile
#
SRC	=	l.c lc.c lp.c str.c ad.c vers.c fakesyslog.c popen.c daemon.c queue.c
OBJ1	=	l.o lc.o lp.o str.o ad.o vers.o fakesyslog.o popen.o daemon.o
OBJ2	=	queue.o fakesyslog.o
INC	=	conf.h ext.h ad.h fakesyslog.h l.h lc.h lp.h popen.h str.h

# Standard targets

all: $(LISTSERV) $(ENQUEUE) $(FILTER)

$(LISTSERV): $(OBJ1)
	$(CC) $(LDFLAGS) -o $@ $(OBJ1) $(LIBS)

$(ENQUEUE): $(OBJ2)
	$(CC) $(LDFLAGS) -o $@ $(OBJ2) $(LIBS)

$(FILTER): $(DELIVER)
	cp $(DELIVER) $@
	chmod +x $@

lint:
	lint $(SRC)

install: $(LISTSERV) $(ENQUEUE) $(FILTER) tulp.5 tulp.8
	-mkdir $(QUEUE_DIR)
	-chown $(USER).$(GROUP) $(QUEUE_DIR)
	-chmod 770 $(QUEUE_DIR)
	-mkdir $(ETCDIR)
	-chown $(USER).$(GROUP) $(ETCDIR)
	-chmod 775 $(ETCDIR)
	@if [ ! -f $(ETCDIR)/lists ] ; then \
	  echo '$(INSTALL) -g $(GROUP) -o $(USER) -m 664 lists $(ETCDIR)'; \
	  $(INSTALL) -g $(GROUP) -o $(USER) -m 664 lists $(ETCDIR); \
	fi
	@if [ ! -f $(ETCDIR)/test.u ] ; then \
	  echo '$(INSTALL) -g $(GROUP) -o $(USER) -m 664 test.u $(ETCDIR)'; \
	  $(INSTALL) -g $(GROUP) -o $(USER) -m 664 test.u $(ETCDIR); \
	fi
	@if [ ! -f $(ETCDIR)/test.w ] ; then \
	  echo '$(INSTALL) -g $(GROUP) -o $(USER) -m 444 test.w $(ETCDIR)'; \
	  $(INSTALL) -g $(GROUP) -o $(USER) -m 444 test.w $(ETCDIR); \
	fi
	@if [ ! -f $(ETCDIR)/test.n ] ; then \
	  echo '$(INSTALL) -g $(GROUP) -o $(USER) -m 644 /dev/null $(ETCDIR)/test.n'; \
	  $(INSTALL) -g $(GROUP) -o $(USER) -m 644 /dev/null $(ETCDIR)/test.n; \
	fi
	$(INSTALL) -g bin -o bin -m 444 helpfile $(ETCDIR)
	$(INSTALL) -g bin -o bin -m 555 $(LISTSERV) $(SBINDIR)
	$(INSTALL) -g $(GROUP) -o $(USER) -m 4511 $(ENQUEUE) $(EXECDIR)
	$(INSTALL) -g bin -o bin -m 555 $(FILTER) $(EXECDIR)
	$(INSTALL) -g bin -o bin -m 444 tulp.5 $(MAN5)
	$(INSTALL) -g bin -o bin -m 444 tulp.8 $(MAN8)

clean:
	rm -f $(EXE) $(OBJ1) $(OBJ2)

# Dependencies

ad.o: conf.h ext.h internal.h
fakesyslog.o: conf.h fakesyslog.h internal.h
queue.o: conf.h internal.h fakesyslog.h
l.o: conf.h ext.h lp.h str.h popen.h ad.h lc.h fakesyslog.h internal.h
lc.o: conf.h ext.h l.h lp.h messages.h str.h popen.h fakesyslog.h internal.h
lp.o: conf.h ext.h str.h fakesyslog.h internal.h
popen.o: conf.h fakesyslog.h internal.h
daemon.o: conf.h
str.o: conf.h internal.h
vers.o: conf.h internal.h
