#
#  Makefile for faces, an icon face server, plus associated software.
#
#  Graphical versions for NeWS, SunView, X11 and XView.
#
#  @(#)Makefile 1.15 90/06/29
#
#  Copyright (c) Rich Burridge.
#                Sun Microsystems, Australia - All rights reserved.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged. 
#
#  No responsibility is taken for any errors inherent either
#  to the comments or the code of this program, but if reported
#  to me then an attempt will be made to fix them.
#
#========================================================================
#
#  There are various small changes needed when compiling faces on
#  different systems.  These have been isolated here, and should be
#  uncommented and set accordingly, if needed.
#
#========================================================================
#  Faces displays a background pattern in its' window. When the window
#  is not completely full, this gives the appearance of trying to blend
#  in with the background. By default, this is a root gray color, but you
#  can specify an alternate pattern to use here.
#
#BACKGROUND       = -DBACKGROUND=\"\"
#------------------------------------------------------------------------
#  If you do not want to show the number of messages on the face icon,
#  then uncomment the next line.
# 
#DONTSHOWNO       = -DDONTSHOWNO
#------------------------------------------------------------------------
#  If you do not want to show the timestamp on the face icon, then
#  uncomment the next line.
#
#DONTSHOWTIME     = -DDONTSHOWTIME
#------------------------------------------------------------------------
#  If you do not want to show the username on the face icon, then
#  uncomment the next line.
#
#DONTSHOWUSER     = -DDONTSHOWUSER
#------------------------------------------------------------------------
#  By default, faces looks for the face images in /usr/local/faces. If
#  you wish to specify an alternate location, then these two lines should
#  be uncommented and set appropriately.
#               
FACEDIR           = /usr/local/faces
CFACEDIR	= -DFACEDIR=\"$(FACEDIR)\"
#------------------------------------------------------------------------
#  It is possible to determine what type of monitoring faces does at
#  run time with different command line options, but it is also possible
#  to define it at compile time.
#
#  Monitor type (0 = mail (all),  1 = mail (new), 2 = print queue).
#                3 = custom prog, 4 = users).
#
#FMONTYPE         = -DFMONTYPE=1
#------------------------------------------------------------------------
#  Some users on monochrome screens display everything in reverse video.
#  If you would like faces to do the same, then this line needs to be
#  uncommented.
#
#INVERT           = -DINVERT
#------------------------------------------------------------------------
#  If you are compiling the NeWS version, then the following two lines
#  should be uncommented, and set appropriately.
#
#NEWSINCDIR	= -I$(OPENWINHOME)/include
#NEWSLIBDIR	= -L$(OPENWINHOME)/lib
#------------------------------------------------------------------------
#  If you don't want faces to use full domain names for extracting face
#  icons, then you should uncomment the NODOMAINS definition below.
#
#NODOMAINS	= -DNODOMAINS
#------------------------------------------------------------------------
#  By default, faces will check the "From " line first for username and
#  hostname, and then the "From:" line. 
#  Not all machines have the index() string library function. If you
#  don't have this function then you should uncomment the NOINDEX
#  definition below.
#
#NOINDEX         = -DNOINDEX
#--------------------------------------------------------------------------
#  By default, faces rechecks for new mail or print jobs every sixty
#  seconds. If you would like to specify an alternate period, then uncomment
#  the following line and set appropriately.
#
#PERIOD           = -DPERIOD=30
#------------------------------------------------------------------------
#  Faces is designed to work on a big-endian machine by default. If you
#  are compiling for a little-endian machine (such as the Sun 386i), then
#  you need to uncomment the following line.
#
#REVORDER	  = -DREVORDER
#------------------------------------------------------------------------
#  If you not running under a BSD4.3 derived system, the parameters
#  to the select call are different, and this definition should be
#  uncommented. You need to uncomment this for SunOS v3.x.
#
#SELTYPE        = -DNO_43SELECT
#------------------------------------------------------------------------
#  If faces is setup to monitor mail, then the name of the default
#  spoolfile is /usr/spool/mail/username. An alternative spoolfile name
#  can be given by uncommenting the following line and setting
#  appropriately.
#
#SPOOLFILE       = -DSPOOLFILE=\"/usr/richb/Mail/pending\"
#------------------------------------------------------------------------
#  If you are running SunOS v3.x, then pr_ttext doesn't exist, and
#  you must uncomment this definition.
#
#TTEXT          = -DNO_PR_TTEXT
#------------------------------------------------------------------------
#  If the -U command line option is given to faces, then mail is sent to
#  a special mail alias. This alias is really a shell script, which will
#  take the given information, and try to update the faces database. By
#  default that alias is called "facemaker", but it is possible to give an
#  alternative alias here. This might be useful if a collection of machines
#  were remotely mounting the faces database from a file server.
#
#UPDATE		= -DUPDATE=\"facemaker@fileserver\"
#------------------------------------------------------------------------
#  If you are compiling the X11 version and the X11 include and
#  library files are not in a standard place, then the following
#  two lines should be uncommented, and set appropriately.
#
#X11INCDIR         = -I$(OPENWINHOME)/include
#X11LIBDIR         = -L$(OPENWINHOME)/lib
#------------------------------------------------------------------------
#  If you are compiling the XView version, then the following two lines
#  should be uncommented, and set appropriately.
#
#XVIEWINCDIR      = -I$(OPENWINHOME)/include
#XVIEWLIBDIR      = -L$(OPENWINHOME)/lib
#
#=======================================================================
#
#  Default locations where faces files will be installed.
#  You might wish to alter these values.
#
BINDIR		= /usr/local/bin
LIBDIR		= /usr/local/lib
MANDIR		= /usr/man
MANSECT		= l

#
#  Options for submakes
#
MAKEOPTS	= $(MFLAGS) BINDIR=$(BINDIR) LIBDIR=$(LIBDIR) MANDIR=$(MANDIR)

#
#  Compilation flags and standard macro definitions.
#
CDEFS		= $(BACKGROUND) $(DONTSHOWNO) $(DONTSHOWTIME) \
		  $(DONTSHOWUSER) $(CFACEDIR) $(FMONTYPE) $(INVERT) \
		  $(NEWSINCDIR) $(NODOMAINS) $(NOINDEX) $(PERIOD) \
		  $(REVORDER) $(SELTYPE) $(SPOOLFILE) $(TTEXT) $(UPDATE) \
		  $(X11INCDIR) $(XVIEWINCDIR)
CCOMP		= -g
CFLAGS		= $(CCOMP) $(CDEFS)
#
#=======================================================================

BINARIES	= psfaces svfaces xfaces xvfaces

CC		= cc
MAKE		= make

STDSRCS		= get.c main.c mon.c parsefrom.c rec.c
STDOBJS		= get.o main.o mon.o parsefrom.o rec.o
STDLIBS		= compface/libcompface.a

COMPFACE	= compface
FACES		= facedir
FILTERS		= filters
GSRCS		= news.c sunview.c x11.c xview.c
HDRS		= extern.h faces.h patchlevel.h
IMAGES		= noface.icon nomail.icon noprint.icon nopaper.icon \
		  nousers.icon
OTHERS		= CHANGES README TODO MANIFEST FILES \
		  faces.1 face_update.1 faces_cps.cps Makefile face_update

SFILES1		= mon.c main.c rec.c
SFILES2		= get.c parsefrom.c news.c sunview.c
SFILES3		= xview.c x11.c $(HDRS)
SFILES4		= CHANGES README TODO MANIFEST FILES Makefile
SFILES5		= faces.1 face_update.1 faces_cps.cps face_update $(IMAGES)
SFILES6		= $(FACES) $(FILTERS)
SFILES7		= $(COMPFACE)

NEWSLIBS	= $(NEWSLIBDIR) -lcps
SVIEWLIBS	= -lsuntool -lsunwindow -lpixrect
X11LIBS		= $(X11LIBDIR) -lX11
XVIEWLIBS	= $(XVIEWLIBDIR) -lxview -lolgx -lX11

help:
		@echo
		@echo "You need to specify one of the following options:"
		@echo
		@echo "  make sunview    - to make the SunView version."
		@echo "  make news       - to make the NeWS version."
		@echo "  make x11        - to make the X11 version."
		@echo "  make xview      - to make the XView version."
		@echo
		@echo "This should be followed by:"
		@echo
		@echo "  make install"
		@echo "  make clean"
		@echo

all:		$(BINARIES)

news:		$(STDOBJS) news.o faces_cps.h
		(cd compface; $(MAKE) $(MAKEOPTS))
		(cd filters; $(MAKE) $(MAKEOPTS))
		$(CC) -o psfaces $(CFLAGS) $(STDOBJS) news.o \
						$(STDLIBS) $(NEWSLIBS)
		-cp psfaces faces

sunview:	$(STDOBJS) sunview.o
		(cd compface; $(MAKE) $(MAKEOPTS))
		(cd filters; $(MAKE) $(MAKEOPTS))
		$(CC) -o svfaces $(CFLAGS) $(STDOBJS) sunview.o \
						$(STDLIBS) $(SVIEWLIBS)
		-cp svfaces faces

x11:		$(STDOBJS) x11.o
		(cd compface; $(MAKE) $(MAKEOPTS))
		(cd filters; $(MAKE) $(MAKEOPTS))
		$(CC) -o xfaces $(CFLAGS) $(STDOBJS) x11.o \
						$(STDLIBS) $(X11LIBS)
		-cp xfaces faces

xview:		$(STDOBJS) xview.o
		(cd compface; $(MAKE) $(MAKEOPTS))
		(cd filters; $(MAKE) $(MAKEOPTS))
		$(CC) -o xvfaces $(CFLAGS) $(STDOBJS) xview.o \
						$(STDLIBS) $(XVIEWLIBS)
		-cp xvfaces faces

install:
		(cd compface; $(MAKE) $(MAKEOPTS) install)
		(cd filters; $(MAKE) $(MAKEOPTS) install)
		install -s -m 751 faces $(BINDIR)
		install -c -m 755 face_update $(BINDIR)
		install -c -m 644 machine.tab $(FACEDIR)
		install -c -m 644 people.tab $(FACEDIR)
		install -c -m 644 faces.1 \
				$(MANDIR)/man$(MANSECT)/faces.$(MANSECT)
		install -c -m 644 face_update.1 \
				$(MANDIR)/man$(MANSECT)face_update.$(MANSECT)

clean:
		(cd compface; $(MAKE) $(MAKEOPTS) clean)
		(cd filters; $(MAKE) $(MAKEOPTS) clean)
		rm -f *.o Part* *~ $(BINARIES) faces core

lint:		lint-news lint-sunview lint-x11 lint-xview
lint-news:;	lint $(CDEFS) $(STDSRCS) news.c $(NEWSLIBS)
lint-sunview:;	lint $(CDEFS) $(STDSRCS) sunview.c $(SVIEWLIBS)
lint-x11:;	lint $(CDEFS) $(STDSRCS) x11.c
lint-xview:;	lint $(CDEFS) $(STDSRCS) xview.c

shar:;          shar.script $(SFILES1) > Part1
		shar.script $(SFILES2) > Part2
		shar.script $(SFILES3) > Part3
		shar.script $(SFILES4) > Part4
		shar.script $(SFILES5) > Part5
		shar.script $(SFILES6) > Part6
		shar.script $(SFILES7) > Part7

create:         SCCS
		-sccs create $(STDSRCS) $(GSRCS) $(HDRS) $(IMAGES) $(OTHERS)

SCCS:
		mkdir SCCS
		chmod 755 SCCS

faces_cps.h:	faces_cps.cps
		cps $<

get.o:		get.c faces.h extern.h patchlevel.h
main.o:		main.c faces.h $(IMAGES)
mon.o:		mon.c faces.h extern.h
news.o:		news.c faces.h extern.h faces_cps.h
rec.o:		rec.c faces.h extern.h
sunview.o:	sunview.c faces.h extern.h
x11.o:		x11.c faces.h extern.h
xview.o:	xview.c faces.h extern.h
