#############################################################################
# 									    #
# Makefile to compile and link FORTRAN programs                             #
#  									    #
# "make" compiles and links the specified main programs and modules,        #
# using the specified libraries (if any), and produces the executables      #
#									    #
# "make clean" removes all files generated by "make"                        #
#                                                                           #
#############################################################################


all: rmxeq  mkxeq
.PHONY: all

# main programs and modules to be compiled 

MAIN = hfbcs-qrpa

# List of the modules to include

MODULES = hfbcs qrpa lib label force units reader unoccupied readhfbcs

# search path for modules

# additional libraries
#LIBS = 
#LIBPATH =

# scheduling and optimization options 

FFLAGS = -O3

# To check in which subroutines does the code spend time,
# compile the code with the -pg option, and then run it with
# gprof nnqns > reportfile.txt


############################## do not change #############################

SHELL=/bin/bash
FF=f77
#FF=g77
#FF=ifort
FLINKER=$(FF) 

PGMS= $(MAIN) $(MODULES)

-include $(addsuffix .d,$(PGMS))

# rule to compile source programs

$(addsuffix .o,$(PGMS)): %.o: %.f Makefile
	$(FF) $< -c $(FFLAGS)

# rule to link object files

$(MAIN): %: %.o $(addsuffix .o,$(MODULES)) Makefile
	$(FLINKER) $< $(addsuffix .o,$(MODULES)) $(FFLAGS)  \
        $(addprefix -L,$(LIBPATH)) $(addprefix -l,$(LIBS)) -o $@

# produce executables

mkxeq: $(MAIN)

# remove old executables

rmxeq:
	@ -rm -f $(MAIN); \
        echo "delete old executables"		

# clean directory 

clean:
	@ -rm -rf *.o *.out *.dat *~  *.eps $(MAIN)
.PHONY: clean
 
################################################################################
