CMLD = /p/wwt/bin/cmld


# Changes copyright (c) 1992-93 by Mark Hill, James Larus, and David Wood for
# the Wisconsin Wind Tunnel Project.
#
# ALL RIGHTS RESERVED.
#
# This software is furnished under a license and may be used and
# copied only in accordance with the terms of such license and the
# inclusion of the above copyright notice.  This software or any other
# copies thereof or any derivative works may not be provided or
# otherwise made available to any other persons.  Title to and ownership
# of the software is retained by Mark Hill, James Larus, and David Wood.
# Any use of this software must include the above copyright notice.
#
# THIS SOFTWARE IS PROVIDED "AS IS".  THE LICENSOR MAKES NO
# WARRANTIES ABOUT ITS CORRECTNESS OR PERFORMANCE.

.KEEP_STATE:

WWTLIB_DIR = $(WWT_ROOT)/lib

INC = -I/p/cm5/usr/include -I$(WWT_ROOT)/include/cm5/$(TEMPEST_IMPL) -I$(WWT_ROOT)/include/cm5/sys -I$(WWT_ROOT)/lib.src/cm5/blizzard -I. -I/$(WWT_ROOT)/include/utils -I$(WWT_ROOT)/include/prot/utils -I$(WWT_ROOT)/include/cm5/$(TEMPEST_IMPL)/utils

CFLAGS += -DWWT -DBLZ -DNO_FORK_SEMANTICS -Dfloat=double $(INC) -DSTACHE_BLK_SIZE=128 

cp_cflags_all           = $(CFLAGS) -DCM5 -DMAIN=main
pn_cflags_all           = $(CFLAGS) $(PN_CFLAGS) -DCM5 -Dpe_obj -DPE_CODE

LDFLAGS += -n -dc -dp -e __wwt_startup_ -X 

LIBDIRS += -L$(WWTLIB_DIR) -L$(WWTLIB_DIR)/cm5/$(TEMPEST_IMPL) 
SP_LIBS += -ltempest_sp -lcmna_sp -lm -lc
PE_LIBS += -lutils_pe -ltempest_pe -lcmna_pe -lm -lc

#==============
# PARMACS stuff
#==============
MACDIR = $(WWT_ROOT)/lib/cm5/$(TEMPEST_IMPL)
MACROS = $(MACDIR)/c.m4.local $(MACDIR)/c.m4.monmacs $(MACDIR)/c.m4.smacs
#==============

.SUFFIXES:
.SUFFIXES: .o .c .U .h .H

%.o: %.c
	$(CC) -c $(pn_cflags_all) $*.c

%.o: $(SRCDIR)/%.c
	$(CC) -c $(pn_cflags_all) $(SRCDIR)/$*.c

%.cp.o: $(SRCDIR)/%.c
	$(CC) $(cp_cflags_all) -o $@ -c $<

%.pn.o: $(SRCDIR)/%.c
	$(CC) $(pn_cflags_all) -o $@ -c $<

%.cp.o: %.c
	$(CC) $(cp_cflags_all) -o $@ -c $<

%.pn.o: %.c
	$(CC) $(pn_cflags_all) -o $@ -c $<

%.c: %.U
	/bin/m4 $(MACROS) $*.U > $*.c

%.c: $(SRCDIR)/%.U
	/bin/m4 $(MACROS) $(SRCDIR)/$*.U > $*.c

%.h: %.H
	/bin/m4 $(MACROS) $*.H > $*.h

%.h: $(SRCDIR)/%.H
	/bin/m4 $(MACROS) $(SRCDIR)/$*.H > $*.h

$(TARGET): $(SP_OBJS) $(OBJS)
	$(CMLD) $(CMLDFLAGS) -gcc -o $(TARGET)$(EXT) $(SP_OBJS) $(LIBDIRS) \
	$(SP_LIBS) -pe $(OBJS) $(LIBDIRS) $(PE_LIBS)

rmtarget:
	rm -f $(TARGETDIR)/$(TARGET) $(TARGETDIR)/$(TARGET).Z

install: $(TARGET)
	cp $(TARGET).Z $(TARGETDIR)

code.o: code.c code.h util.c 
code_io.o: code_io.c code.h
getparam.o: getparam.c stdinc.h 
grav.o: grav.c code.h 
load.o: load.c code.h

code.h: defs.h 
defs.h: stdinc.h vectmath.h 

clean:
	/bin/rm -f $(TARGET) $(TARGET).Z *.o
