#
# Makefile for Pcal v4.5 under UNIX
#
# v4.5: "make clean" leaves pcal intact but removes other by-products;
#       "make clobber" blows everything away
#

# Set the configuration variables below to taste.

CC	= gcc -O

# PACK is for packing the man page.  Note that setting PACK to ":" will cause
# no packing to be done; otherwise, choose "compress" or "pack" as your system
# requires.
PACK	= :
# PACK	= compress
# PACK	= pack

# directories for installing executable and man page(s)
BINDIR	= /usr/local/bin
MANDIR	= /usr/local/man/man1
CATDIR	= /usr/local/man/cat1

OBJECTS = pcal.o exprpars.o moonphas.o pcalutil.o readfile.o writefil.o

# Site-specific defaults which may be overridden here (cf. pcallang.h);
# uncomment the examples below and/or change them to your liking

# include Roman8 or ISO Latin1 8-bit character mappings by defining MAPFONTS
# as ROMAN8 or LATIN1 respectively
# D_MAPFONTS   = -DMAPFONTS=ROMAN8

# redefine title, date, and notes font/pointsize (-t, -d, -n)
# D_TITLEFONT = '-DTITLEFONT="Helvetica-Bold/48"'
# D_DATEFONT  = '-DDATEFONT="Helvetica-Bold/28"'
# D_NOTESFONT = '-DNOTESFONT="Helvetica/8"'

# redefine shading (dates/fillboxes)
# D_SHADING = '-DSHADING="0.6/0.99"'

# specify American (USA_DATES) or European (EUR_DATES) date parsing (-A, -E)
# D_DATE_STYLE = -DDATE_STYLE=USA_DATES

# specify first (leftmost) weekday on calendar (-F)
# D_FIRST_DAY  = -DFIRST_DAY=SUN

# specify default time zone for moon phases: "0" = GMT; "5" = Boston (-z)
# D_TIMEZONE   = '-DTIMEZONE="5 [Boston]"'
D_TIMEZONE   = '-DTIMEZONE="6 [Iowa City]"'

# generate EPS-compatible PostScript (-DEPS)
D_EPS	       = -DEPS

COPTS = $(D_MAPFONTS) $(D_TITLEFONT) $(D_DATEFONT) $(D_NOTESFONT) \
        $(D_SHADING) $(D_DATE_STYLE) $(D_FIRST_DAY) $(D_TIMEZONE) \
	$(D_EPS)

pcal:	$(OBJECTS)
	$(CC) $(LDFLAGS) -o pcal $(OBJECTS) -lm
	@ echo "Build of pcal complete"

exprpars.o:	exprpars.c pcaldefs.h
	$(CC) $(CFLAGS) $(COPTS) -c exprpars.c

moonphas.o:	moonphas.c pcaldefs.h pcalglob.h protos.h
	$(CC) $(CFLAGS) $(COPTS) -c moonphas.c

pcal.o:		pcal.c pcaldefs.h pcalglob.h pcallang.h protos.h
	$(CC) $(CFLAGS) $(COPTS) -c pcal.c

pcalutil.o:	pcalutil.c pcaldefs.h pcalglob.h pcallang.h protos.h
	$(CC) $(CFLAGS) $(COPTS) -c pcalutil.c

readfile.o:	readfile.c pcaldefs.h pcalglob.h pcallang.h protos.h
	$(CC) $(CFLAGS) $(COPTS) -c readfile.c

writefil.o:	writefil.c pcaldefs.h pcalglob.h pcallang.h protos.h pcalinit.h
	$(CC) $(CFLAGS) $(COPTS) -c writefil.c

pcalinit: pcalinit.c
	$(CC) $(CFLAGS) $(LDFLAGS) $(COPTS) -o pcalinit pcalinit.c

pcalinit.h: pcalinit pcalinit.ps
	./pcalinit pcalinit.ps pcalinit.h header

clean:
	rm -f $(OBJECTS) pcalinit pcalinit.h pcal.cat

clobber:
	rm -f $(OBJECTS) pcal pcalinit pcalinit.h pcal.cat

man:	pcal.man
	nroff -man pcal.man > pcal.cat

install:	pcal man
	cp pcal $(BINDIR)
	cp pcal.man $(MANDIR)/pcal.1
	$(PACK) $(MANDIR)/pcal.1
	cp pcal.cat $(CATDIR)/pcal.1
	$(PACK) $(CATDIR)/pcal.1
