# Changes copyright (c) 1992-94 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:

TARGET = appbt
TARGETDIR = .

WWTLIB_DIR = $(WWT_ROOT)/lib

MODEL = parmacs

INC = -I$(WWT_ROOT)/include/$(PROTOCOL) -I$(WWT_ROOT)/include -I/p/cm5/usr/include

STD_CFLAGS  = $(INC)
STD_LDFLAGS = -n -dc -dp -e __wwt_startup_ -X 

CFLAGS = $(STD_CFLAGS) $(OTHER_CFLAGS)
LDFLAGS = $(STD_LDFLAGS) $(OTHER_LDFLAGS)

LIBDIRS = -L$(WWTLIB_DIR) -L$(WWTLIB_DIR)/$(PROTOCOL) -L/usr/psup/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.8
LIBS = -l$(MODEL) -lm -lgcc -lc

OBJS = appbt.o jacx.o jacy.o jacz.o btridx.o btridy.o btridz.o\
       erhs.o rhs.o /lib/crt0.o

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

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

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

%.o: $(SRCDIR)/%.c
	$(CC) -c $(CFLAGS) $(SRCDIR)/$*.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): $(OBJS)
	ld  $(LDFLAGS) $(OBJS) -o $(TARGET).no-vt $(LIBDIRS) $(LIBS)
	vt -a $(TARGET) -d -w $(OTHER_VTFLAGS) $(TARGET).no-vt

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

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

appbt.h: prot.h
appbt.o: appbt.c appbt.h gray3.h
rhs.o: rhs.c appbt.h
erhs.o: erhs.c appbt.h
btridx.o: btridx.c appbt.h
btridy.o: btridy.c appbt.h
btridz.o: btridz.c appbt.h
jacx.o: jacx.c appbt.h
jacy.o: jacy.c appbt.h
jacz.o: jacz.c appbt.h

clean:
	/bin/rm -f $(TARGET) $(TARGET).Z *.[coh] $(TARGET).no-vt   
