# Makefile for Qfax 1.3
# Copyright 1994, 1995 Robert LeBlanc and Renaissoft

# The directory the executables go into (e.g. /usr/local/bin, /usr/bin)
# Note: if you change this value, be sure you tell your mailer where
#       Qfax is (see INSTALL, step 3). 
BINDIR=/usr/bin

# The directory the man pages go into (e.g. /usr/man)
MANDIR=/usr/man

# The directory the documentation goes into (e.g. /usr/info/qfax)
INFODIR=/usr/info/fax

# The owner of Efax and Qfax (note: this UID must exist!)
OWNER=fax

# The group Efax and Qfax belong to (e.g. uucp)
GROUP=uucp

# Your C compiler (e.g. cc, gcc)
CC=gcc

# Any compiler flags you'd like to add (e.g. -m486, -g, -O)
CFLAGS=-m486 -O

# Any extra flags you need for the linker
LDFLAGS=

# Just in case you've got header files in a strange place
INCLS=

# ...or need extra libraries compiled in for some strange reason
LIBS=

############## End of user-configurable options ###########################

PROGS1=qfax qsend
PROGS2=qrun qstat qdel
PROGS=$(PROGS1) $(PROGS2)
MAN1=qfax.1 qrun.1 qsend.1 qstat.1 qdel.1 
MAN5=qfax.phonebook.5

.c.o:	
	$(CC) $(CFLAGS) -c $<

all:	$(PROGS)
	@cd efax07a ; make all

qfaxlib.a:	qfax.h config.h qfaxutil.c Makefile
		$(CC) $(CFLAGS) $(INCLS) -c qfaxutil.c
		ar ruv qfaxlib.a qfaxutil.o
		ranlib qfaxlib.a

qfax:	qfaxlib.a qfax.o
	$(CC) $(CFLAGS) -o qfax $(LIBS) qfax.o qfaxlib.a

qrun:	qfaxlib.a qrun.o
	$(CC) $(CFLAGS) -o qrun $(LIBS) qrun.o qfaxlib.a

qsend:	qfaxlib.a qsend.o
	$(CC) $(CFLAGS) -o qsend $(LIBS) qsend.o qfaxlib.a

qstat:	qfaxlib.a qstat.o
	$(CC) $(CFLAGS) -o qstat $(LIBS) qstat.o qfaxlib.a

qdel:	qfaxlib.a qdel.o
	$(CC) $(CFLAGS) -o qdel $(LIBS) qdel.o qfaxlib.a

efax:	config.h
	@cd efax07a ; make all

qfax.o:	qfax.c qfax.h
qrun.o:	qrun.c qfax.h
qsend.o:	qsend.c qfax.h
qstat.o:	qstat.c qfax.h
qdel.o:	qdel.c qfax.h

clean:	
	rm -f core *~ *.o *.a $(PROGS)
	@cd efax07a; make clean

install:	all
		@echo Installing binaries...
		@set -x ;for i in $(PROGS1) ; do \
		install -c -s \
                           -m 4755 \
                           -o $(OWNER) \
                           -g $(GROUP) \
                        $$i $(BINDIR) ; done
		@set -x ;for i in $(PROGS2) ; do \
		install -c -s \
			   -m 755 \
			   -o $(OWNER) \
			   -g $(GROUP) \
			$$i $(BINDIR) ; done
		@echo Installing man pages...
		@set -x ;for i in $(MAN1) ; do \
		install -c $$i $(MANDIR)/man1 ; done
		@set -x ;for i in $(MAN5) ; do \
		install -c $$i $(MANDIR)/man5 ; done
		@echo Installing docs...
		install -c -d -m 777 $(INFODIR)
		cp doc/* README* INSTALL TODO COPYING $(INFODIR)
		@echo "Installing efax..."
		@cd efax07a ; make install

############ Prepare a qfax1.2d.tar.gz distribution archive.

tgz:	
	tar -cvzf qfax1.3.tar.gz *.c *.h *.1 *.5 doc README*\
		INSTALL COPYING TODO Makefile fax.rc fax.db \
		cover-template.ps CHANGES efax07a

dist:	tgz
	uuencode qfax1.3.tar.gz qfax1.3.tar.gz > qfax1.3.dist
