CFLAGS = $(CCOPTS) $(DEFS) $(LOCALINCLUDE)

##DOSBUILDTOP = ..\..
##DOSLIBNAME=profile.lib
##DOS!include $(BUILDTOP)\config\windows.in

LOCALINCLUDE=-I. -I$(srcdir)/../et

.c.o:
	$(CC) $(CFLAGS) -c $(srcdir)/$*.c
@SHARED_RULE@

OBJS = prof_tree.$(OBJEXT) \
	prof_file.$(OBJEXT) \
	prof_parse.$(OBJEXT) \
	prof_err.$(OBJEXT) \
	prof_init.$(OBJEXT)

SRCS = $(srcdir)/prof_tree.c \
	$(srcdir)/prof_file.c \
	$(srcdir)/prof_parse.c \
	prof_err.c \
	$(srcdir)/prof_init.c

LIBS = ../et/libcom_err.$(LIBEXT)

install::

all:: all-$(WHAT)

all-max:: all-unix
all-unix:: shared includes libprofile.a test_parse test_profile

shared:
	mkdir shared

all-windows: $(OBJS)

awk-windows:
	$(AWK) -f $(BUILDTOP)/util/et/et_h.awk outfile=prof_err.h prof_err.et
	$(AWK) -f $(BUILDTOP)/util/et/et_c.awk outfile=prof_err.c prof_err.et
	if exist prof_err.h copy profile.hin+prof_err.h profile.h
	if exist profile.h copy profile.h $(BUILDTOP)\include\profile.h

libprofile.a: $(OBJS)
	$(ARCHIVE) $@ $(OBJS)
	$(RANLIB) $@

test_parse: test_parse.$(OBJEXT) $(OBJS) $(LIBS)
	$(CC) -o test_parse test_parse.$(OBJEXT) $(OBJS) $(LIBS)

test_profile: test_profile.$(OBJEXT) $(OBJS) $(LIBS)
	$(CC) -o test_profile test_profile.$(OBJEXT) $(OBJS) $(LIBS)

test_parse.exe: 
	$(CC) $(CFLAGS2) -o test_parse.exe test_parse.c \
		prof_parse.c prof_tree.c /link /stack:16384

test_profile.exe: 
	$(CC) $(CFLAGS2) -o test_profile.exe test_profile.c prof_init.c \
		prof_file.c prof_parse.c prof_tree.c /link /stack:16384

profile.h: prof_err.h profile.hin
	cat $(srcdir)/profile.hin prof_err.h > $@

prof_err.h: $(srcdir)/prof_err.et

prof_err.c: $(srcdir)/prof_err.et

prof_err.o: prof_err.c
	$(CC) $(CFLAGS) -c prof_err.c
@SHARED_RULE_LOCAL@

clean:: clean-$(WHAT)

clean-mac:: clean-unix
clean-unix::
	rm -f $(PROGS) *.o *~ test_parse core libprofile.a prof_err.h \
		prof_err.c test_profile profile.h shared/*

clean-windows::
	$(RM) profile.lib profile.bak test_parse.exe test_profile.exe

check:: check-$(WHAT)

check-mac::
check-unix::
check-windows:: test_profile.exe test_parse.exe
	$(RM) *.obj
	test_parse test.ini

# +++ Dependency line eater +++
# 
# Makefile dependencies follow.  This must be the last section in
# the Makefile.in file
#
prof_tree.o: $(srcdir)/prof_tree.c $(srcdir)/prof_int.h prof_err.h
prof_file.o: $(srcdir)/prof_file.c $(srcdir)/prof_int.h prof_err.h
prof_parse.o: $(srcdir)/prof_parse.c $(srcdir)/prof_int.h prof_err.h
prof_err.o: prof_err.c
prof_init.o: $(srcdir)/prof_init.c $(srcdir)/prof_int.h prof_err.h

