########################################################################
# Generic Makefile for RNPL 'f77' application.
#
# Requires following environment variables to be set to appropriate
# values:
#
# RNPL_RNPL 
# RNPL_F77 
# RNPL_F77LOAD
# RNPL_F77PP 
# RNPL_FLIBS
#
########################################################################
.IGNORE:

########################################################################
#  NOTE: This Makefile uses the Bourne shell, 'sh'
########################################################################
SHELL = /bin/sh

########################################################################
#  Set 'APP' to application name stem (prefix) then execute
#  'make fix' to convert Makefile to use explicit targets
########################################################################
APP        =  w1dcn

########################################################################
# If your application uses headers and/or libraries from 
# non-system locations, define the following macros appropriately ...
# (set to white-space separated path names, don't use 'csh' ~ notation
# for home directories)
########################################################################
USER_INC_PATHS =
USER_LIB_PATHS = 

########################################################################
# If you want to set non-default flags for the 'f77' compiler, do so
# here
########################################################################
RNPL      = $(RNPL_RNPL)

F77       = $(RNPL_F77)
F77_LOAD  = $(RNPL_F77LOAD)
F77PP     = $(RNPL_F77PP)
FLIBS     = $(RNPL_FLIBS)

.f.o:
	$(F77) -c $*.f

all: w1dcn w1dcn_init

fix: Makefile
	sed "s@w1dcn@w1dcn@g" < Makefile > .Makefile 
	mv .Makefile Makefile

w1dcn.f:      w1dcn_rnpl
	$(RNPL) -l allf  w1dcn_rnpl
	rnpl_fix_f77 updates.f initializers.f residuals.f

updates.f:     w1dcn_rnpl
residuals.f:     w1dcn_rnpl
initializers.f:     w1dcn_rnpl
w1dcn_init.f: w1dcn_rnpl

w1dcn_init: w1dcn_init.o updates.o initializers.o residuals.o
	$(F77_LOAD) w1dcn_init.o updates.o residuals.o initializers.o $(FLIBS) -o w1dcn_init

w1dcn: w1dcn.o updates.o residuals.o
	$(F77_LOAD) w1dcn.o updates.o residuals.o $(FLIBS) -o w1dcn

clean: 
	rm *.hdf *.sdf .rn*  w1dcn  w1dcn_init > /dev/null 2>&1
	rm *.o > /dev/null 2>&1
	rm residuals.f updates.f initializers.f w1dcn.f w1dcn_init.f > /dev/null 2>&1
	rm gfuni0.inc globals.inc other_glbs.inc sys_param.inc > /dev/null 2>&1
	rm work.pc work.pcl > /dev/null 2>&1
