PROG = analysis
FC = gfortran
#FC = gfortran -ffixed-line-length-0 -std=legacy 
LIBS = 
FFLAGS = -O
LDFLAGS = -s
SRCS = Makefile lapack.f rs.f precision.f90 units.f90 output.f90 input.f90 constants.f90 pdb.f90 cv.f90 analysis.f90 
OBJS = lapack.o rs.o precision.o units.o output.o input.o constants.o pdb.o cv.o analysis.o 

$(PROG): $(OBJS)
	$(FC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

# use this PATTERN rule instead of old-fashioned SUFFIX rules like 
#.SUFFIXES: $(SUFFIXES) .f90 
#
#.f90.o:
#	$(FC) $(FFLAGS) -c $<
%.o : %.f90
	$(FC) $(FFLAGS) -c $<


precision.o: precision.f90
lapack.o: lapack.f 
rs.o: rs.f
output.o: output.f90 precision.o units.o
units.o: units.f90 precision.o
input.o: input.f90 precision.o
output.o: output.f90 precision.o units.o
constants.o: constants.f90 precision.o
pdb.o: pdb.f90 precision.o units.o
cv.o: cv.f90 precision.o constants.o pdb.o
analysis.o: analysis.f90 precision.o output.o units.o pdb.o input.o cv.o

.PHONY: default clean veryclean debug fcheck fdepend showtargets

# clean: remove useless files, but keep executables
clean:
	$(RM) core TAGS ?*[~#] *.o __* ...* *.mod $(PROG)

# veryclean: remove all regenerable files, including executables
veryclean: clean
	$(RM) $(PROG) $(OBJS)

# debug: debug options (enable D comments lines, disable -O for ABSOFT)
debug:
	$(MAKE) "FFLAGS=-g " "OSTYPE=$(OSTYPE:-gnu=)"

# fcheck: pass sources to the Fortran program checker
fcheck:
	fcheck -nonovice main.f90

# fdepend: pass sources to the Fortran dependency analyzer
fdepend:
	fdepend main.f90

# showtargets: list the most important targets of this makefile
showtargets:
	@ echo clean veryclean debug fcheck fdepend 

distclean: veryclean
