#
# File:		makefile.template
# 
# Author:	Ulli Horlacher (framstag@rus.uni-stuttgart.de)
# 
# History:	12 Aug 95   Framstag	initial version (Makefile)
#               18 Sep 95   Framstag	changed to makefile.template
# 
# Makefile template for the real Makefile for the sendfile package.
# You'll need the gcc compiler.
# DO NOT CHANGE ANYTHING BEFORE THE LINE BEGINNING WITH #=== 
# 
# This file is covered by the GNU General Public License
#


make:	
	sh genmake; exec make

#============================================================================#

BIN=/usr/local/bin
MAN=/usr/local/man/man1
SERVERDIR=/usr/local/sbin


all:	sendfile sendmsg receive sendfiled
	

sendfile: sendfile.o message.o utf7.o pstring.o net.o io.o destination.o
	$(LINK) sendfile.o message.o utf7.o pstring.o net.o io.o \
	        destination.o -o sendfile
	strip sendfile

sendmsg: sendmsg.o message.o utf7.o pstring.o net.o io.o destination.o
	$(LINK) sendmsg.o message.o utf7.o pstring.o net.o io.o \
	        destination.o -o sendmsg
	strip sendmsg

receive: receive.o message.o utf7.o pstring.o string.o spool.o reply.o io.o
	$(LINK) receive.o message.o utf7.o pstring.o string.o spool.o \
	        reply.o io.o -o receive
	strip receive

sendfiled: sendfiled.o message.o utf7.o pstring.o peername.o string.o \
	   reply.o io.o spool.o
	$(LINK) sendfiled.o message.o utf7.o pstring.o peername.o string.o \
	        reply.o io.o spool.o -o sendfiled
	strip sendfiled

spoolid: spoolid.o message.o
	$(LINK) spoolid.o message.o -o spoolid

utf7: utf7.o pstring.o
	$(LINK) utf7.o pstring.o -o utf7

base64: base64.o pstring.o
	$(LINK) base64.o pstring.o -o base64


clean:	
	rm -f core *.o *~ a.out spoolid tmp* /tmp/sendfile.* sf.tgz \
	      base64 utf7 sendfile sendfiled sendmsg receive Makefile
	ln -s makefile.template Makefile

wc:
	@wc -cl sendfile.c sendfiled.c sendmsg.c receive.c string.[ch] \
	        utf7.[ch] pstring.[ch] message.[ch] peername.[ch] io.[ch] \
	        net.[ch] destination.[ch] spool.[ch] reply.[ch] config.h \
		bsd.h makefile.template genmake insserv check_sendfile \
		nosendfile
	@echo;
	@wc -cl LIESMICH* sendmsg.1 sendfile.1 receive.1 doku.fm

dis: clean
	@mkdir sendfile
	@cp sendfile.c sendfiled.c sendmsg.c receive.c string.[ch] utf7.[ch] \
	    pstring.[ch] message.[ch] peername.[ch] io.[ch] net.[ch] \
	    destination.[ch] spool.[ch] reply.[ch] config.h bsd.h \
	    sendmsg.1 sendfile.1 receive.1 *akefile* genmake insserv \
	    check_sendfile nosendfile LIESMICH* doku.ps sendfile/
	@tar cvf - sendfile | gzip > sf.tgz
	@rm -rf sendfile

floppy: clean
	(cd ..; tar cvzf /dev/fd0 sendfile)

install: all
	cp sendfile sendmsg receive check_sendfile $(BIN)
	cd $(BIN); chmod 755 sendfile sendmsg receive check_sendfile
	cp sendfile.1 sendmsg.1 receive.1 $(MAN)
	cd $(MAN); chmod 644 sendfile.1 sendmsg.1 receive.1
	sh insserv $(SERVERDIR) $(BIN)
	

sendfile.o: sendfile.c config.h
	$(CC) -c sendfile.c

sendmsg.o: sendmsg.c config.h
	$(CC) -c sendmsg.c

receive.o: receive.c config.h
	$(CC) -c receive.c

sendfiled.o: sendfiled.c reply.h bsd.h config.h
	$(CC) -c sendfiled.c

spoolid.o: spoolid.c config.h
	$(CC) -c spoolid.c

message.o: message.c message.h config.h
	$(CC) -c message.c

utf7.o: utf7.c utf7.h config.h
	$(CC) -c utf7.c

base64.o: base64.c base64.h config.h
	$(CC) -c base64.c

pstring.o: pstring.c pstring.h config.h
	$(CC) -c pstring.c

peername.o: peername.c peername.h bsd.h config.h
	$(CC) -c peername.c
	
net.o: net.c net.h io.h bsd.h config.h
	$(CC) -c net.c
	
io.o: io.c io.h config.h
	$(CC) -c io.c
	
string.o: string.c string.h config.h
	$(CC) -c string.c

destination.o: destination.c destination.h config.h
	$(CC) -c destination.c

spool.o: spool.c spool.h config.h
	$(CC) -c spool.c

reply.o: reply.c reply.h config.h
	$(CC) -c reply.c
