PKG_FFLAGS = #-Wall -pedantic #-O3 #-fno-align-commons -ffixed-line-length-none #-std=f95
PKG_FCFLAGS = #-mmacosx-version-min=11.1 #-Wall -pedantic #-O3 #-fno-align-commons -ffixed-line-length-none #-std=f95

all: $(SHLIB)

# Fortran 90 modules must be compiled before any file that `use`s them. CRAN
# builds with a parallel make (make -j); without explicit ordering it can
# a necessary `.mod` file might not be available, generating an error
# "Cannot open module file '<name>.mod'". Fix by declaring the dependencies 
# explicitly for files which use modules.
sorting.o: types.o
stats.o: sorting.o
utilities.o: stats.o sorting.o
FA.o: utilities.o
sac_snow.o: utilities.o
uh2p_get_scale.o: uh_optim.o
# zero_brent.f90 is a bare function (no module), linked into the shared object;
# uh_optim calls it as an external procedure.

# These files use obsolete features and so fail when using the default -std=f95
fka7.o: fka7.f
	$(FC) -c -fPIC -O2 fka7.f
flag7.o: flag7.f
	$(FC) -c -fPIC -O2 flag7.f
pin7.o: pin7.f
	$(FC) -c -fPIC -O2 pin7.f
ex57.o: ex57.f
	$(FC) -c -fPIC -O2 ex57.f
exsnow19.o: exsnow19.f
	$(FC) -c -fPIC -O2 exsnow19.f
