#			    -- MAKEFILE (UNIX) --
#
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# @@                                                                         @@
# @@                    Mailing List Label Formatter                         @@
# @@                  Program Maintenance Specification                      @@
# @@                    (C) Copyright 1987 by Joe Chen                       @@
# @@                         All Rights Reserved                             @@
# @@                                                                         @@
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#
# Program created by Joe Chen - Jul 24, 1987
#
# *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

# Directory where LABELS is to be installed (please specify the full path)
DESTDIR = /usr/pollux/jchen/bin

# Directory where label forms can be found (please specify the full path)
FRMDIR = /usr/pollux/jchen/bin/lib

# Program name
LNAME = labels

# Compiling flags UNIX, BSD (USG and MSDOS are valid, but not fully supported)
# NOTE: This program has been fully tested on Sun UNIX only.
CFLAGS = -DBSD -DUNIX

CC = cc -c -g $(CFLAGS)
YACC = yacc
LEX = lex
LINK = cc

# *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

OBJS = y.tab.o lex.yy.o main.o


labels: $(OBJS)
	@echo char \*rev_date = \"`date`\"\; > revdate.c
	@echo Linking $(LNAME)...
	@${LINK} $(OBJS) revdate.c -o $(LNAME)
	@rm -f revdate.c revdate.o
	@echo 
	@echo \`$(LNAME)\' Compiled.

y.tab.c: labels.y
	@echo Running Yacc...
	@${YACC} -d labels.y

y.tab.o: y.tab.c
	@echo Compiling: y.tab.c
	@${CC} y.tab.c

lex.yy.c: labels.l
	@echo Running Lex...
	@${LEX} labels.l

lex.yy.o: lex.yy.c y.tab.h
	@echo Compiling: lex.yy.c
	@${CC} lex.yy.c

main.o: main.c Makefile
	@echo Compiling: main.c
	@${CC} -DFDIR=\"$(FRMDIR)\" main.c

install:
	@echo Installing \`$(LNAME)\' in $(DESTDIR)...
	@rm -f $(DESTDIR/$(LNAME)
	@cp $(LNAME) $(DESTDIR)/$(LNAME)
	@strip $(DESTDIR)/$(LNAME)
	@chmod 755 $(DESTDIR)/$(LNAME)
	@echo
	@echo Placing Form Definitions in $(FRMDIR)...
	@echo mkdir $(FRMDIR) 2\> /dev/null \; exit 0 > mklib
	@chmod u+x mklib
	@./mklib
	@rm -f mklib
	@chmod 755 $(FRMDIR)
	@cp *.lbl $(FRMDIR)
	@chmod 644 $(FRMDIR)/*.lbl
	@make man
	@echo 
	@echo \`$(LNAME)\' installed.

clean:
	@echo Cleaning Directory...
	@rm -f *.o *\~ y.tab.* lex.yy.c $(LNAME)
	@echo 
	@echo Done!

man:
	@echo
	@echo Processing a raw man page: $(LNAME).1
	@/lib/cpp -P -DLIBDIR=$(FRMDIR) -DLNAME=$(LNAME) -DPROGDIR=$(DESTDIR) \
		$(LNAME).man > $(LNAME).1


shar:
	@echo Shell Archiving \($(LNAME)\.shar\)...
	@shar INSTALL Makefile main.c labels.l labels.y labels.man \
		*.lbl > $(LNAME).shar
	@echo 
	@echo Done!
