--- trunk/GNUmakefile 2014/03/12 21:16:36 90 +++ trunk/GNUmakefile 2018/05/03 16:14:08 267 @@ -4,59 +4,80 @@ # 1. Source files -src_root = . +makefile_dir = . -VPATH := ${src_root} $(addprefix ${src_root}/, $(shell cat ${src_root}/directories)) +VPATH := ${makefile_dir} $(addprefix ${makefile_dir}/, $(shell cat ${makefile_dir}/directories)) -common_sources := $(shell cat ${src_root}/common_sources) -src_ce0l_only := $(shell cat ${src_root}/src_ce0l_only) -src_gcm_only := $(shell cat ${src_root}/src_gcm_only) -sources = ${src_ce0l_only} ${src_gcm_only} ${common_sources} +src_ce0l := $(shell cat ${makefile_dir}/src_ce0l) +src_gcm := $(shell cat ${makefile_dir}/src_gcm) +src_test_ozonecm := $(shell cat ${makefile_dir}/src_test_ozonecm) +src_test_inter_barxy := $(shell cat ${makefile_dir}/src_test_inter_barxy) +src_test_fxhyp := $(shell cat ${makefile_dir}/src_test_fxhyp) +src_test_inifilr := $(shell cat ${makefile_dir}/src_test_inifilr) + +sources := $(sort ${src_ce0l} ${src_gcm} ${src_test_ozonecm} ${src_test_inter_barxy} ${src_test_fxhyp} ${src_test_inifilr}) + +cpp_macros = CPP_IIM=16,CPP_JJM=12,CPP_LLM=11 +lib_list = numer_rec_95 jumble nr_util netcdf95 netcdff # 2. Objects and executable files -obj_ce0l := $(sort ${common_sources:.f=.o} ${src_ce0l_only:.f=.o}) -obj_gcm := $(sort ${common_sources:.f=.o} ${src_gcm_only:.f=.o}) -objects := $(sources:.f=.o) -execut = ce0l gcm +obj_ce0l := $(addsuffix .o, $(basename ${src_ce0l})) +obj_gcm := $(addsuffix .o, $(basename ${src_gcm})) +obj_test_ozonecm := $(addsuffix .o, $(basename ${src_test_ozonecm})) +obj_test_inter_barxy := $(addsuffix .o, $(basename ${src_test_inter_barxy})) +obj_test_fxhyp := $(addsuffix .o, $(basename ${src_test_fxhyp})) +obj_test_inifilr := $(addsuffix .o, $(basename ${src_test_inifilr})) +objects := $(addsuffix .o, $(basename ${sources})) +execut = ce0l gcm test_ozonecm test_inter_barxy test_fxhyp test_inifilr # 3. Compiler-dependent part mode = debug -include Compiler_options/${FC}_${mode}.mk +include ${general_compiler_options_dir}/${FC}_${mode}.mk # 4. Rules SHELL = bash +LINK.o = $(FC) $(LDFLAGS) $(TARGET_ARCH) + +%.o: %.f + @echo "Building $@..." + @$(COMPILE.f) $(OUTPUT_OPTION) $< + +%: %.o + @echo "Linking $@..." + @$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ + .DELETE_ON_ERROR: .PHONY: all clean clobber depend all: ${execut} log - -${execut}: - $(FC) $(LDFLAGS) $^ $(LDLIBS) -o $@ - ce0l: ${obj_ce0l} gcm: ${obj_gcm} +test_ozonecm: ${obj_test_ozonecm} +test_inter_barxy: ${obj_test_inter_barxy} +test_fxhyp: ${obj_test_fxhyp} +test_inifilr: ${obj_test_inifilr} -depend ${src_root}/depend.mk: - makedepf90 -free -Wmissing -Wconfused $(addprefix -I, ${VPATH}) -nosrc $(addprefix -u , netcdf numer_rec_95 netcdf95 nr_util jumble) ${sources} >${src_root}/depend.mk +depend ${makefile_dir}/depend.mk: + makedepf90 -free -Wmissing -Wconfused $(addprefix -I, ${VPATH}) -nosrc $(addprefix -u , netcdf numer_rec_95 netcdf95 nr_util jumble) ${sources} >${makefile_dir}/depend.mk -${src_root}/TAGS: ${sources} - ctags -e --language-force=fortran -f $@ $^ +TAGS: ${sources} + ctags -e --language-force=fortran $^ clean: rm -f ${execut} ${objects} log clobber: clean - rm -f *.mod ${src_root}/depend.mk ${src_root}/TAGS + rm -f *.mod ${makefile_dir}/depend.mk TAGS log: hostname >$@ ${FC} ${version_flag} >>$@ 2>&1 - echo -e "\nFC = ${FC}\n\nFFLAGS = ${FFLAGS}\n\nLDLIBS = ${LDLIBS}\n\nLDFLAGS = ${LDFLAGS}" >>$@ + @echo -e "\nFC = ${FC}\n\nFFLAGS = ${FFLAGS}\n\nLDLIBS = ${LDLIBS}\n\nLDFLAGS = ${LDFLAGS}" >>$@ ifeq ($(findstring $(MAKECMDGOALS), clobber depend),) -include ${src_root}/depend.mk +include ${makefile_dir}/depend.mk endif -include grep.mk