# Standalone Makefile for FORTRAN 2003 interfaces to NETCDF C routines
# builds a local library libnetcfnf.a

# NOTE: version 2 interfaces are not built because they depend on
# fort-v2compat.c in the fortran directory

include ./macros.make

LIBRARY = ./libnetcdfnf.a

F03GARBAGE = module_netcdf_nc_interfaces.f90 \
 module_netcdf_nf_data.f90 \
 module_netcdf_nf_interfaces.f90 \
 module_netcdf_f03.f90 \
 nf_misc.f90 \
 nf_control.f90 \
 nf_dim.f90 \
 nf_gen_att.f90 \
 nf_gen_inq.f90 \
 nf_gen_var.f90 \
 nf_attio.f90 \
 nf_vario.f90 \
 nf_var1io.f90 \
 nf_varaio.f90 \
 nf_varsio.f90 \
 nf_varmio.f90

LIB_OBJS = module_netcdf_nc_interfaces.o \
 module_netcdf_nf_data.o \
 module_netcdf_nf_interfaces.o \
 module_netcdf_f03.o \
 nf_misc.o \
 nf_control.o \
 nf_dim.o \
 nf_gen_att.o \
 nf_gen_inq.o \
 nf_gen_var.o \
 nf_attio.o \
 nf_vario.o \
 nf_var1io.o \
 nf_varaio.o \
 nf_varsio.o \
 nf_varmio.o

all: lib

lib:  $(LIBRARY) 

$(LIBRARY): $(LIB_OBJS)
	$(AR) $(ARFLAGS) $@ $(LIB_OBJS)
	$(RANLIB) $@

install:
	cp ../fortran/netcdf.inc $(INCDIR)/

# make explicit targets since we don't have a lot of files

module_netcdf_nc_interfaces.o: module_netcdf_nc_interfaces_.F90
	$(FPP) $(FPPFLAGS) module_netcdf_nc_interfaces_.F90 > module_netcdf_nc_interfaces.f90
	$(F90) -c $(F90FLAGS) module_netcdf_nc_interfaces.f90

module_netcdf_nf_data.o: module_netcdf_nf_data_.F90
	$(FPP) $(FPPFLAGS) module_netcdf_nf_data_.F90 > module_netcdf_nf_data.f90
	$(F90) -c $(F90FLAGS) module_netcdf_nf_data.f90

module_netcdf_nf_interfaces.o: module_netcdf_nf_interfaces_.F90
	$(FPP) $(FPPFLAGS) module_netcdf_nf_interfaces_.F90 > module_netcdf_nf_interfaces.f90
	$(F90) -c $(F90FLAGS) module_netcdf_nf_interfaces.f90

module_netcdf_f03.o: module_netcdf_f03_.F90
	$(FPP) $(FPPFLAGS) module_netcdf_f03_.F90 > module_netcdf_f03.f90
	$(F90) -c $(F90FLAGS) module_netcdf_f03.f90

nf_attio.o: nf_attio_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_attio_.F90 > nf_attio.f90
	$(F90) -c $(F90FLAGS) nf_attio.f90

nf_misc.o: nf_misc_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_misc_.F90 > nf_misc.f90
	$(F90) -c $(F90FLAGS) nf_misc.f90

nf_control.o: nf_control_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_control_.F90 > nf_control.f90
	$(F90) -c $(F90FLAGS) nf_control.f90

nf_dim.o: nf_dim_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_dim_.F90 > nf_dim.f90
	$(F90) -c $(F90FLAGS) nf_dim.f90

nf_vario.o: nf_vario_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_vario_.F90 > nf_vario.f90
	$(F90) -c $(F90FLAGS) nf_vario.f90

nf_gen_att.o: nf_gen_att_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_gen_att_.F90 > nf_gen_att.f90
	$(F90) -c $(F90FLAGS) nf_gen_att.f90

nf_gen_inq.o: nf_gen_inq_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_gen_inq_.F90 > nf_gen_inq.f90
	$(F90) -c $(F90FLAGS) nf_gen_inq.f90

nf_gen_var.o: nf_gen_var_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_gen_var_.F90 > nf_gen_var.f90
	$(F90) -c $(F90FLAGS) nf_gen_var.f90

nf_var1io.o: nf_var1io_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_var1io_.F90 > nf_var1io.f90
	$(F90) -c $(F90FLAGS) nf_var1io.f90

nf_varaio.o: nf_varaio_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_varaio_.F90 > nf_varaio.f90
	$(F90) -c $(F90FLAGS) nf_varaio.f90

nf_varsio.o: nf_varsio_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_varsio_.F90 > nf_varsio.f90
	$(F90) -c $(F90FLAGS) nf_varsio.f90

nf_varmio.o: nf_varmio_.F90 $(NCINTS)
	$(FPP) $(FPPFLAGS) nf_varmio_.F90 > nf_varmio.f90
	$(F90) -c $(F90FLAGS) nf_varmio.f90

clean:
	$(RM) *.o *~ *.mod *.a $(F03GARBAGE) 
