PROG = rmsd_pdb
FC = gfortran
FFLAGS = -O
LDFLAGS = -s
SRCS = Makefile rmsd_pdb.f90 pdb.f90 rmsd.f eigrs.f 
OBJS = rmsd_pdb.o rmsd.o pdb.o eigrs.o 

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

.SUFFIXES: $(SUFFIXES) .f90 .f

.f.o:
	$(FC) $(FFLAGS) -c $<

.f90.o:
	$(FC) $(FFLAGS) -c $<

eigrs.o: eigrs.f
pdb.o: pdb.f90
rmsd.o: rmsd.f 
rmsd_pdb.o: rmsd_pdb.f90 pdb.o 

.PHONY: default clean realclean debug fcheck fdepend showtargets

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

# realclean: remove all regenerable files, including executables
realclean: 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 realclean debug fcheck fdepend 

distclean: realclean
