#
# Makefile for sports schedule programs
#
# George Ferguson, ferguson@cs.rochester.edu, 15 Mar 1994
#

#
# Adjust as needed:
#
#CC = cc
#CDEBUGFLAGS = -g
LINKFLAGS =
LIBS =
BINDIR = /usr/local/bin
MANDIR = /usr/local/man/man1
MANEXT = 1

#
# Which schedules to compile for?
#
PROGRAMS = nhl mlb nba

#
# If you want dates to be specified as "dd/mm" rather than "mm/dd",
# uncomment the following definition of the constant EUROPEAN_DATES
#EUROPEAN_DATES = -DEUROPEAN_DATES

#####################################################################
# You should only need to change below here if you are adding new schedules

all: $(PROGRAMS)

CFLAGS = $(CDEBUGFLAGS) $(EUROPEAN_DATES)

#
# Each program needs a link line that specifies which DATAFILE to
# include while compiling schedule.c.
# You should also have a target to create a manpage for the program
# from the template schedule.man, and you should add an install.*
# target to allow just that program to be built and installed.
#

nhl: schedule.c nhl.93-94.c
	$(CC) $(CFLAGS) -o $@ -DDATAFILE=\"nhl.93-94.c\" schedule.c $(LINKFLAGS) $(LIBS)

nhl.man: schedule.man
	sed -e 's/@PROGRAM@/nhl/' \
	    -e 's/@LEAGUE@/National Hockey League/' \
	    <schedule.man >$@

mlb: schedule.c mlb.94.c
	$(CC) $(CFLAGS) -o $@ -DDATAFILE=\"mlb.94.c\" schedule.c $(LINKFLAGS) $(LIBS)

mlb.man: schedule.man
	sed -e 's/@PROGRAM@/mlb/' \
	    -e 's/@LEAGUE@/Major League Baseball/' \
	    <schedule.man >$@

nba: schedule.c nba.93-94.c
	$(CC) $(CFLAGS) -o $@ -DDATAFILE=\"nba.93-94.c\" schedule.c $(LINKFLAGS) $(LIBS)

nba.man: schedule.man
	sed -e 's/@PROGRAM@/nba/' \
	    -e 's/@LEAGUE@/National Basketball Association/' \
	    <schedule.man >$@

#
# Installation
#
install:
	@for i in $(PROGRAMS); do \
	    $(MAKE) install.$$i; \
	done

install.nhl: nhl nhl.man
	cp nhl $(BINDIR)
	cp nhl.man $(MANDIR)/nhl.$(MANEXT)

install.mlb: mlb mlb.man
	cp mlb $(BINDIR)
	cp mlb.man $(MANDIR)/mlb.$(MANEXT)

install.nba: nba nba.man
	cp nba $(BINDIR)
	cp nba.man $(MANDIR)/nba.$(MANEXT)

#
# Cleanup
#
clean:
	@for i in $(PROGRAMS); do \
	    echo "rm -f $$i $$i.man"; \
	    rm -f $$i $$i.man; \
	done

#
# Archiving targets
#
CORE = README INSTALLING UPDATING Makefile schedule.c schedule.man patchlevel.h
NHL  = nhl.92-93.c nhl.93-94.c nhl-build.pl
MLB  = mlb.94.c mlb-build.pl
NBA  = nba.93-94.c

SHARNAME = schedules.shar
SHAROPTS = -n schedules -s ferguson@cs.rochester.edu

shar:
	shar $(SHAROPTS) $(CORE) >$(SHARNAME).1
	shar $(SHAROPTS) $(NHL) >$(SHARNAME).2
	shar $(SHAROPTS) $(MLB) >$(SHARNAME).3
	shar $(SHAROPTS) $(NBA) >$(SHARNAME).4

tar:
	tar cvf - $(CORE) $(NHL) $(MLB) $(NBA) | gzip >schedules.tar.gz
