# CKUKER.MAK, Mon Dec  5 13:50:05 1994
#
CKVER= "5A(190)"
#
# -- Makefile to build C-Kermit 5A for UNIX and UNIX-like systems --
#
# INSTALLATION NOTES:
#
# For more detailed installation instructions, read the files ckuins.doc and
# ckccfg.doc.  For descriptions of known problems and limitations, read the
# files ckcker.bwr and ckuker.bwr (the "beware files").
# 
###########################################################################
#
#  Compile and Link variables:
#
#  EXT is the extension (file type) for object files, normally o.
#  See MINIX entry for what to do if another filetype must be used.
#
EXT=o
#LNKFLAGS=
SHAREDLIB=
CC= cc
CC2= cc
MAKE= make
SHELL=/bin/sh
#
###########################################################################
# SAMPLE ONLY.
# Easy installation. Modify this to suit your own computer's file organization
# and permissions.  If you don't have write access to the destination
# directories, "make install" will fail.

WERMIT = sys3upcc
DESTDIR =
BINDIR = /usr/local/bin
MANDIR = /usr/man/manl
MANEXT = l
ALL = $(WERMIT)

all: $(ALL)

install: $(ALL)
	cp wermit $(DESTDIR)$(BINDIR)/kermit
# The following can fail if the program image was already stripped,
# for example by the link flags in the makefile entry.
#	strip $(DESTDIR)$(BINDIR)/kermit
	chmod 755 $(DESTDIR)$(BINDIR)/kermit
	cp ckuker.nr $(DESTDIR)$(MANDIR)/kermit.$(MANEXT)
# To make sure 'man' notices the new source file and doesn't keep
# showing the old formatted version, remove the old formatted version,
# something like this:
#	rm -f $(DESTDIR)$(MANDIR)/../cat$(MANEXT)/kermit.$(MANEXT)
# or this (which requires CATDIR to be defined):
#	rm -f $(DESTDIR)$(CATDIR)/kermit.$(MANEXT)
	chmod 644 $(DESTDIR)$(MANDIR)/kermit.$(MANEXT)

makewhat:
	@echo 'make what?  You must tell which system to make C-Kermit for.'
	@echo Examples:  make hpux90, make sys5r4, make solaris2x, etc.
	@echo Please read the comments at the beginning of the makefile.

###########################################################################
#
# Dependencies Section:

manpage: ckuker.nr

wermit:	ckcmai.$(EXT) ckucmd.$(EXT) ckuusr.$(EXT) ckuus2.$(EXT) ckuus3.$(EXT) \
		ckuus4.$(EXT) ckuus5.$(EXT) ckuus6.$(EXT) ckuus7.$(EXT) \
		ckuusx.$(EXT) ckuusy.$(EXT) ckcpro.$(EXT) ckcfns.$(EXT) \
		ckcfn2.$(EXT) ckcfn3.$(EXT) ckuxla.$(EXT) ckucon.$(EXT) \
		ckutio.$(EXT) ckufio.$(EXT) ckudia.$(EXT) ckuscr.$(EXT) \
		ckcnet.$(EXT)
	$(CC2) $(LNKFLAGS) -o wermit ckcmai.$(EXT) ckutio.$(EXT) \
		ckufio.$(EXT) ckcfns.$(EXT) ckcfn2.$(EXT) ckcfn3.$(EXT) \
		ckuxla.$(EXT) ckcpro.$(EXT) ckucmd.$(EXT) ckuus2.$(EXT) \
		ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) ckuus6.$(EXT) \
		ckuus7.$(EXT) ckuusx.$(EXT) ckuusy.$(EXT) ckuusr.$(EXT) \
		ckucon.$(EXT) ckudia.$(EXT) ckuscr.$(EXT) ckcnet.$(EXT) $(LIBS)

#Malloc Debugging version

mermit:	ckcmdb.$(EXT) ckcmai.$(EXT) ckucmd.$(EXT) ckuusr.$(EXT) ckuus2.$(EXT) \
		ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) ckuus6.$(EXT) \
		ckuus7.$(EXT) ckuusx.$(EXT) ckuusy.$(EXT) ckcpro.$(EXT) \
		ckcfns.$(EXT) ckcfn2.$(EXT) ckcfn3.$(EXT) ckuxla.$(EXT) \
		ckucon.$(EXT) ckutio.$(EXT) ckufio.$(EXT) ckudia.$(EXT) \
		ckuscr.$(EXT) ckcnet.$(EXT)
	$(CC2) $(LNKFLAGS) -o mermit ckcmdb.$(EXT) ckcmai.$(EXT) \
		ckutio.$(EXT) ckufio.$(EXT) ckcfns.$(EXT) ckcfn2.$(EXT) \
		ckcfn3.$(EXT) ckuxla.$(EXT) ckcpro.$(EXT) ckucmd.$(EXT) \
		ckuus2.$(EXT) ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) \
		ckuus6.$(EXT) ckuus7.$(EXT) ckuusx.$(EXT) ckuusy.$(EXT) \
		ckuusr.$(EXT) ckucon.$(EXT) ckudia.$(EXT) ckuscr.$(EXT) \
		ckcnet.$(EXT) $(LIBS)

strings.o: strings
	xstr
	cc -c xs.c
	mv -f xs.o strings.o
	rm -f xs.c

###########################################################################
# man page...
#
# WARNING: Using "cc -E" to preprocess the man page is not portable, but it
# works OK in SunOS 4.1.x, HP-UX, etc.  We use the preprocessor to produce
# custom man pages based on ifdef, else, and endif directives.  But the
# preprocessor replaces omitted lines by blank lines and comment lines, so we
# use grep to filter them out.  THIS MEANS THAT THE SOURCE FILE, ckuker.cpp,
# MUST NOT CONTAIN ANY BLANK LINES!
#
ckuker.nr: ckuker.cpp
	$(CC) $(CFLAGS) -E ckuker.cpp |grep -v "^$$" |grep -v "^\#" > ckuker.nr

###########################################################################
# Dependencies for each module...
#
ckcmai.$(EXT): ckcmai.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcnet.h

ckcpro.$(EXT): ckcpro.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h

ckcpro.c: ckcpro.w wart ckcdeb.h ckcsym.h ckcasc.h ckcker.h
	./wart ckcpro.w ckcpro.c

ckcfns.$(EXT): ckcfns.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h \
		ckuxla.h

ckcfn2.$(EXT): ckcfn2.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h ckuxla.h

ckcfn3.$(EXT): ckcfn3.c ckcker.h ckcdeb.h ckcsym.h ckcasc.h ckcxla.h \
		ckuxla.h

ckuxla.$(EXT): ckuxla.c ckcker.h ckcsym.h ckcdeb.h ckcxla.h ckuxla.h

ckuusr.$(EXT): ckuusr.c ckucmd.h ckcker.h ckuusr.h ckcsym.h ckcdeb.h ckcxla.h \
		ckuxla.h ckcasc.h ckcnet.h

ckuus2.$(EXT): ckuus2.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
		ckcasc.h ckcnet.h ckcsym.h

ckuus3.$(EXT): ckuus3.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
		ckcasc.h ckcnet.h ckcsym.h

ckuus4.$(EXT): ckuus4.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
		ckcasc.h ckcnet.h ckuver.h ckcsym.h

ckuus5.$(EXT): ckuus5.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcasc.h ckcnet.h \
		 ckcsym.h

ckuus6.$(EXT): ckuus6.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcasc.h ckcnet.h \
		 ckcsym.h

ckuus7.$(EXT): ckuus7.c ckucmd.h ckcker.h ckuusr.h ckcdeb.h ckcxla.h ckuxla.h \
		ckcasc.h ckcnet.h ckcsym.h

ckuusx.$(EXT): ckuusx.c  ckcker.h ckuusr.h ckcdeb.h ckcasc.h ckcsym.h

ckuusy.$(EXT): ckuusy.c  ckcker.h ckcdeb.h ckcasc.h ckcnet.h ckcsym.h

ckucmd.$(EXT): ckucmd.c ckcasc.h ckucmd.h ckcdeb.h ckcsym.h

ckufio.$(EXT): ckufio.c ckcdeb.h ckuver.h ckcsym.h

ckutio.$(EXT): ckutio.c ckcdeb.h ckcnet.h ckuver.h ckcsym.h

ckucon.$(EXT): ckucon.c ckcker.h ckcdeb.h ckcasc.h ckcnet.h ckcsym.h

ckcnet.$(EXT): ckcnet.c ckcdeb.h ckcker.h ckcnet.h ckcsym.h

wart: ckwart.$(EXT)
	$(CC) $(LNKFLAGS) -o wart ckwart.$(EXT) $(LIBS)

ckcmdb.$(EXT): ckcmdb.c ckcdeb.h ckcsym.h

ckwart.$(EXT): ckwart.c

ckudia.$(EXT): ckudia.c ckcker.h ckcdeb.h ckucmd.h ckcasc.h ckcsym.h

ckuscr.$(EXT): ckuscr.c ckcker.h ckcdeb.h ckcasc.h ckcsym.h

###########################################################################
#
# Entries to make C-Kermit for specific systems.
#
# Put the ones that need short makefiles first.

#AT&T 7300/UNIX PC (3B1) systems, sys3 but special handling for internal modem.
#Link with the shared library -- the conflict with openi in shared library
#is solved with -Dopeni=xopeni
sys3upc:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC, shared lib...'
	@echo 'If shared lib causes trouble, use make sys3upcold.'
	$(MAKE) wermit \
	"CFLAGS = -O -DATT7300 -DDYNAMIC -DNOSETBUF -DNOMKDIR -DNOCSETS \
	-DNODEBUG -DMINIDIAL $(KFLAGS) -Dopeni=xopeni" \
	"CC2 = ld /lib/crt0s.o /lib/shlib.ifile" "LNKFLAGS = -s"

#AT&T 7300/UNIX PC (3B1) systems, with curses support.
#Curses and the shared library don't get along, so we don't use the
#shared library.  We need to include CK_NEWTERM to avoid a conflict
#with curses and buffering on stdout.  Merged with submission by
#Robert Weiner/Programming Plus, rweiner@watsun.cc.columbia.edu.
#We don't need -Dopeni=xopeni since we're not using the shared library,
#but we keep it to be consistent with the other entries.
sys3upcc:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC, curses...'
	$(MAKE) wermit "CFLAGS = -O -DATT7300 -DDYNAMIC -DNOSETBUF \
	-DCK_CURSES -DCK_NEWTERM -DNOMKDIR $(KFLAGS) -Dopeni=xopeni" \
	"LIBS = -lcurses" "LNKFLAGS = -s"

#AT&T 7300 UNIX PC (3B1), as above, but no newterm().
sys3upcx:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC, curses...'
	$(MAKE) wermit "CFLAGS = -O -DATT7300 -DDYNAMIC -DNOSETBUF \
	-DCK_CURSES -DNOMKDIR $(KFLAGS) -Dopeni=xopeni" \
	"LIBS = -lcurses -ltermcap" "LNKFLAGS = -s"

#AT&T 7300/UNIX PC (3B1) systems, with curses and shared library support.
sys3upcshcc:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC, shared lib...'
	@echo 'With curses.  Requires shcc.'
	$(MAKE) wermit "CFLAGS = -O -DATT7300 -DDYNAMIC -DNOMKDIR \
	-DNOSETBUF -DCK_NEWTERM -DCK_CURSES $(KFLAGS) -Dopeni=xopeni" \
	"LNKFLAGS = -i -s" "CC = shcc" "CC2 = shcc" "LIBS = -lcurses"

#AT&T 7300/UNIX PC (3B1) systems, as above, no curses, but use gcc.
sys3upcg:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC...'
	$(MAKE) wermit \
	"CFLAGS = -O -DATT7300 -DDYNAMIC -DNOSETBUF -DNOMKDIR $(KFLAGS) \
	-Dopeni=xopeni" \
	"CC = gcc" "CC2 = gcc" "LNKFLAGS = -s -shlib"

#AT&T 7300/UNIX PC (3B1) systems, curses and gcc.
sys3upcgc:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC, curses...'
	$(MAKE) wermit "CFLAGS = -O -DATT7300 -DDYNAMIC -DNOSETBUF \
	-DCK_CURSES -DIFDEBUG -DCK_NEWTERM -DNOMKDIR $(KFLAGS)" \
	"CC = gcc" "CC2 = gcc" "LIBS = -lcurses" "LNKFLAGS = -s"

#AT&T 7300/UNIX PC (3B1) systems, special handling for internal modem.
#No FULLSCREEN file transfer display (curses).
sys3upcold:
	@echo 'Making C-Kermit $(CKVER) for AT&T 7300 UNIX PC...'
	$(MAKE) wermit "CFLAGS = -DATT7300 -DNOMKDIR $(KFLAGS) -O" \
	"LNKFLAGS = -i"

#AT&T 7300/Unix PC systems, minimum kermit for those with smaller amounts
#of memory.
sys3upcm:
	@echo Minimum interactive
	$(MAKE) "MAKE=$(MAKE)" sys3upc \
	"KFLAGS=-DNOSPL -DNOFRILLS -DNOHELP -DNODEBUG -DNOTLOG -DNOCSETS \
	-DNOSETKEY -DNOSETBUF"

#As above, but with gcc...
sys3upcgm:
	@echo Minimum interactive
	$(MAKE) "MAKE=$(MAKE)" sys3upcg \
	"KFLAGS=-DNOSPL -DNOFRILLS -DNOHELP -DNODEBUG -DNOTLOG -DNOCSETS \
	-DNOSETKEY -DNOSETBUF"

#Clean up intermediate and object files
clean:
	@echo 'Removing object files...'
	-rm -f ckcmai.$(EXT) ckucmd.$(EXT) ckuusr.$(EXT) ckuus2.$(EXT) \
ckuus3.$(EXT) ckuus4.$(EXT) ckuus5.$(EXT) ckcpro.$(EXT) ckcfns.$(EXT) \
ckcfn2.$(EXT) ckcfn3.$(EXT) ckuxla.$(EXT) ckucon.$(EXT) ckutio.$(EXT) \
ckufio.$(EXT) ckudia.$(EXT) ckuscr.$(EXT) ckwart.$(EXT) ckuusx.$(EXT) \
ckuusy.$(EXT) ckcnet.$(EXT) ckuus6.$(EXT) ckuus7.$(EXT) ckcmdb.$(EXT) \
ckcpro.c wart

#Run Lint on this mess for the SUN/BSD version.
lintsun:
	@echo 'Running Lint on C-Kermit $(CKVER) sources for SunOS version...'
	lint -x -DSUNOS4 -DDIRENT -DTCPSOCKET -DSAVEDUID -DDYNAMIC \
	ck[cu]*.c > ckuker.lint.sun

lintbsd:
	@echo 'Running Lint on C-Kermit $(CKVER) sources for BSD 4.2 version..'
	lint -x -DBSD4 -DTCPSOCKET ck[cu]*.c > ckuker.lint.bsd42

lints5:
	@echo 'Running Lint on C-Kermit $(CKVER) sources for Sys V version...'
	lint -x -DATTSV ck[cu]*.c > ckuker.lint.s5

lintmips:
	@echo 'Running lint on C-Kermit $(CKVER) sources for MIPS version...'
	lint -DMIPS -DDIRENT -DPID_T=int -DGID_T=gid_t \
	-DUID_T=uid_t -DNOJC ck[cu]*.c > ckuker.lint.mips

ckuuid:
	@echo 'building C-Kermit $(CKVER) set-UID/set-GID test programs'
	$(CC) -DANYBSD -DSAVEDUID -o ckuuid1 ckuuid.c
	$(CC) -DANYBSD -o ckuuid2 ckuuid.c
	$(CC) -DANYBSD -DNOSETREU -o ckuuid3 ckuuid.c
	$(CC) -DANYBSD -DSETEUID -DNOSETREU -o ckuuid4 ckuuid.c
	$(CC) -o ckuuid5 ckuuid.c
	@echo 'Read the top of ckuuid.c for directions...for testing'
	@echo 'you must make these programs setuid and setgid'

#Remember TECO?
love:
	@echo 'Not war?'
