# Code Aspects, version 2.0.
# Michel Fioc, 2014-4-15. 

f95_compiler = ifort
#f95_compiler = gfortran

# Options of compilation (none of them is mandatory):
ifeq ($(f95_compiler), ifort)
  f95_options = -std95 -fp-model precise -check bounds -check overflow \
		-check uninit -warn declarations -warn argument_checking \
		-warn uninitialized -warn usage -implicitnone -warn uncalled \
		-warn unused
else # gfortran
  f95_options = -fimplicit-none -Wextra -finit-local-zero -fbounds-check 
endif

all: example_simul example_read

%.o: %.f90

	@ echo "\nCompiling \"$<\""
	@ $(f95_compiler) $(f95_options) -o $@ -c $<
	@ echo "Done"

mod_simul_catalogs.o: mod_constants.o \
	mod_heap_index.o \
	mod_types.o \
	mod_variables.o

mod_constants.o: mod_types.o 

mod_heap_index.o: mod_constants.o

mod_Aspects.o: mod_types.o \
	mod_constants.o \
	mod_heap_index.o 

mod_variables.o: mod_types.o 

mod_read_catalog.o: mod_types.o \
	mod_files.o 

mod_output_prob.o: mod_types.o \
	mod_files.o 

example_simul.o: mod_files.o \
	mod_types.o \
	mod_constants.o \
	mod_Aspects.o \
	mod_simul_catalogs.o \
	mod_variables.o

example_read.o: mod_types.o \
	mod_constants.o \
	mod_Aspects.o \
	mod_files.o \
	mod_variables.o \
	mod_read_catalog.o \
	mod_output_prob.o

example_simul: example_simul.o \
	mod_heap_index.o \
	mod_Aspects.o \
	mod_constants.o \
	mod_files.o \
	mod_read_catalog.o \
	mod_simul_catalogs.o \
	mod_types.o \
	mod_variables.o

	@ echo "\nLinking \"example_simul\""
	@ $(f95_compiler) $(f95_options) -o $@ $^
	@ echo "Done"

example_read: mod_types.o \
	mod_constants.o \
	mod_Aspects.o \
	mod_files.o \
	mod_variables.o \
	mod_read_catalog.o \
	mod_heap_index.o \
	mod_output_prob.o \
	example_read.o

	@ echo "\nLinking \"example_read\""
	@ $(f95_compiler) $(f95_options) -o $@ $^
	@ echo "Done\n"

clean:
	rm -f *.o *.mod

clean_all:
	rm -f *.o *.mod example_simul example_read