# $Source: /mit/kerberos/src/util/makedepend/RCS/Imakefile,v $
# $Author: jtkohl $
# $Header: Imakefile,v 4.3 89/04/11 10:31:26 jtkohl Exp $
#
# Copyright 1987 by the Massachusetts Institute of Technology.
#
# For copying and distribution information,
# please see the file <mit-copyright.h>.
#
# Utility to build makefile header dependancies from C source.
#
# If you have source for cpp...
#
#ifdef cpp_source_path
SRCS = include.c main.c parse.c pr.c cppsetup.c cpp.c cpy.y
SOURCES = \
	${SRCDIR}/util/makedepend/include.c \
	${SRCDIR}/util/makedepend/main.c \
	${SRCDIR}/util/makedepend/parse.c \
	${SRCDIR}/util/makedepend/pr.c \
	${SRCDIR}/util/makedepend/cppsetup.c \
	${SRCDIR}/util/makedepend/cpp.ed \
	${SRCDIR}/util/makedepend/def.h \
	${SRCDIR}/util/makedepend/Imakefile \
	${SRCDIR}/util/makedepend/Makefile
OBJS = include.o main.o parse.o pr.o cppsetup.o cpp.o cpy.o
DEFINES = -DCPP '-DINCLUDEDIR="/usr/include"'
CPPSRC = cpp_source_path

#else

#
# But if you don't have cpp source...
#
SRCS = include.c main.c parse.c pr.c cppsetup.c
SOURCES = \
	${SRCDIR}/util/makedepend/include.c \
	${SRCDIR}/util/makedepend/main.c \
	${SRCDIR}/util/makedepend/parse.c \
	${SRCDIR}/util/makedepend/pr.c \
	${SRCDIR}/util/makedepend/cppsetup.c \
	${SRCDIR}/util/makedepend/def.h \
	${SRCDIR}/util/makedepend/Imakefile \
	${SRCDIR}/util/makedepend/Makefile
OBJS = include.o main.o parse.o pr.o cppsetup.o
DEFINES = '-DINCLUDEDIR="/usr/include"'

#endif

CODE=$(SRCS) Imakefile

genutil(makedepend,$(OBJS),,)

cpy.c: cpy.y yylex.c
	yacc cpy.y
	sed -e '/^# *line/d' < y.tab.c > cpy.c
	$(RM) y.tab.c

cpy.y: $(CPPSRC)/cpy.y
	$(RM) $@
	$(LN) $(CPPSRC)/cpy.y .

yylex.c: $(CPPSRC)/yylex.c
	$(RM) $@
	sed -e 's/#if pdp11 | vax | mc68000/& | ns16000 | ibm032/' \
		$(CPPSRC)/yylex.c > yylex.c

cpp.c: $(CPPSRC)/cpp.c cpp.ed
	$(RM) cpp.c
	/lib/cpp $(CPPSRC)/cpp.c \
		| cb \
		| sed -e '/^$$/d' -e '/^#/d' -e 's/	/ /g' > cpp.c
	sed -e '/^#/d' < cpp.ed | ed - cpp.c

cpp.o: cpp.c
cpy.o: cpy.c

clean::
	$(RM) cpp.c cpy.? yylex.c

config: $(SOURCES)
	-mkdir $(DESTDIR)/util/makedepend
	for i in $(SOURCES); do \
		$(RM) ${DESTDIR}/util/makedepend/`basename $$i`; \
		$(CP) $$i ${DESTDIR}/util/makedepend/`basename $$i`; done

