/**/#	Copyright (c) 1990, 1991, 1992, 1993, 1994 Novell, Inc. All Rights Reserved.
/**/#	Copyright (c) 1993 Novell, Inc. All Rights Reserved.
/**/#	  All Rights Reserved

/**/#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Novell Inc.
/**/#	The copyright notice above does not evidence any
/**/#	actual or intended publication of such source code.

/**/#ident	"@(#)r5util:makedepend/Imakefile	1.8"
XCOMM $XConsortium: Imakefile,v 1.14 91/07/16 23:07:25 gildea Exp $

/*
 * NOTE: CppSourcesPresent IS NO LONGER TESTED OR SUPPORTED,
 * and is nearly guaranteed to not work.
 */

#ifndef CppSourcesPresent
#define CppSourcesPresent	NO	/* only works with BSD sources */
#endif
#ifndef CppSources
#define CppSources /usr/src/lib/cpp
#endif

#if CppSourcesPresent
    SRCS = include.c main.c parse.c pr.c cppsetup.c cpp.c cpy.y
    OBJS = include.o main.o parse.o pr.o cppsetup.o cpp.o cpy.o
 CPPDEFS = -DCPP
  CPPSRC = CppSources
#else
/*
 * But if you do not have cpp source...
 */
    SRCS = include.c main.c parse.c pr.c cppsetup.c
    OBJS = include.o main.o parse.o pr.o cppsetup.o
#endif

INCLUDES = -I$(CONFIGSRC)
 DEFINES = $(CPPDEFS) '-DINCLUDEDIR="/usr/include"' $(SIGNAL_DEFINES)
 DEPLIBS =

#ifdef MacIIArchitecture
 XBSDLIB = /**/
#endif

#if UTSXENV
 CC = $(HCC)
CCOPTIONS=
STD_INCLUDES=-I/usr/include
EXTRA_INCLUDES=
INC=
LDOPTIONS=
CFLAGS=-c -DUTSXENV -DUSG -DSYSV -DX_NOT_STDC_ENV -DX_NOT_POSIX -I$(TOP) -I$(CONFIGSRC) $(DEFINES)
#endif

#undef InstallManPage
#define InstallManPage(file,dest) /* as nothing */
LOCAL_LIBRARIES=
LDLIBS=

all:: makedepend makedepend_nat

makedepend:: $(SRCS)
	$(HCC) -c $(HCFLAGS) include.c
	$(HCC) -c $(HCFLAGS) main.c
	$(HCC) -c $(HCFLAGS) parse.c
	$(HCC) -c $(HCFLAGS) pr.c
	$(HCC) -c $(HCFLAGS) cppsetup.c
	$(HCC) -o makedepend $(OBJS) $(HLDOPTIONS) 
	$(RM) $(OBJS)

makedepend_nat:: $(SRCS)
	$(CC) -c $(CFLAGS) include.c
	$(CC) -c $(CFLAGS) main.c
	$(CC) -c $(CFLAGS) parse.c
	$(CC) -c $(CFLAGS) pr.c
	$(CC) -c $(CFLAGS) cppsetup.c
	$(CC) -o makedepend_nat $(OBJS) $(LDOPTIONS) 
	$(RM) $(OBJS)

InstallManPageLong(mkdepend,$(MANDIR),makedepend)

InstallProgram(makedepend,$(BINDIR))
InstallProgram(makedepend_nat,$(BINDIR))

#if CppSourcesPresent
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
#endif

includes::

depend:: $(DEPEND)

$(DEPEND):
	@echo "checking $@ over in $(DEPENDSRC) first..."; \
	cd $(DEPENDSRC); $(MAKE); \
	echo "okay, continuing in $(CURRENT_DIR)"

depend::
	$(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS)

lint:
	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
lint1:
	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)

clean::
	$(RM) makedepend makedepend_nat
