#---- configured by Configure revision 3.20 for ECU 3.23
#---- edit ./Make.src and rerun Configure to produce this file

SIGTYPE = void

CC = gcc
CFLAGS = \
	-O \
	-fstrength-reduce -fpcc-struct-return -fwritable-strings \
	-finline-functions -fforce-mem -fforce-addr \
	-W -Wunused -Wpointer-arith -Wcast-qual -Wshadow -Wcomment -Wswitch\
	-DM_BITFIELDS -DM_COFF -DM_I386 -DM_I86 -DM_I86SM \
	-DM_INTERNAT -DM_SDATA -DM_STEXT -DM_SYS3 -DM_SYS5 \
	-DM_SYSIII -DM_SYSV -DM_UNIX -DM_WORDSWAP -Dunix -Di386\
	-DLINUX \
	-DUSE_ECUUNGETTY \
	-DSIGTYPE=$(SIGTYPE) \
	-DLOCK_DIR_NAME='"/usr/spool/uucp"' \
	-DGCC140 \
	-DDEFAULT_TTY='"/dev/ttyS1"' \
	-DDEFAULT_BAUD_RATE=2400 \
	-DDEFAULT_PARITY="'n'" \
	-DHDBLIBDIR='"$(HDBLIBDIR)"' \
	-DECULIBDIR='"$(ECULIBDIR)"' -DECUUNGETTY_CHOWN \
	-DPID_T=int \
	$(SYMBOLIC) $(CFLAGS_EXTRA) $(GCC_CFLAGS_EXTRA) $(LOCAL_CFLAGS)

LDFLAGS = \
	$(SYMBOLIC) $(LDFLAGS_EXTRA)

LIBS = -lncurses

LBIN = /usr/bin
ECULIBDIR = /usr/lib/ecu
SYSTEM = UNIX/386
HDBLIBDIR = /usr/lib/uucp
USE_ECUUNGETTY = yes
#BINTIME = /bin/time

#---- end of configured make variables
#+------------------------------------------------------------------- 
# Make.src - master Makefile source for ECU and related programs
# If THIS line is the third in the file you are reading, refer to
# the files README and Configure.
# wht@n4hgf.Mt-Park.GA.US
#--------------------------------------------------------------------
#+:EDITS:*/
#:09-10-1992-13:58-wht@n4hgf-ECU release 3.20
#:08-22-1992-15:37-wht@n4hgf-ECU release 3.20 BETA
#:07-17-1992-18:23-wht@n4hgf-new module nap.c
#:07-07-1992-20:04-wht@n4hgf-new installation mechanism
#:05-17-1992-18:50-wht@n4hgf-add cpio
#:02-10-1992-05:47-wht@n4hgf-mcs avail on some systems when non-COFF produced
#:09-03-1991-23:47-wht@n4hgf2-add timetest directory
#:09-02-1991-19:25-wht@n4hgf2-ckutio dif and fas.h left out of distribution
#:09-01-1991-16:22-wht@n4hgf2-generalize HDB config location
#:08-23-1991-13:35-wht@n4hgf-sun porting (3.13)
#:07-25-1991-12:55-wht@n4hgf-ECU release 3.10
#:04-21-1991-12:43-wht@n4hgf-convert to Make.src

PROGRAM = ecu
INSTALLABLE = $(LBIN)/$(PROGRAM)

ECUSHARNAME=ecu320
MANSHARNAME=ecuman320

LIBFUNCKEYMAP = $(ECULIBDIR)/funckeymap

SHELL = /bin/sh

.SUFFIXES:
.SUFFIXES: .o .c .h .l
.c.o:;	$(BINTIME) $(CC) -c $(CFLAGS) $*.c 


SRC	= \
	bamboozle.c\
	cmdtbl.c\
	ecu.c\
	ecuLCK.c\
	ecuchdir.c\
	ecudump.c\
	ecufinsert.c\
	ecufkey.c\
	ecufork.c\
	ecuDCE.c\
	ecugrabbag.c\
	eculine.c\
	eculock.c\
	ecunumrev.c\
	ecuicmaux.c\
	ecuicmhelp.c\
	ecuicmhist.c\
	ecuicmd.c\
	ecupde.c\
	ecuphdir.c\
	ecuphrase.c\
	ecurcvr.c\
	ecuscrdump.c\
	ecusetup.c\
	ecushm.c\
	ecusighdl.c\
	ecutcap.c\
	ecutime.c\
	ecutty.c\
	ecuuclc.c\
	ecuusage.c\
	ecuutil.c\
	ecuwinutil.c\
	ecuxfer.c\
	esdutil.c\
	fasiintf.c\
	expresp.c\
	feval.c\
	gint.c\
	gstr.c\
	hdbintf.c\
	logevent.c\
	nap.c \
	funckeymap.c\
	pcmd.c\
	pcmdif.c\
	pcmdfile.c\
	pcmdtty.c\
	pcmdwhile.c\
	pcmdxfer.c\
	poutput.c\
	pprintf.c\
	proc.c\
	proc_error.c\
	procframe.c\
	regexp.c\
	ttynaming.c\
	utmpstat.c\
	var.c

OBJ	= \
	bamboozle.o\
	cmdtbl.o\
	ecu.o\
	ecuLCK.o\
	ecudump.o\
	ecuchdir.o\
	ecufinsert.o\
	ecufkey.o\
	ecufork.o\
	ecuDCE.o\
	eculine.o\
	eculock.o\
	ecunumrev.o\
	ecuicmaux.o\
	ecuicmhelp.o\
	ecuicmhist.o\
	ecuicmd.o\
	ecugrabbag.o\
	ecupde.o\
	ecuphdir.o\
	ecuphrase.o\
	ecurcvr.o\
	ecuscrdump.o\
	ecusetup.o\
	ecushm.o\
	ecusighdl.o\
	ecutcap.o\
	ecutime.o\
	ecutty.o\
	ecuuclc.o\
	ecuusage.o\
	ecuutil.o\
	ecuwinutil.o\
	ecuxfer.o\
	esdutil.o\
	fasiintf.o\
	expresp.o\
	feval.o\
	gint.o\
	gstr.o\
	hdbintf.o\
	logevent.o\
	lstat.o\
	nap.o \
	mkdirs.o\
	funckeymap.o\
	pcmd.o\
	pcmdif.o\
	pcmdfile.o\
	pcmdtty.o\
	pcmdwhile.o\
	pcmdxfer.o\
	poutput.o\
	pprintf.o\
	proc.o\
	proc_error.o\
	procframe.o\
	regexp.o\
	ttynaming.o\
	utmpstat.o\
	var.o
#	shm.o
#	ipc.o

SHARFLS = \
	README \
	README.* \
	CHANGES \
	HISTORY \
	OLD-HISTORY-* \
	ESOTERIC \
	Configure \
	Make.src */Make.src \
	*.[ch] \
	bperr/bperr.c \
	help/{*.[ch],ecuhelp.src} \
	ecuungetty/*.[ch] \
	z/*.[ch] \
	sea/{*.[ch],*.{doc,imp}} \
	gendial/{README,install_dialer,*.[ch]} \
	fasi/{Makefile,Master,Node,PATCHLEVEL} \
	fasi/{README,README.FASI,RELEASENOTES} \
	fasi/{Space.c,System,digi-pc8.h,fas.c,fas.h,idfasi} \
	ecufriend/*.[ch] \
	mapkey/README mapkey/keys.usa.ecu \
	xsel386/* \
	memmove/{README,*.{s,asm}} \
	timetest/{Makefile,*.c} \
	doc/{README,Makefile,*.txt} models/* zgcc mkoldproto.l'

MAKEDIRS_OBJ =\
	makedirs.o\
	mkdirs.o\
	lstat.o

all: $(PROGRAM) .make.help .make.ug .make.z .make.s kbdtest3 makedirs

$(PROGRAM): $(OBJ)
	echo 'char *makedate="@(#)'ecu `date` $(SYSTEM)'";'  >makedate.c
	$(CC) -c $(CFLAGS) makedate.c; rm makedate.c
	rm -f $@; if [ -f $@ ]; then mv $@ $@~; fi
	$(BINTIME) $(CC) -o $@ $(LDFLAGS) makedate.o $(OBJ) $(LIBS)
	rm makedate.o

#$(OBJ): Makefile

.make.help:
	cd help; $(MAKE) -$(MAKEFLAGS)

.make.z:
	cd z; $(MAKE) -$(MAKEFLAGS)

.make.s:
	cd sea; $(MAKE) -$(MAKEFLAGS)

.make.ug:
	if [ $(USE_ECUUNGETTY) = yes ]; then \
		cd ecuungetty; $(MAKE) -$(MAKEFLAGS); \
	fi

bperr/bperr: bperr/bperr.c
	cd bperr; $(MAKE) -$(MAKEFLAGS) bperr

proc_error.c: ecuerror.h
	$(MAKE) -$(MAKEFLAGS) bperr/bperr
	bperr/bperr

ecuicmhelp.o: ecuicmhelp.c ecucurses.h pc_scr.h

ecuicmhist.o: ecuicmhist.c ecucurses.h pc_scr.h

ecuphdir.o: ecuphdir.c ecucurses.h pc_scr.h

ecuscrdump.o: ecuscrdump.c pc_scr.h

ecusetup.o: ecusetup.c ecucurses.h pc_scr.h

ecutcap.o: ecutcap.c pc_scr.h

ecuwinutil.o: ecusetup.c ecucurses.h pc_scr.h

ecuxfer.o: ecuxfer.c ecucurses.h pc_scr.h

kbdtest3: kbdtest3.c
	$(CC) -o $@ $(CFLAGS) kbdtest3.c

$(OBJ): ecushm.h

ecu.fls: Makefile
	ls $(SRC) >ecu.fls

# Not recommended
protos: ecu.fls afterlint mkoldproto
	echo ' ' > protos.h
	csh ./zgcc ecu.fls protos.h .

# Not recommended
allprotos:
	$(MAKE) -$(MAKEFLAGS) protos
	cd z; $(MAKE) -$(MAKEFLAGS) protos
	cd sea; $(MAKE) -$(MAKEFLAGS) protos

makedirs: $(MAKEDIRS_OBJ)
	$(CC) -o $@ $(LDFLAGS) $(MAKEDIRS_OBJ) $(LIBS)

# install ecu
iecu: makedirs ecu
	@echo Installing ECU in $(LBIN) and $(ECULIBDIR) ... please wait
	@if [ ! -d $(LBIN) ]; then \
		echo '\012'Attempting to make $(LBIN); \
		./makedirs -m 755 $(LBIN); \
		ls -ld $(LBIN); \
	fi
	@rm -f $(INSTALLABLE) $(INSTALLABLE)~
	@if [ -f $(INSTALLABLE) ]; then \
		echo '\012'Cannot remove $(INSTALLABLE) - moving to $(INSTALLABLE)~ \
		mv $(INSTALLABLE) $(INSTALLABLE)~; \
	fi
	@cp $(PROGRAM) $(INSTALLABLE)
	@strip $(INSTALLABLE)
	@-if [ -x /usr/bin/mcs ]; then \
		/usr/bin/mcs -d $(INSTALLABLE) || echo mcs present but not COFF? ; \
	fi
	@chown bin $(INSTALLABLE)
	@chgrp bin $(INSTALLABLE)
	@chmod 711 $(INSTALLABLE)
	@echo '\012'Installed
	@ls -l $(INSTALLABLE)
	@if [ ! -d $(ECULIBDIR) ]; then \
		echo '\012'Attempting to make $(ECULIBDIR); \
		./makedirs -m 755 $(ECULIBDIR); \
		ls -ld $(ECULIBDIR); \
	fi
	@-if [ -f $(LIBFUNCKEYMAP) ]; then \
		echo '\012'Saving your old $(LIBFUNCKEYMAP); \
		for i in  2 1; \
		do \
			j=`expr $$i + 1`; \
			mv $(LIBFUNCKEYMAP)-$$i $(LIBFUNCKEYMAP)-$$j 2>/dev/null; \
		done; \
		mv $(LIBFUNCKEYMAP) $(LIBFUNCKEYMAP)-1; \
		ls -l $(LIBFUNCKEYMAP)*; \
	fi
	@cp models/funckeymap $(ECULIBDIR)
	@chown bin $(LIBFUNCKEYMAP)
	@chgrp bin $(LIBFUNCKEYMAP)
	@chmod 644 $(LIBFUNCKEYMAP)
	@echo '\012'Installed
	@ls -l $(LIBFUNCKEYMAP)

# install everything
install: all makedirs #run as root
	@echo '\012'Starting full installation of ECU ... please wait
	@make iecu
	@if [ $(USE_ECUUNGETTY) = yes ]; then \
		cd ecuungetty; $(MAKE) -$(MAKEFLAGS) install; \
	fi
	cd z; $(MAKE) -$(MAKEFLAGS) install
	cd sea; $(MAKE) -$(MAKEFLAGS) install
	cd help; $(MAKE) -$(MAKEFLAGS) install
	@if [ ! -f $(HDBLIBDIR)/Devices ]; then \
		cp models/*.mi $(ECULIBDIR); \
		echo "==> edit $(ECULIBDIR)/*.mi for your tty lines per ecu.man"; \
	fi
	@echo '\012'Installation complete.  Follow the yellow brick road.

shar.fls: Makefile
	csh -c 'ls $(SHARFLS) | sort > shar.fls'

# for shar 3.461
shar: shar.fls
	csh -c 'shar -F -c -s "wht@n4hgf.Mt-Park.GA.US" -a \
	-E 'SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses' \
-n$(ECUSHARNAME) -L57 -o/tmp/$(ECUSHARNAME) $(SHARFLS)' 
	cd doc;make
	shar -F -c -s "wht@n4hgf.Mt-Park.GA.US" -a \
	-E 'SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses' \
-n$(MANSHARNAME) -L57 -o/tmp/$(MANSHARNAME) doc/ecu.man doc/proc.man

cpio: shar.fls
	@echo Making /tmp/$(ECUSHARNAME)cpio.Z
	cd doc;make
	rm -f /tmp/ecu.cpio.fls
	cat shar.fls > /tmp/ecu.cpio.fls
	echo doc/ecu.man >> /tmp/ecu.cpio.fls
	echo doc/proc.man >> /tmp/ecu.cpio.fls
	sed -e 's:^:ecu/:' < /tmp/ecu.cpio.fls > cpio.fls
	rm -f /tmp/ecu.cpio.fls
	cd ..;cat ecu/cpio.fls | sort -y | cpio -oc | \
		 compress > /tmp/$(ECUSHARNAME)cpio.Z
	zcat /tmp/$(ECUSHARNAME)cpio.Z | cpio -itv | head

# tools for making ecu
afterlint: afterlint.c
	cc -O afterlint.c -o $@
	-if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $@; fi
	strip $@

mkoldproto: mkoldproto.l
	lex mkoldproto.l
	cc -O lex.yy.c -ll -o $@
	-if [ -x /usr/bin/mcs ]; then /usr/bin/mcs -d $@; fi
	strip $@
	rm lex.yy.?

# lint is outdated old biddy, but is worth consulting once per millineum
# hack LINT_ARGS into your config.local file
lint.out: Makefile $(SRC)
	lint $(LINT_ARGS) $(SRC) > lint.out

neat:
	rm -f core tags cscope.out makedate.c makedate.o
	rm -f *~ *# *.orig *.rej make.log a.out
	rm -f */*~ */*# */*.orig */*.rej
	rm -f makedirs kbdtest kbdtest3
	rm -f bperr/bperr shar.fls cpio.fls /tmp/ecu.cpio.fls
	rm -f .make.* depend.tmp eddep.tmp Makefile.new *.bak *.BAK
	cd help; $(MAKE) -$(MAKEFLAGS) neat
	cd z; $(MAKE) -$(MAKEFLAGS) neat
	cd sea; $(MAKE) -$(MAKEFLAGS) neat
	if [ $(USE_ECUUNGETTY) = yes ]; then \
		cd ecuungetty; $(MAKE) -$(MAKEFLAGS) neat; \
	fi

clean: neat
	rm -f $(OBJ) makedirs.o
	rm -f config kbdtest kbdtest3 makedirs afterlint mkoldproto
	cd help; $(MAKE) -$(MAKEFLAGS) clean
	cd z; $(MAKE) -$(MAKEFLAGS) clean
	cd sea; $(MAKE) -$(MAKEFLAGS) clean
	if [ $(USE_ECUUNGETTY) = yes ]; then \
		cd ecuungetty; $(MAKE) -$(MAKEFLAGS) clean; \
	fi
	-if [ -f gendial/Makefile ]; then \
		cd gendial; $(MAKE) -$(MAKEFLAGS) clean; \
	fi
	-if [ -f timetest/Makefile ]; then \
		cd timetest; $(MAKE) -$(MAKEFLAGS) clean; \
	fi

clobber: clean
	rm -f $(PROGRAM) $(PROGRAM)~
	rm -f kbdtest3.out
	cd help; $(MAKE) -$(MAKEFLAGS) clobber
	cd z; $(MAKE) -$(MAKEFLAGS) clobber
	cd sea; $(MAKE) -$(MAKEFLAGS) clobber
	if [ $(USE_ECUUNGETTY) = yes ]; then \
		cd ecuungetty; $(MAKE) -$(MAKEFLAGS) clobber; \
	fi

#regenerate .o:.h dependencies automatically
depend:
	rm -f depend.tmp
	if test '$(SRC)' ;\
	then (grep '^#include' $(SRC) \
	| sed	-e 's?:[^<]*<\([^>]*\)>.*?: /usr/include/\1?'\
		-e 's?:[^"]*"\([^"]*\)".*?: \1?'\
		-e 's?\(.*\)\.c?\1.o?'\
	 >> depend.tmp) ;\
	fi

	echo '/^# DO NOT DELETE THIS LINE' >eddep.tmp
	echo '.+1,$$d' >>eddep.tmp
	echo 'r depend.tmp' >> eddep.tmp
	echo 'w' >> eddep.tmp
	cp Makefile Makefile.new
	ed Makefile.new < eddep.tmp
	rm eddep.tmp depend.tmp
	echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile.new
	echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY'>>Makefile.new
	echo '# see make depend above'>>Makefile.new
	mv Makefile Makefile.bak
	mv Makefile.new Makefile
	cd help; $(MAKE) -$(MAKEFLAGS) depend
	cd z; $(MAKE) -$(MAKEFLAGS) depend
	cd sea; $(MAKE) -$(MAKEFLAGS) depend
	if [ $(USE_ECUUNGETTY) = yes ]; then \
		cd ecuungetty; $(MAKE) -$(MAKEFLAGS) depend; \
	fi

# DO NOT DELETE THIS LINE
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
