# NUT-0 makefile for alpha sherlock.ph.utexas.edu
#
# Type or call from another script:
# make geom         To make a new nut0 geometry,
# make or make exe  To make Nut0 executable stand-alone program,
# make lib          To make nut0.a library with all nut0 subs in it,
# make clean        To clean up,
#
# Get the idea?
###############################################################
# To make a custom file for your machine, 
# choose the right "rules" file from the rules/ directory
#
include rules
#
# Note that this is all you need to change for your machine
# I have provided sample rules files for:
# rules_sun   : sun os
# rules_alpha : alpha linux
#
# To make your own rules file, see my rules_alpha and
# look up how your other makefiles set the various flags.
# There are some dummy flags here ("") that you may need.
# 
# When you do figure out the correct settings, 
# I will appreciate if you email me the new file so that
# I can include it in nut distribution.
#
# This file uses only local files.
#
# Note that this code will NOT compile with f77
# you MUST use an f90 compiler
# Some machines automatically assume *.f files to be f77
# My compiler (Fujitsu) associates *.f with fixed format files,
# but not with f77 compiler, so I have no trouble.
# You may need to specify that the file format is fixed, 
# but the compiler to use is the f90 version.
# All this inherited baggage will vanish in NUT-1
###############################################################
# Here are all the *.f files needed for nut_0 executable
fsubs = nut0_demo.f nut0_subs.f nut0_fs.f nut0_wdata.f
exe    : $(fsubs:.f=.o)
	 $(FC) $(FFLAGS) -o Nut0 $(fsubs:.f=.o)

#####
# Files needed for geometrical pre-processor:
gsubs = nut0_new_geom.f nut0_fs.f nut0_wdata.f
geom   : $(gsubs:.f=.o)
	 $(FC) $(FFLAGS) -o nut0_new_geom $(gsubs:.f=.o)

######
# All include file dependencies (*.i files needed in each *.f file):
ginc = nut0_constants.i 
nut0_new_geom.o : \
	 $(ginc)

sinc = nut0_constants.i nut0_icom.i nut0_idata.i
nut0_subs.o : \
	 $(sinc)

dinc = nut0_ucom.i
nut0_demo.o : \
	 $(dinc)

#####
lib    : 
	 ar $(ARFLAGS) nut0.a \
         nut0_subs.o nut0_fs.o nut0_wdata.o
##### 
# This defines what is in the nut0.tar file
tar    :
	rm -rf nut0
	mkdir nut0
	cp README nut0_install nut0_make nutpl \
           demo fs gifs src dat docs rules nut0
	tar -cvf nut0.tar nut0

######
# Rule to convert .f to .o, in case your machine does not have it
objs   : $(@:o=f)
	 $(FC) $(FFLAGS) $(@:o=f)

#####
.PHONY	: clean
clean	:
	 -rm -f core *.o
######
