#
# Makefile to build the MWC sales system.
# based on cef's Makefile to build the stand-alone C programs.
# by fwb, 5/24/94
#

CC=cc
C4GL=c4gl

.SUFFIXES: .frm .4gl .per

# RULES

.4gl.o:
	c4gl -c $<
	rm -f $*.ec $*.c

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

.per.frm:
	form4gl $<

#
# MACROS
#

# All of the executables
ALL =	bacct \
	base.4ge \
	c10 \
	ccreps.4ge \
	cform \
	comform \
	credit.4ge \
	crib \
	dupfind.4ge \
	dupl_cust.4ge \
	dupwrite \
	format \
	format2 \
	forrdb \
	macct \
	mainline.4ge \
	mform \
	pacct \
	print_land \
	reports.4ge \
	repx.4ge \
	tech.4ge \
	tmn \
	tnet.4ge \
	tranlog \
	tyme \
	unblank \
	xacct

#	ups.4ge \
#	xacct

# modules that comprise "bacct", which generates .bat files for Owen's
# accounting system
BACCT = \
	bacct.o

# modules that comprise "base.4ge", the program with which the user
# can update the static tables in the data base
BASE =	\
	bad_disk.o \
	bad_report.o \
	base.o \
	crunch.o \
	dest.o \
	freight.o \
	globals0.o \
	mag.o \
	prod.o \
	ship.o \
	state.o \
	term.o

BASE_FRM = \
	bad_disk.frm \
	mag.frm \
	product.frm \
	shippers.frm \
	state.frm \
	term.frm

# modules that comprise "c10", which prints a file in ten-point Courier font
C10 = \
	c10.o

# modules that comprise "ccreps.4ge", the program that guides the execution
# and printing of invoices
CCREP = \
	ccreps.o \
	globals0.o

# modules that comprise "cform", which prints a mass of credit memos
CFORM = \
	cform.o

# modules that comprise "comform", which formats Informix output for
# commercial invoices
COMFORM = \
	comform.o

# modules that comprise "credit.4ge", which generates credit memos
CREDIT = \
	addline.o \
	address.o \
	auth.o \
	checkno.o \
	credit.o \
	crunch.o \
	fileread.o \
	globals0.o \
	payment.o

CREDIT_FRM = \
	auth.frm \
	credit.frm \
	pay.frm

# modules that comprise "crib", which builds cribsheets (whatever they are)
CRIB = \
	crib.o \
	getopt.o

# modules that comprise "dupfind.4ge", which finds duplicate customers
# within the data base
DUPFIND = \
	crunch.o \
	dupfind.o \
	globals0.o

# modules that comprise "dupl_cust.4ge", which finds duplicate customers
# and removes them, should the clerk wish
DUPL_CUST = \
	dupl_cust.o \
	globals0.o

DUPL_CUST_FRM = \
	dupl_cust.frm

# modules that comprise "dupwrite", which finds and prints duplicate entries
# within a list
DUPWRITE = \
	dupwrite.o

# modules that comprise "format", a C program that formats reports
FORMAT = \
	format.o \
	mv2xy.o \
	mwlogo.o \
	PrintLine.o

# modules that comprise "format2", a C program that formats log-file entries
FORMAT2 = \
	format2.o

# modules that comprise "forrdb", which formats reports for loading into
# Jay's rdb system
FORRDB = \
	forrdb.o

# modules that comprise "macct", which formats a credit memo for loading into
# Owen's account system
MACCT = \
	macct.o

# modules that comprise "mainline.4ge", the program that runs the whole
# shebang.
MAINLINE = \
	addline.o \
	address.o \
	all.o \
	crunch.o \
	exp_num.o \
	get_usr.o \
	globals0.o \
	mailer.o \
	mainline.o \
	newreg.o \
	regcard.o \
	shipdate.o \
	ups_add.o \
	ups_charge.o \
	ups_cor.o \
	ups_func.o \
	ups_grzone.o \
	ups_main.o \
	ups_report.o \
	ups_tag.o \
	wand.o

MAINLINE_FRM = \
	mailer.frm \
	mainline.frm \
	regcard.frm \
	shipdate.frm \
	wand.frm \
	PickLine.frm \
	ground.frm \
	ups_tag.frm \
	w_z_p.frm

# modules that comprise "mform", the program that prints labels for mailers
MFORM = \
	mform.o \
	mv2xy.o

# modules that comprise "pacct", which generates a .bat file for
# Owen's accounting system
PACCT = \
	pacct.o

# modules that comprise "print_land", which puts the printer into landscape
# mode.  (This should be done through a spooler option, but never mind.)
PRINT_LAND = \
	print_land.o

# modules that comprise "reports.4ge", which generates and prints
# reports on invoices
REPORTS = \
	addline.o \
	globals0.o \
	reports.o

# modules that comprise "tech", which displays a screen into which
# tech supports logs calls.
TECH = 	\
	tech.o \
	get_usr.o \
	crunch.o \
	globals0.o

# modules that comprise "tmn", the program that calls Tymnet and
# executes credit-card transactions
TMN = \
	connect.o \
	sales.o \
	transact.o

# modules that comprise "tnet.4ge", the 4GL wrapper for executing
# credit-card transactions
TNET =	\
	addline.o \
	fileread.o \
	globals0.o \
	tnet.o

# modules that comprise "tranlog", which manipulates the transaction log
TRANLOG = \
	tranlog.o

# modules that comprise "tyme", which also performs some Tymnet transaction
# (though how it's used exactly is unclear)
TYME = \
	tyme.o

# modules that comprise "unblank", which removes blank lines from output
UNBLANK = \
	unblank.o

# modules that comprise "ups.4ge", the program that handles UPS transactions.
# UPS = \
# 	globals0.o \
# 	ups_add.o \
# 	ups_charge.o \
# 	ups_cor.o \
# 	ups_func.o \
# 	ups_grzone.o \
# 	ups_main.o \
# 	ups_report.o \
# 	ups_tag.o

# UPS_FRM = \
# 	PickLine.frm \
# 	ground.frm \
# 	ups_tag.frm \
# 	w_z_p.frm

# modules that comprise "xacct", which also does something for Owen's
# accounting package
XACCT = \
	xacct.o

#
# LINK THE EXECUTABLES
#

all: $(ALL)

bacct: $(BACCT)
	cc -s -O -o bacct bacct.o

base.4ge: $(BASE) $(BASE_FRM)
	c4gl -s -O -o base.4ge $(BASE)

c10: $(C10)
	cc -O -o c10 $(C10)
	strip c10

ccreps.4ge: $(CCREP) tnet.4ge dupfind.4ge tmn
	c4gl -s -O -o ccreps.4ge $(CCREP)

cform: $(CFORM)
	cc -O -o cform $(CFORM)

clean:
	rm $(ALL)
	rm *.o
	rm *.frm

comform: $(COMFORM)
	cc -s -O -o comform $(COMFORM)

credit.4ge: $(CREDIT) $(CREDIT_FRM)
	c4gl -s -O -o credit.4ge $(CREDIT)

crib: $(CRIB)	
	cc -s -O -o crib $(CRIB)

dupfind.4ge: $(DUPFIND)
	c4gl -s -O -o dupfind.4ge $(DUPFIND)

dupl_cust.4ge: $(DUPL_CUST) $(DUPL_CUST_FRM)
	c4gl -s -O -o dupl_cust.4ge $(DUPL_CUST)
	strip dupl_cust.4ge

dupwrite: $(DUPWRITE)
	cc -O -o dupwrite $(DUPWRITE)
	strip dupwrite

format: $(FORMAT)
	cc -s -O -o format $(FORMAT) -lm

forrdb: $(FORRDB)
	cc -s -O -o forrdb $(FORRDB)

macct: $(MACCT)
	cc -s -O -o macct $(MACCT)

#mainline.4ge : $(MAINLINE) $(MAINLINE_FRM) \
#		base.4ge ccreps.4ge credit.4ge reports.4ge repx.4ge ups.4ge
#	c4gl -s -O -o mainline.4ge $(MAINLINE)

mainline.4ge : $(MAINLINE) $(MAINLINE_FRM) \
		base.4ge ccreps.4ge credit.4ge reports.4ge repx.4ge tnet.4ge
	c4gl -s -O -o mainline.4ge $(MAINLINE)

mform: $(MFORM)
	cc -s -O -o mform $(MFORM) -lm

pacct: $(PACCT)
	cc -s -O -o pacct $(PACCT)

print_land: $(PRINT_LAND)
	cc -s -O -o print_land $(PRINT_LAND)

reports.4ge: $(REPORTS)
	c4gl -s -O -o reports.4ge $(REPORTS)

repx.4ge: addline.o globals0.o repx.o
	c4gl -s -O -o repx.4ge addline.o globals0.o repx.o

tech.4ge: $(TECH) tech.frm
	c4gl -s -O -o tech.4ge $(TECH)

tmn: $(TMN)
	cc -s -O -o tmn $(TMN)

tnet.4ge: $(TNET) format
	c4gl -s -O -o tnet.4ge $(TNET)

tranlog: $(TRANLOG)
	cc -s -O -o tranlog $(TRANLOG)

tyme: $(TYME) tymnet.h
	cc -s -O -o tyme $(TYME)

unblank: $(UNBLANK)
	cc -s -O -o unblank $(UNBLANK)

# ups.4ge: $(UPS) $(UPS_FRM)
#	c4gl -s -O -o ups.4ge $(UPS)

xacct: $(XACCT)
	cc -s -O -o xacct $(XACCT)

# the end (and about time, too!)
