#/*
# * The Termprocessor Kimwitu
# *
# * Copyright (c) 1991 University of Twente, Dept TIOS.
# * All rights reserved.
# *
# */
# This is the makefile for kc.
#
# Usage: make [ GENDIR=yourgendirpath ]
#		will bootstrap kc in directory GENDIR, by default set to ./Gen
# Usage: make new [ GENDIR=yourgendirpath ]
#		will make a new kc in directory GENDIR, by default set to ./Gen,
#		using an existent version, that should be in the PATH

#
RCSMAKEID = '"@('$(HACK)')$$Id: Makefile,v 2.78 1998/03/18 16:55:24 belinfan Rel $$"'
#
# files:
#  kimwy.y	grammar
#  kimwl.l	lexicals
#  kimw.*.k	all the rest
# note that the ORDER of the .k files is IMPORTANT (for cat / KC)
SHELL = /bin/sh
ROOT = .
GENDIR = Gen
DISTRDIR=$(ROOT)/Distr


# because we use $(KIMWITUVERSION) as symbolic RCS name,
# KIMWITUVERSION is *not* allowed to contain dots: we use _ instead
KIMWITUVERSION = `fgrep KIMWITUVERSION $(PATCHLEVELFILE) | awk '{print $$3}' | tail -1`

# The stuf below makes that RCSVERSIONID contains the version string, that
# can be used in: cc -DVERSION=$(RCSVERSIONID)
# This can be done a lot easier if cpp allows string concatenation as in ANSI C
# Currently: we put the RCS keyword for the RCSVERSIONID in a separate macro, to
# avoid expansion by RCS
# Apart from that, we have to hack in the hash (#) symbol, currently using tr.
KIMWITUCOPYRIGHTDEFINE = KIMWITUCOPYRIGHT $(RCSCOPYRIGHTID)
MAKEFILEVERSIONDEFINE = RCSMAKEID $(RCSMAKEID)
NODEFAULTINWITHDEFINE = #-DKC_NO_DEFAULT_IN_WITH='"kc: internal error: no default action defined in with at line %s%d of file %s\\n"'
HACK = `echo a | tr 'a' '\043'`
RCSKEYWORD = Author
RCSCOPYRIGHTID = '"@('$(HACK)')$$$(RCSKEYWORD): $(RESTRCSCOPYRIGHTID) $$"'
RESTRCSCOPYRIGHTID = Kimwitu version: '$(KIMWITUVERSION)' (c) 1990-1996 University of Twente

KIMWITUVERSIONSTRINGDEFINE = KIMWITUVERSIONSTRING '"'$(KIMWITUVERSION)'"'
KIMWITURELEASEDEFINE = KIMWITURELEASE $(RCSRELEASE)
RCSRELEASE = '"@('$(HACK)')RELEASE VERSION $(RESTRCSRELEASE)"'
RESTRCSRELEASE = '$(KIMWITUVERSION)'
# If this defines KC_USE_STAT then fstat will be used in main.k
USESTATDEFINE =  KC_USE_STAT
OLD = $(KIMWITUVERSION)
NEW = $(KIMWITUVERSION)
PATCHPREFIX = kc-patch.
PATCHFILE = "$(PATCHPREFIX)$(OLD)to$(NEW)"
RLOGFLAGS= -r$(OLD):

#
# List the source/object etc files.. Note the use of the
# macro substitution to have to list only once the .k files and the
# files that are generated from them...
# We patch the K__SOURCE variable during the recursive make call
# to patch in the path to the source directory

K__FILES = \
	abs.X \
	main.X \
	parse.X \
	error.X \
	defocc.X \
	extocc.X \
	useocc.X \
	util.X \
	gen.X \
	gutil.X \
	pat.X
K__GENS  = unpk.X k.X rk.X
K__SOURCE = $(K__FILES:X=k)
K__OBJS   = $(K__FILES:X=o) $(K__GENS:X=o)
K__CFILES = $(K__FILES:X=c) $(K__GENS:X=c)
K__HFILES = $(K__FILES:X=h) $(K__GENS:X=h)
PATCHLEVELBASENAME = patchlvl.h
PATCHLEVELFILE = $(ROOT)/$(PATCHLEVELBASENAME)
BISONSIMPLERECOVERFILE = $(ROOT)/bisonsim.rec
BISONSIMPLEERRMSGFILE = $(ROOT)/bisonsim.msg
ERRMSG_H_BASENAME = errmsg.h
ERRMSG_H_FILE = $(ROOT)/$(ERRMSG_H_BASENAME)
ERRMSG_PL_FILE = $(ROOT)/errmsg.pl
DEF_H_FILE = defs.h

C_SOURCE = 
H_SOURCE = $(PATCHLEVELFILE) $(ERRMSG_H_FILE)
K_SOURCE = $(K__SOURCE)
L_SOURCE = $(ROOT)/kimwl.l
M_SOURCE = $(ROOT)/Makefile
Y_SOURCE = $(ROOT)/kimwy.y
S_SOURCE = $(BISONSIMPLERECOVERFILE) $(BISONSIMPLEERRMSGFILE)
PL_SOURCE = $(ERRMSG_PL_FILE)
K_OBJS   = $(K__OBJS)
K_CFILES = $(K__CFILES)
K_HFILES = $(K__HFILES)
LY_CFILES = kimwy.c kimwl.c
LY_HFILES = kimwy.h kimwy.hh
LY_TFILE = y.output
LY_OBJS = $(LY_CFILES:c=o)
DF_HFILES = $(DEF_H_FILE) $(DEF_H_FILE)h
D_FILES = $(ROOT)/LICENSE $(ROOT)/CHANGES $(ROOT)/README
ERRMSG_C_FILE = errmsg.c

SOURCE = \
 $(C_SOURCE) \
 $(H_SOURCE) \
 $(K_SOURCE) \
 $(L_SOURCE) \
 $(M_SOURCE) \
 $(Y_SOURCE) \
 $(PL_SOURCE) \
 $(S_SOURCE)
# ERRMSG_OBJ is defined below (if it is to be used)
OBJS   = $(LY_OBJS) $(K_OBJS) $(ERRMSG_OBJ)
CFILES = $(LY_CFILES) $(K_CFILES)
HFILES = $(LY_HFILES) $(K_HFILES) $(DF_HFILES)
OTHERFILES = tstamp.kc

BOOTSTRAPSOURCE = \
 $(C_SOURCE) \
 $(H_SOURCE) \
 $(L_SOURCE) \
 $(M_SOURCE) \
 $(Y_SOURCE) \
 $(PL_SOURCE) \
 $(S_SOURCE) \
 $(K_CFILES) \
 $(K_HFILES) \
 $(OTHERFILES) \
 $(D_FILES)

# Now that we have changed the include path to only the GEN directory,
# we no longer need a separate BS_PREFIX, so unset it (so it will be empty)
## BS_PREFIX = bs

#
# setting of (architecture dependend) flags etc.
#

# yacc flags: we need both the -d and -v flags
YFLAGS = -d -v
YACC = bison -y
# Next two macros enable the use of an error-recovering bison.
# To use them, also use bison as your parser generator
# NOTE: this doesn't really work right now (do not use!)
##BISONENV = env BISON_SIMPLE=$(BISONSIMPLERECOVERFILE)
##YCFLAGS = -DBISON_RECOVER
# Next three macros enable the use of a bison that gives better error messages.
# To use them, also use bison as your parser generator
# and use the errmsg.pl perl script to generate the errmsg.c file
# This can be used together with YYERROR_VERBOSE
BISONENV = env BISON_SIMPLE=$(BISONSIMPLEERRMSGFILE)
YCFLAGS = -DYYERRMSG_VERBOSE
ERRMSG_OBJ = errmsg.o
# Next macro enables the use of better error messages with bison.
# To use it, also use bison as your parser generator
YCFLAGS1 = -DYYERROR_VERBOSE

LEX = flex -l
# LFLAGS = -d
INCLUDES = -I.
#GENDEFINES = -DYYDEBUG=1
#GENDEFINES = -DMYLEXDEBUG
#GENDEFINES = -DYYDEBUG=1 -DMYLEXDEBUG
DEFINES = $(NODEFAULTINWITHDEFINE) $(YCFLAGS) $(YCFLAGS1) $(GENDEFINES)
# the Makefile/Kimwitu version define only necessary for kimwc.c
KIMWC_CDEFINES = $(MAKEFILEVERSIONDEFINE) $(KIMWITUCOPYRIGHTDEFINE) $(USESTATDEFINE) $(KIMWITURELEASEDEFINE) $(KIMWITUVERSIONSTRINGDEFINE)
DEBUG_CFLAGS = -g
#DEBUG_CFLAGS = -pedantic -ansi -O2 -Wall
SABER_ANY_ARCH_CFLAGS = $(DEBUG_CFLAGS) $(INCLUDES)
ANY_ARCH_CFLAGS = $(SABER_ANY_ARCH_CFLAGS) $(DEFINES)
HP_CFLAGS = -Wc,-Ns10000 -Wc,-Np300
LINT_HP_CFLAGS = -Ns100000 -Na100000 -Zn50000 -Zt50000 -Np300
# ARCH_DEPEND_CFLAGS = `(if hp9000s300 ; then echo $(HP_CFLAGS); fi) 2>>/dev/null`
# LINT_ARCH_DEPEND_CFLAGS = `(if hp9000s300 ; then echo $(LINT_HP_CFLAGS); fi) 2>>/dev/null`
ANY_ARCH_MALLOC_LDFLAGS = 
HP_MALLOC_LDFLAGS = -lmalloc
ARCH_DEPEND_MALLOC_LDFLAGS = `(if hp9000s300 ; then echo $(HP_MALLOC_LDFLAGS); fi) 2>>/dev/null`
CFLAGS = $(ANY_ARCH_CFLAGS) $(ARCH_DEPEND_CFLAGS)
# LIBS = -ll
SABER_CFLAGS = $(SABER_ANY_ARCH_CFLAGS) $(ARCH_DEPEND_CFLAGS)
LINT_CFLAGS = $(INCLUDES) $(LINT_ARCH_DEPEND_CFLAGS) $(GENDEFINES)
# MALLOC_LDFLAGS = $(ANY_ARCH_MALLOC_LDFLAGS) $(ARCH_DEPEND_MALLOC_LDFLAGS)
KC = kc
CC = gcc
CPP = /usr/lib/cpp
# LN = ln -s
LN = cp -f
CP = cp -f
RM = rm -f

PURIFY = /Tios/Language/Purify/purify-4.0-solaris2/purify

TARGET = kc.new
BOOTSTRAPTARGET = kc
GENDEPEND = kc.depend
GENSABER = kc.saber
GENALLSOURCE = GENallsource
GENCLEAN = GENclean
GENLINT = GENlint

#
# The Main targets & rules
#
default: $(GENDIR)/$(BOOTSTRAPTARGET)
pure: $(GENDIR)/$(BOOTSTRAPTARGET).pure
new: $(GENDIR)/$(TARGET)
new.pure: $(GENDIR)/$(TARGET).pure
depend: $(GENDIR)/$(GENDEPEND)
saber: $(GENDIR)/$(GENSABER)
allsource: $(GENDIR)/$(GENALLSOURCE)
clean: $(GENDIR)/$(GENCLEAN)
lint: $(GENDIR)/$(GENLINT)


$(GENDIR)/$(BOOTSTRAPTARGET) $(GENDIR)/$(BOOTSTRAPTARGET).pure:: \
	$(GENDIR)/bootstrap.kc

$(GENDIR)/$(BOOTSTRAPTARGET) $(GENDIR)/$(BOOTSTRAPTARGET).pure \
$(GENDIR)/$(TARGET) $(GENDIR)/$(TARGET).pure \
$(GENDIR)/$(GENDEPEND) $(GENDIR)/$(GENSABER) \
$(GENDIR)/$(GENALLSOURCE) $(GENDIR)/$(GENCLEAN) \
$(GENDIR)/$(GENLINT) ::
	@echo "Making $@..."
	@case $(GENDIR) in \
	/*) olddir=`pwd`;; \
	*/../*) olddir=`pwd`;; \
	*/./*) olddir=`pwd`;; \
	*) olddir=`echo $(GENDIR)|sed 's/[^\/][^\/]*/../g'`;; \
	esac; \
	if test ! -d $(GENDIR); then mkdir $(GENDIR); fi; \
	cd $(GENDIR); \
	k__source=""; \
	for f in $(K__SOURCE); \
	do k__source="$${k__source} $${olddir}/$${f}"; done; \
	$(MAKE) -e -f $${olddir}/Makefile \
		ROOT=$${olddir} \
		K__SOURCE="$${k__source}" \
		`basename $@`

# When bootrapping (i.e. building kc from .[ch] source),
# we _link_ the standard header files and kc-generated code
#  (because it is unlikely to be overwritten - is that true for kc-generated?)
# and we _copy_ the other generated files
#  (because the may be changed by a re-run yacc(bison) or (f)lex)
$(GENDIR)/bootstrap.kc:
	@echo "Setting up $(GENDIR)..."
	case $(GENDIR) in \
	/*) olddir=`pwd`;; \
	*/../*) olddir=`pwd`;; \
	*/./*) olddir=`pwd`;; \
	*) olddir=`echo $(GENDIR)|sed 's/[^\/][^\/]*/../g'`;; \
	esac; \
	if test ! -d $(GENDIR); then mkdir $(GENDIR); fi; \
	cd $(GENDIR); \
	k__source=""; \
	for f in $(K__SOURCE); \
	do k__source="$${k__source} $${olddir}/$${f}"; done; \
	for f in $(K__CFILES) $(K__HFILES) $(H_SOURCE); \
	do $(RM) $${f}; $(LN)  $${olddir}/$${f} $${f}; done; \
	for f in $(LY_CFILES) $(LY_HFILES) $(LY_TFILE) $(DF_HFILES) $(ERRMSG_C_FILE); \
	do $(RM) $${f}; $(CP)  $${olddir}/$(BS_PREFIX)$${f} $${f}; done; \
	touch tstamp.kc; \
	touch bootstrap.kc;

# When building a new kc from .k source we copy nothing here.
# However, the PATCHLEVELFILE and ERRMSG_H_FILE will be copied by
# the dependencies that are written for them below.

# running KC on the .k files
# HACK because cpp dumps core
tstamp.kc: $(K_SOURCE)
	#if test -f unpk.c; then mv unpk.c old.unpk.c; fi
	#if test -f util.c; then mv util.c old.util.c; fi
	#if test -f gutil.c; then mv gutil.c old.gutil.c; fi
	#if test -f pat.c; then mv pat.c old.pat.c; fi
	$(KC) $(K_SOURCE)
	#egrep -v '^#line' unpk.c > ok.unpk.c
	#if test -f old.unpk.c; then mv old.unpk.c unpk.c; fi
	#-cmp -s ok.unpk.c unpk.c || mv ok.unpk.c unpk.c
	#egrep -v '^#line' util.c > ok.util.c
	#if test -f old.util.c; then mv old.util.c util.c; fi
	#-cmp -s ok.util.c util.c || mv ok.util.c util.c
	#egrep -v '^#line' gutil.c > ok.gutil.c
	#if test -f old.gutil.c; then mv old.gutil.c gutil.c; fi
	#-cmp -s ok.gutil.c gutil.c || mv ok.gutil.c gutil.c
	#egrep -v '^#line' pat.c > ok.pat.c
	#if test -f old.pat.c; then mv old.pat.c pat.c; fi
	#-cmp -s ok.pat.c pat.c || mv ok.pat.c pat.c
	touch tstamp.kc

$(K_CFILES) $(K_HFILES): tstamp.kc

$(TARGET) $(BOOTSTRAPTARGET): $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(MALLOC_LDFLAGS) -o $@ $(LIBS)

$(TARGET).pure $(BOOTSTRAPTARGET).pure: $(OBJS)
	$(PURIFY) $(CC) $(CFLAGS) $(OBJS) $(MALLOC_LDFLAGS) -o $@ $(LIBS)

kimwy.c kimwy.h y.output: $(ROOT)/kimwy.y 
	$(BISONENV) $(YACC) $(YFLAGS) $(ROOT)/kimwy.y
	mv y.tab.c kimwy.c
	mv y.tab.h kimwy.h
kimwl.c: $(ROOT)/kimwl.l
	$(LEX) $(LFLAGS) $(ROOT)/kimwl.l
	mv lex.yy.c kimwl.c

# we use a perl script to extract verbose error messages from a
# y.output file generated by bison.
# NOTE: this only works with bison-generated y.output files
# NOTE: to use the errmsg.c file, use the BISONSIMPLEERRMSGFILE skeleton file
$(ERRMSG_C_FILE): y.output
	perl $(ERRMSG_PL_FILE) < y.output > $(ERRMSG_C_FILE)

# We collect a number of definitions in the defs.h file
# we do this for two reasons:
#  1) we don't clutter the CC command line with lots of -D flags
#  2) we can put the file in the distribution, for non-unix platforms
#
$(DEF_H_FILE): $(ROOT)/Makefile  $(ROOT)/$(PATCHLEVELBASENAME)
	echo "/* this file is automatically generated by 'make'; do not edit! */" > $@
	echo "#ifndef DEFS_H" >> $@
	echo '# define ' $(MAKEFILEVERSIONDEFINE) >> $@
	echo '# define ' $(KIMWITUCOPYRIGHTDEFINE) >> $@
	echo '# define ' $(USESTATDEFINE) >> $@
	echo '# define ' $(KIMWITURELEASEDEFINE) >> $@
	echo '# define ' $(KIMWITUVERSIONSTRINGDEFINE) >> $@
	echo '#endif /* DEFS_H */' >> $@

# Link (or copy - depending on LN definition) header files
# from source to compilation (Gen) directory,
# such that all include files that we need are there, so
# we don't need the source directory in the include path
$(ERRMSG_H_BASENAME): $(ERRMSG_H_FILE)
	$(LN) $(ERRMSG_H_FILE) $@
$(PATCHLEVELBASENAME): $(PATCHLEVELFILE)
	$(LN) $(PATCHLEVELFILE) $@

# making copies to prevent unnessary compilation
kimwy.hh: kimwy.h
	-cmp -s $@ $? || cp $? $@
$(DEF_H_FILE)h: $(DEF_H_FILE)
	-cmp -s $@ $? || cp $? $@

#
# special (maintenaince) targets
#
$(GENCLEAN):
	$(RM) *.o $(TARGET) $(BOOTSTRAPTARGET)
veryclean:
	@echo "Completely Cleaning $(GENDIR)..."
	@olddir=`pwd`; cd $(GENDIR); \
	if test $${olddir} = `pwd`; then echo "You don't want to do this; ";\
	echo "you don't want to veryclean the current (sources) directory."; exit 1; fi; \
	echo "To $@ directory $(GENDIR) simply execute 'rm -rf $(GENDIR)'"; \
	echo "from the shell. Make sure you don't delete anything you would regret..."
	
print: $(SOURCE)
	npr `ls $?`; touch print
newfiles: $(SOURCE)
	@echo `ls $?`
thesource:
	@echo $(SOURCE)
longsource:
	@ls -lrt $(SOURCE)
writablesource:
	@ls -lrt $(SOURCE) |  fgrep 'rw-' | awk '{print $$NF}'
theksource:
	@k__source=""; \
	for f in $(K__SOURCE); \
	do k__source="$${k__source} ${ROOT}/$${f}"; done; \
	echo $${k__source}
thecsource:
	@echo $(C_SOURCE)
$(GENALLSOURCE):
	@echo $(K__SOURCE) $(BOOTSTRAPSOURCE)
distr:
	@case $(GENDIR) in \
	/*) olddir=`pwd`;; \
	*/../*) olddir=`pwd`;; \
	*/./*) olddir=`pwd`;; \
	*) olddir=`echo $(GENDIR)|sed 's/[^\/][^\/]*/../g'`;; \
	esac; \
	if test ! -d $(GENDIR); then exit 1; fi; \
	if test ! -d $(DISTRDIR); then mkdir $(DISTRDIR); fi; \
	if test ! -d $(DISTRDIR); then exit 1; fi; \
	cd $(GENDIR); \
	k__source=""; \
	for f in $(K__SOURCE); \
	do k__source="$${k__source} $${olddir}/$${f}"; done; \
	$(MAKE) -e -f $${olddir}/Makefile ROOT=$${olddir} GENk__source="$${k__source}" GENdistr
GENdistr:
	$(CP) $(GENk__source) $(BOOTSTRAPSOURCE) $(DISTRDIR)
	for f in $(LY_CFILES) $(LY_HFILES) $(LY_TFILE) $(DF_HFILES) $(ERRMSG_C_FILE); \
	do $(CP) $$f $(DISTRDIR)/$(BS_PREFIX)$$f; done

#
# Debugging
#
$(GENLINT):
	$(LINT)  $(LINT_CFLAGS) $(CFILES) rk.c csgiok.c > $(LINT).out

#lint $(INCLUDES) $(DEFINES) $(CFILES) > lint.out

# this rule is recursively called for target 'saber'
$(GENSABER): $(CFILES)
	#cd $(GENDIR)
	#load $(SABER_CFLAGS) $(CFILES)
	#cd $(PWD)

#
# RCS stuff
#
versionid:
	@echo '$(RCSVERSIONID)'
version:
	@echo $(KIMWITUVERSION)
rlog:
	-$(RM) -f Changes.since.$(OLD)
	@for f in $(SOURCE); do \
	rlog -N -r$(OLD): $${f} >> Changes.since.$(OLD); \
	done
release:
	kcv=$(KIMWITUVERSION) ; \
	for f in $(SOURCE); do \
	rev=`ident $${f} | awk '{printf("%s", $$3)}' ` ; \
	echo "rcs -n$${kcv}:$${rev} -sRel:$${kcv} $${f}" ; \
	rcs -n$${kcv}:$${rev} -sRel:$${kcv} $${f} ; \
	co -r$${rev} $${f} ; \
	done
patch:
	-@old="$(OLD)"; new="$(NEW)"; patchfile=$(PATCHPREFIX)$${old}to$${new}; \
	echo "This patch patches Kimwitu from patchlvl $${old} to $${new}.\\\
To apply, cd to the kc-distr/src directory, and execute\\\
\\\
	patch < $(PATCHFILE)\\\
\\\
To rebuild kc:\\\
- Make sure you have a working kc in your PATH\\\
- Remove the kc-distr/src/Gen directory if existing (make veryclean)\\\
- execute 'make new' to build the new kc as kc-distr/Gen/kc.new\\\
\\\
\\\
Prereq: $${old}\\\
" |tr '\\' '\012' > $${patchfile}; \
	for f in $(SOURCE); do \
	rev=`ident $${f} | awk '{printf("%s", $$3)}' ` ; \
	echo "rcsdiff -c -r$${old} -r$${new} $${f} |egrep -v '^No differences' >> $${patchfile}" ; \
	echo "Index: $${f}" >> $${patchfile}; \
	rcsdiff -c -r$${old} -r$${new} $${f} |egrep -v '^No differences' >> $${patchfile} ; \
	done

# this rule is recursively called by the 'depend' rule
$(GENDEPEND):
	$(RM) ${ROOT}/depend; \
	for f in $(CFILES); \
	do $(CC) -xM $(INCLUDES) $${f} >> ${ROOT}/depend; done

#	do $(CPP) -MM $(INCLUDES) $${f} >> $${olddir}/depend; done
	

$(OBJS): k.h
main.o: $(PATCHLEVELBASENAME)
# defs.h(h) contains a couple of definitions, to be included in main.c
main.o: main.c defs.hh

# dependencies from here generated using the depend target
# slightly edited:
#   to change kimwy.h into kimwy.hh
#   to remove the stdio include from the kimwl.o dependency
#   to replace some file names by macro's

kimwy.o : kimwy.c k.h error.h defocc.h useocc.h parse.h \
  extocc.h 
kimwl.o : kimwl.c  k.h error.h defocc.h useocc.h \
  kimwy.hh 
abs.o : abs.c k.h error.h defocc.h useocc.h abs.h 
main.o : main.c k.h error.h defocc.h useocc.h unpk.h gen.h \
  gutil.h main.h 
parse.o : parse.c k.h error.h defocc.h useocc.h util.h extocc.h \
  parse.h 
error.o : error.c k.h error.h defocc.h useocc.h unpk.h gen.h \
  error.h 
defocc.o : defocc.c k.h error.h defocc.h useocc.h defocc.h 
extocc.o : extocc.c k.h error.h defocc.h useocc.h extocc.h 
useocc.o : useocc.c k.h error.h defocc.h useocc.h useocc.h 
util.o : util.c k.h error.h defocc.h useocc.h parse.h util.h 
gen.o : gen.c k.h error.h defocc.h useocc.h gen.h 
gutil.o : gutil.c k.h error.h defocc.h useocc.h util.h unpk.h \
  gen.h gutil.h 
pat.o : pat.c k.h error.h defocc.h useocc.h util.h pat.h 
unpk.o : unpk.c k.h error.h defocc.h useocc.h unpk.h gen.h util.h \
  extocc.h parse.h pat.h gutil.h 
k.o : k.c k.h error.h defocc.h useocc.h 
errmsg.o: $(ERRMSG_C_FILE) $(ERRMSG_H_BASENAME)
