# Copyright (c) 1994-95 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.


# 
# Makefile
#
# Make sure the environment variable WWT_ROOT is set to the root the 
# WWT tree.  This directory should contain the Include and Lib
# directories. 
# 
# In the CS dept. in Wisconsin, set WWT_ROOT to /p/WWT
#
# Three steps:
# 1. Complete or change value assigned to the variables defined below.
# 2. Add file dependencies.
# 3. Complete "clean" rule.
#
.KEEP_STATE:

# WWT_ROOT = /p/WWT
WWT_ROOT = /p/wwt/users/chandra/cvs
#
# 1. Complete or change value assigned to the following variables.
#

# Protocol used (diriX/dir1SW)
# PROTOCOL = diriX
PROTOCOL = dir1SW

# Programming model used.
MODEL = cmmd

COMM_MODEL = cmmd_wwt_opt

# Target name
TARGET = sor

FTN_SRCS        = 
C_SRCS          = sor.c

F2C_SRCS        = $(FTN_SRCS:%.f=%.c)
F2C             = /p/WWT3/chandra/F2c/f2c
f2c_flags       = -w -A -!R -s -Nn802 -Nx400

%.c: %.f
	$(F2C) $(f2c_flags) $<
	ed $@ < patch.$<

# The object files.
# /lib/crt0.o provides a pointer to the environment needed by some 
# libc objects

ALL_SRCS 	= $(C_SRCS) $(F2C_SRCS)

USR_OBJS	= $(ALL_SRCS:%.c=%.o)

OBJS 		= /lib/crt0.o

OTHER_CFLAGS = -O2 -DWWT -DDIR1

OTHER_LDFLAGS = -lg
OTHER_VTFLAGS =

#
# You should not need to change any other variables.
#
INC = -I$(WWT_ROOT)/Include/$(PROTOCOL) -I$(WWT_ROOT)/Include -I$(WWT_ROOT)/CMInclude -I/usr/include -I/p/cm5/usr/include

# Invariants, you shouldn't (typically) override these.
STD_CFLAGS = $(INC)
#STD_LDFLAGS = -n -dc -dp  -X
STD_LDFLAGS = -n -dc -dp -e __wwt_startup_ -X

# You should not change these.
CC = /p/cm5/gcc/bin/gcc
#CC = gcc
LD = ld
CFLAGS = $(STD_CFLAGS) $(OTHER_CFLAGS)
LDFLAGS = $(STD_LDFLAGS) $(OTHER_LDFLAGS)

WWTLIBDIR = $(WWT_ROOT)/Lib

COMM_LIB_DIR = $(WWT_ROOT)/CMLib

LIBDIRS = -L$(COMM_LIB_DIR) -L$(WWTLIBDIR) -L$(WWTLIBDIR)/$(PROTOCOL) -L/p/cm5/gcc/lib/gcc-lib/sparc-sun-sunos4.1.3/2.5.8

LIBS =  -l$(MODEL) -l$(COMM_MODEL) -lgcc -lm -lc

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

.SUFFIXES:
.SUFFIXES: .o .c .U .h .H
.c.o: ; $(CC) -c $(CFLAGS) $*.c 
.U.c: ; m4 $(MACROS) $*.U >$*.c
.H.h: ; m4 $(MACROS) $*.H >$*.h

$(TARGET): $(OBJS) $(USR_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(USR_OBJS) -o $(TARGET).no-vt $(LIBDIRS) $(LIBS)
	/p/wwt/bin/vt -a $(TARGET) -d -w $(OTHER_VTFLAGS) $(TARGET).no-vt
#	/bin/rm $(TARGET).no-vt

#
# 2. Add file dependencies.
#


#
# 3. Complete "clean" rule.
# For instance add intermediate files created by m4 (.[ch]) and cc (.o).
#
clean:
	-rm -f $(TARGET) $(TARGET).no-vt 


