# Makefile for scm4e2 (Scheme implementation intended for JACAL).
# Copyright (C) 1990, 1991, 1992, 1993, 1994 Aubrey Jaffer.
# See the file "COPYING" for terms applying to this program

# directory where COPYING and Init.scm reside.
#IMPLPATH = /usr/local/src/scm/
#this one is good while debugging
IMPLPATH = `pwd`/

# Pathname where Init.scm resides.  This directory must also contain COPYING.
IMPLINIT = $(IMPLPATH)Init.scm
# DOS version.
DOSIMPLINIT = c:\\\scm\\\Init.scm

# If pathname where Init.scm resides is not known in advance then
# SCM_INIT_PATH is the environment variable whose value is the
# pathname where Init.scm resides.

prefix = /usr/local/
exec_prefix = $(prefix)/
# directory where `make install' will put executable.
bindir = $(exec_prefix)bin/
libdir = $(exec_prefix)lib/
# directory where `make install' will put manual page.
man1dir = $(prefix)man/man1/
infodir = $(prefix)info/
includedir = $(prefix)include/

#	CFLAGS	are user flags to the C compiler.
#	CSCM	cc flags due to platform and SCM options
#	CDLP	cc flags for program which can load dynamically
#	CDLL	ld flags for files which can be loaded dynamically

#	LD	statement for linking .o files
#	LDLP	cc flags for program which can load dynamically
#	LDLL	ld flags for files which can be loaded dynamically
#	LINK	statement for linking .OBJ files

################ PLATFORM DEFINITIONS ################

#	cc +O1		#workaround for HP-UX 9.01 bug.
#	cc -Wl,-E	#dynamic link flags for HP-UX 9.01.
#	cc -c +z	#flags for linkable files
#	$(LD) -b sc2.o -o sc2
#	From: fred@sce.carleton.ca (Fred J Kaudel)
#	-U, if get can't include machine file errors from sys/signal.h
#	during cc [-Ac] compiles under HP-UX A.08.07, or similar, then
#	try changing to either cc -Aa, if available, for this file
#	only, or replace the scm.o compilation line with the
#	following:
#	$(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $(DFLAG) scm.c -U__hp9000s800
HPUX_FLAGS = \
	CSCM=+O1 CDLP="-Wl,-E" LDLL=-b

#	cc -hvector2 -hscalar2		#for UNICOS, inlining breaks gc.
#	setjump.o #for Cray YMP
UNICOS_FLAGS = \
	CSCM="-hvector2 -hscalar2" LD="cc setjump.o"

#	gcc -O2 -traditional or gcc -g -O2 -Wall
GCC_FLAGS = \
	CSCM="-Wall -O2"

#	-Dunix is required for SCO and AIX
#	-lansi for SCO and XENIX
AIX_FLAGS = \
	CSCM="-O -Dunix" LD="cc -lansi" RM_R="delete -r"

#	-DSVR4 is required for Solaris 2.x and other SVR4 clones
SVR4_FLAGS = \
	CSCM="-O -DSVR4"

#	LDLP = -ldl		# for Sun-OS 4.1.x (and maybe Solaris)
SUN_FLAGS = \
	LDLP=-ldl CDLP=-DSUN_DL

#	LDLP = -ldld		# for Linux
#	-lncurses on linux (curses has bugs).
LINUX_FLAGS = \
	LDLP=-ldld CDLP="-DDLD -DDLD_DYNCM" LBCRS=-lncurses \
	INCRS=-I/usr/include/ncurses $(GCC_FLAGS)

#	-f- no floating point
#	-d merge duplicate strings
#	-O jump optimization
#	-Z register optimization
#	-G optimize for speed
#	-w-pro to eliminate "without prototype" messages
#	-N stack bounds checking
#	-W Creates an .OBJ for Windows with all functions exportable
#	-ml Use large memory model
#	For turtlscm compile?:
#	CFLAGS=-c -a -d -r -w -G -O -Z -v- -y- -N- -O-a -k- \
#	-Ob -Oe -Oi -Og -Ol -Om -Op -Ov -w-pro -w-sig -DFLOATS
#	For Debugging:
#	CFLAGS=-c -f- -O -N -v -y
#	LFLAGS=-M -v
BCC_FLAGS = \
	CC=bcc -DCSCM="-d -O -Z -G -w-pro -ml" \
	-DLINK="bcc -ml" -DFGNM=-f-

BCW_FLAGS = \
	CC=bcc -DCSCM="-d -O -Z -G -w-pro -N -ml -W" \
	-DLINK="bcc -ml -W" -DFGNM=-f-

#	-static is required with gcc under OSF/1 V1.2 on DEC Alpha.

################ TARGET DEFINITIONS ################

INCRS = -I/usr/include/
# some systems also require -ltermcap
# -lcurses for `curses'
LBCRS = -lcurses

# GNU Regex
#INRGX = -I../regex-0.11/
#LBRGX = -l../regex-0.11/regex.o

# Default
XINCLUDEPATH=/usr/local/X11R5/include

# WB database library path
DBAPATH=../wb/db.a

# flags for fancy numbers (floating point and bignums)
# -DBIGNUMS turns on support for large precision integers.
# -DFLOATS turns on support for inexact numbers.
# -DENGNOT for engineering notation instead of scientific notation.
# FGM = -DFLOATS -DENGNOT -DBIGNUMS
# -lm for -DFLOATS
LBM = -lm

#you should not need to change below this line.

LD = $(CC)

AR = ar
RM_R = rm -rf
#MAKE = make
RANLIB = ranlib

ofiles = time.o repl.o scl.o sys.o eval.o subr.o unif.o
objfiles = time.obj repl.obj scl.obj sys.obj eval.obj subr.obj unif.obj

#	odlfiles are dynamically linkable files
odlfiles = sc2.o turtlegr.o rgx.o crs.o

RUNFILES = scm scmlit turtlscm dscm curscm libscm
PLATFORMS=hpux unicos gcc aix svr4 sun linux bcc bcw

SHELL = /bin/sh
intro:
	@echo ""
	@echo "This is scm$(VERSION).  This is the new generalized"
	@echo "'Makefile' for unix and other systems.  If you have"
	@echo "problems with it let me know.  Also available is the"
	@echo "following:"
	@echo ""
	@echo "  From: bos@scrg.cs.tcd.ie"
	@echo "  Build and install scripts using GNU autoconf are"
	@echo "  available as scmconfig.tar.gz in the SCM distribution"
	@echo "  directories.  See README.unix in scmconfig.tar.gz for"
	@echo "  further instructions."
	@echo ""
	@echo "IMPLINIT (DOSIMPLINIT for DOS or Windows) in the"
	@echo "'Makefile' determines where SCM will look for its"
	@echo "startup code.  IMPLINIT can be overridden by the"
	@echo "environment variable SCM_INIT_PATH when SCM is run."
	@echo ""
	@echo "To build, type 'make DO=scm <platform>'"
	@echo "  where <platform> is one of"
	@echo "$(PLATFORMS)"
	@echo ""
	@echo "Once you have built scm successfully, test it:"
	@echo "      make DO=scm check"
	@echo ""
	@echo "To install SCM, type 'make install'"
	@echo ""
	@echo "This 'makefile' can also build variations on SCM."
	@echo "Type 'make DO=<target> <platform>'"
	@echo "  where <target> is one of"
	@echo "$(RUNFILES)"
	@echo ""

hpux Hpux HPUX hp-ux Hp-ux HP-UX:
	$(MAKE) $(HPUX_FLAGS) _$(DO)
unicos Unicos UNICOS:
	$(MAKE) $(UNICOS_FLAGS) _$(DO)
gcc Gcc GCC:
	$(MAKE) $(GCC_FLAGS) _$(DO)
aix Aix AIX:
	$(MAKE) $(AIX_FLAGS) _$(DO)
svr4 Svr4 SVR4:
	$(MAKE) $(SVR4_FLAGS) _$(DO)
sun Sun SUN:
	$(MAKE) $(SUN_FLAGS) _$(DO)
linux Linux LINUX:
	$(MAKE) $(LINUX_FLAGS) _$(DO)
bcc Bcc BCC:
	$(MAKE) $(BCC_FLAGS) _$(DO).exe
bcw Bcw BCW:
	$(MAKE) $(BCW_FLAGS) _$(DO).exe

check:	test.scm
	$(DO) -ftest.scm -e'(test-sc4)(test-cont)(test-delay)(gc)'

_scmlit.exe _Scmlit.exe _SCMLIT.exe:
	$(MAKE) "-DCSCM=$(CSCM) $(FGNM)" $(objfiles) scm.obj
	$(LINK) scm.obj $(objfiles)
	ren scm.exe scmlit.exe
_scm.exe _Scm.exe _SCM.exe:
	del scmflags.h
	echo "#define FLOATS" > scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	echo "#define IMPLINIT \"$(DOSIMPLINIT)\"" >> scmflags.h
	$(MAKE) "-DCSCM=$(CSCM)" $(objfiles) scm.obj
	$(LINK) scm.obj $(objfiles) $(LBM)
_turtlscm.exe _Turtlscm.exe _TURTLSCM.exe:
	del scmflags.h
	echo "#define FLOATS" > scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	echo "#define IMPLINIT \"$(DOSIMPLINIT)\"" >> scmflags.h
	echo "#define INITS init_sc2\(\)\;init_turtlegr\(\)" >> scmflags.h
	$(MAKE) "-DCSCM=$(CSCM)" sc2.obj turtlegr.obj $(objfiles) scm.obj
	$(LINK) scm.obj turtlegr.obj sc2.obj graphics.lib
	ren scm.exe turtlscm.exe

_scmlit _Scmlit _SCMLIT:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM) $(FGNM)" $(ofiles) scm.o
	$(LD) -o scmlit scm.o $(ofiles)
_scm _Scm _SCM:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	echo "#define FLOATS" >> scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM)" $(ofiles) scm.o
	$(LD) -o scm scm.o $(ofiles) $(LBM)
_turtlscm _Turtlscm _TURTLSCM:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	echo "#define FLOATS" >> scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	echo "#define INITS init_sc2();init_turtlegr()" >> scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM)" sc2.o turtlegr.o $(ofiles) scm.o
	$(LD) -o turtlscm scm.o $(ofiles) turtlegr.o sc2.o -lX11 $(LBM)
_dscm _Dscm _DSCM:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	echo "#define FLOATS" >> scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM) $(CDLP)" $(ofiles) dynl.o scm.o
	$(LD) -o dscm $(ofiles) dynl.o scm.o $(LDLP) $(LBM)
#	strip -S -X -x dscm		# for Linux
	$(MAKE) "CSCM=$(CDLL)" "LDLL=$(LDLL)" -k $(odlfiles)
_curscm _Curscm _CURSCM:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	echo "#define FLOATS" >> scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	echo "#define INITS init_sc2();init_crs();init_rgx()" >> scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM)" $(ofiles) scm.o rgx.o crs.o sc2.o
	$(LD) -o curscm $(ofiles) scm.o rgx.o crs.o sc2.o \
	$(LBM) $(LBCRS) $(LBRGX)
_dbscm _Dbscm _DBSCM:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	echo "#define INITS init_db()" >> scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM)" $(ofiles) scm.o
	$(LD) -o dbscm scm.o $(ofiles) $(DBAPATH)

_libscm _Libscm _LIBSCM:
	-mv -f scmflags.h scmflags.h~
	echo "#define IMPLINIT \"$(IMPLINIT)\"" > scmflags.h
	echo "#define FLOATS" >> scmflags.h
	echo "#define ENGNOT" >> scmflags.h
	echo "#define BIGNUMS" >> scmflags.h
	echo "#define ARRAYS" >> scmflags.h
	echo "#define IO_EXTENSIONS" >> scmflags.h
	echo "#define RTL" >> scmflags.h
	echo "#define INITS init_init_user_scm()" >> scmflags.h
	-if cmp -s scmflags.h~ scmflags.h;then mv -f scmflags.h~ scmflags.h;fi
	-rm scm.o
	$(MAKE) "CSCM=$(CSCM)" $(ofiles) scm.o
	rm -f libscm.a
	$(AR) rc libscm.a scm.o $(ofiles)
	-$(RANLIB) libscm.a

# -DRTL if this is a run-time library only (no interactive top level)
# -DRECKLESS if you want most scm error checking disabled.
# -DSTACK_LIMIT=(HEAP_SEG_SIZE/2) to enable stack checking.

# INITS = the initialization calls for user extension files.
#File:	INITS line:		functions defined:
#sc2.c	init_sc2\(\)	substring-move-left!, substring-move-right!,
#			substring-fill!, append!, and last-pair
#rgx.c	init_rgx\(\)	regcomp and regexec.
#crs.c	init_crs\(\)	lots.

# user extension files or machine specific files: rgx.o dynl.o sc2.o

_scm.a:	$(ofiles)
	$(AR) crv scm.a $(ofiles)

ALL_CFLAGS = $(CSCM) $(CFLAGS)
DFLAG = -DIMPLINIT=\"$(IMPLINIT)\"

scm.o:	scm.c scm.h scmfig.h patchlvl.h scmflags.h
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $(DFLAG) scm.c 
scm.obj:	scm.c scm.h scmfig.h patchlvl.h
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -DHAVE_CONFIG_H scm.c

.c.o:
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< -o $@
.c.obj:
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -DHAVE_CONFIG_H $<

scl.o:	scl.c scm.h scmfig.h scmflags.h
eval.o:	eval.c scm.h scmfig.h scmflags.h setjump.h
unif.o:	unif.c scm.h scmfig.h scmflags.h
repl.o:	repl.c scm.h scmfig.h scmflags.h setjump.h
sys.o:	sys.c scm.h scmfig.h scmflags.h setjump.h
time.o:	time.c scm.h scmfig.h scmflags.h
subr.o:	subr.c scm.h scmfig.h scmflags.h
dynl.o:	dynl.c scm.h scmfig.h scmflags.h

scl.obj:	scl.c scm.h scmfig.h
eval.obj:	eval.c scm.h scmfig.h setjump.h
unif.obj:	unif.c scm.h
repl.obj:	repl.c scm.h scmfig.h setjump.h
sys.obj:	sys.c scm.h scmfig.h setjump.h
time.obj:	time.c scm.h scmfig.h
subr.obj:	subr.c scm.h scmfig.h
dynl.obj:	dynl.c scm.h scmfig.h
sc2.obj:	sc2.c scm.h
turtlegr.obj:	turtlegr.c scm.h scmfig.h
	$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) turtlegr.c

# Now for dynamically loadable files:

sc2.o:	sc2.c scm.h
rgx.o:	rgx.c scm.h scmfig.h
	$(CC) -c $(INRGX) $(CPPFLAGS) $(ALL_CFLAGS) rgx.c -o $@
crs.o:	crs.c scm.h scmfig.h
	$(CC) -c $(INCRS) $(CPPFLAGS) $(ALL_CFLAGS) crs.c -o $@
turtlegr.o:	turtlegr.c scm.h scmfig.h turtle
	$(CC) -c -DX11 -I$(XINCLUDEPATH) \
	$(CPPFLAGS) $(ALL_CFLAGS) turtlegr.c -o $@

install:	scm.1
	test -d $(bindir) || mkdir $(bindir)
	test -d $(man1dir) || mkdir $(man1dir)
	-cp scm $(bindir)
	-strip $(bindir)scm
	-cp scm.1 $(man1dir)
	test -d $(IMPLPATH) || mkdir $(IMPLPATH)
	-cp Init.scm $(IMPLPATH)
	-cp Link.scm $(IMPLPATH)
	-cp Transcen.scm $(IMPLPATH)
	-cp COPYING $(IMPLPATH)

installlib:
	test -d $(includedir) || mkdir $(includedir)
	cp scm.h $(includedir)scm.h
	cp scmfig.h $(includedir)scmfig.h
	test -d $(libdir) || mkdir $(libdir)
	cp libscm.a $(libdir)libscm.a

uninstall:
	-rm $(bindir)scm
	-rm $(man1dir)scm.1
	-rm $(includedir)scm.h
	-rm $(includedir)scmfig.h
	-rm $(libdir)libscm.a
#	-rm $(IMPLPATH)Init.scm
#	-cp $(IMPLPATH)Link.scm
#	-rm $(IMPLPATH)Transcen.scm
#	-rm $(IMPLPATH)COPYING

scm.doc:	scm.1
	nroff -man $< >$@

#### Stuff for maintaining SCM below ####

VERSION = 4e2
ver = $(VERSION)
cfiles = scm.c time.c repl.c scl.c sys.c eval.c subr.c sc2.c unif.c \
	rgx.c crs.c dynl.c
confiles = INSTALL.unix configure configure.in scmconfig.h.in \
	mkinstalldirs Makefile.in acconfig-1.5.h
hfiles = scm.h scmfig.h setjump.h patchlvl.h
ifiles = Init.scm Transcen.scm Link.scm
tfiles = test.scm example.scm pi.scm pi.c split.scm
dfiles = ANNOUNCE README COPYING scm.1 scm.doc QUICKREF MANUAL ChangeLog \
	code.doc
mfiles = Makefile makefile.unix makefile.msc makefile.bor makefile.tur\
	makefile.djg makefile.emx makefile.qc compile.amiga link.amiga \
	makefile.aztec makefile.ast makefile.prj dmakefile makefile.wcc \
	makefile.acorn
vfiles = setjump.mar VMSBUILD.COM VMSGCC.COM setjump.s
afiles = $(dfiles) $(cfiles) $(hfiles) $(ifiles) $(tfiles) $(mfiles) $(vfiles)

makedev = make -f $(HOME)/makefile.dev
dest = $(HOME)/dist/
temp/scm:	$(afiles)
	-$(RM_R) temp
	mkdir temp
	mkdir temp/scm
	ln $(afiles) temp/scm

dist:	$(dest)scm$(VERSION).tar.gz
$(dest)scm$(VERSION).tar.gz:	temp/scm
	$(makedev) DEST=$(dest) PROD=scm ver=$(VERSION) tar.gz
shar:	scm.shar
scm.shar:	temp/scm
	$(makedev) PROD=scm shar
dclshar:	scm.com
com:	scm.com
scm.com:	temp/scm
	$(makedev) PROD=scm com
zip:	scm.zip
scm.zip:	temp/scm
	$(makedev) PROD=scm zip
distzip:	scm$(VERSION).zip
scm$(VERSION).zip:	temp/scm turtle turtlegr.c grtest.scm
	$(makedev) DEST=$(dest) PROD=scm ver=$(VERSION) zip
	cd ..; zip -ur $(dest)scm$(VERSION).zip \
		scm/turtle scm/turtlegr.c scm/grtest.scm
	mv $(dest)scm$(VERSION).zip /d/scm/dist/
pubzip:	temp/scm
	$(makedev) DEST=$(HOME)/pub/ PROD=scm zip

diffs:	pubdiffs
pubdiffs:	temp/scm
	$(makedev) DEST=$(HOME)/pub/ PROD=scm pubdiffs
distdiffs:	temp/scm
	$(makedev) DEST=$(dest) PROD=scm ver=$(ver) distdiffs


HOBBITVERSION = 3
hobfiles = README.hob hobbit.doc hobbit.tms hobbit.scm scmhob.h

hobtemp/scm:	$(hobfiles)
	-$(RM_R) hobtemp
	mkdir hobtemp
	mkdir hobtemp/scm
	ln $(hobfiles) hobtemp/scm

hobdist:	$(dest)hobbit$(HOBBITVERSION).tar.gz
$(dest)hobbit$(HOBBITVERSION).tar.gz:	hobtemp/scm
	$(makedev) DEST=$(dest) PROD=scm ver=-hob$(HOBBITVERSION) \
		tar.gz TEMP=hobtemp/
	mv $(dest)scm-hob$(HOBBITVERSION).tar.gz \
		$(dest)hobbit$(HOBBITVERSION).tar.gz

new:
	chpat scm$(VERSION) scm$(ver) ANNOUNCE ../jacal/ANNOUNCE \
		../wb/README ../wb/ANNOUNCE \
		/d/scm/dist/install.bat /d/scm/dist/makefile
	chpat $(VERSION) $(ver) README MANUAL patchlvl.h Init.scm \
		Makefile makefile.unix

temp/scmconfig:	$(confiles)
	-$(RM_R) temp/scmconfig
	-mkdir temp
	mkdir temp/scmconfig
	ln $(confiles) temp/scmconfig
confdist:	scmconfig.tar.gz
scmconfig.tar.gz:	temp/scmconfig
	cd temp; tar cohf ../scmconfig.tar scmconfig
	chmod 664 scmconfig.tar
	-rm -f scmconfig.tar.*z
	gzip scmconfig.tar
	chmod 664 scmconfig.tar.*z

lint:	lints
lints:	$(cfiles) $(hfiles)
	lint $(CPPFLAGS) $(ALL_CFLAGS) $(cfiles) | tee lints
#	lint $(CPPFLAGS) $(ALL_CFLAGS) $(cfiles) | tee lintes

#seds to help find names not unique in first 8 characters (name8s)
# for BSD nm format
SED_TO_STRIP_NM=sed -e '/.*\.o$$/d' -e 's/.* _//' -e 's/.* T //'
#old, bad for T [^_] on suns: SED_TO_STRIP_NM=sed -e '/.*\.o$$/d' -e 's/.* _//'
# For a System V nm where plain C identifiers have _ prepended:
#SED_TO_STRIP_NM=sed -e '/^_[A-Za-z][A-za-z0-9_]*[ 	|].*|extern|!d' -e 's/|/ /g' -e 's/^_//'
# For a System V nm where plain C identifiers have nothing prepended:
#SED_TO_STRIP_NM=sed -e '/^[A-Za-z][A-za-z0-9_]*[ 	|].*|extern|!d' -e 's/|/ /g'

name8:	name8s
name8s:	scm
	nm scm |\
	$(SED_TO_STRIP_NM) |\
	sort -u|\
	awk '{	if (substr(l,1,8)==substr($$1,1,8)) {\
			if (p) print l;\
			print $$1;p=0;stat=1\
		}else p=1;\
		l=$$1\
	     }END{exit stat}' -
ctags:	$(hfiles) $(cfiles) code.doc
	etags $(hfiles) $(cfiles) code.doc
TAGS:
tags:	$(hfiles) $(cfiles) $(ifiles) $(mfiles) $(vfiles) \
	MANUAL code.doc README
	etags $(hfiles) $(cfiles) $(ifiles) $(mfiles) $(vfiles) \
	MANUAL code.doc README
mostlyclean:
clean:
	-rm -f *~ *.bak *.orig *.rej core a.out *.o lints tmp* \#* *\#
	-$(RM_R) *temp
distclean:	clean
	-rm -f $(EXECFILES) a.out TAGS
realclean:	distclean
	-rm -f scm.doc
realempty:	temp/scm
	-rm -f $(afiles)
