13 |
VPATH := ${src_root} $(addprefix ${src_root}/, $(shell cat ${src_root}/directories)) |
VPATH := ${src_root} $(addprefix ${src_root}/, $(shell cat ${src_root}/directories)) |
14 |
|
|
15 |
common_sources := $(shell cat ${src_root}/common_sources) |
common_sources := $(shell cat ${src_root}/common_sources) |
16 |
src_no_main_ce0l_only := $(shell cat ${src_root}/src_no_main_ce0l_only) |
src_ce0l_only := $(shell cat ${src_root}/src_ce0l_only) |
17 |
src_no_main_gcm_only := $(shell cat ${src_root}/src_no_main_gcm_only) |
src_gcm_only := $(shell cat ${src_root}/src_gcm_only) |
18 |
src_no_main = ${src_no_main_ce0l_only} ${src_no_main_gcm_only} ${common_sources} |
sources = ${src_ce0l_only} ${src_gcm_only} ${common_sources} |
19 |
|
|
20 |
# 2. Objects |
# 2. Objects and executable files |
21 |
|
|
22 |
obj_ce0l := $(addsuffix .o, $(sort $(basename ${common_sources} ${src_no_main_ce0l_only}))) |
obj_ce0l := $(addsuffix .o, $(sort $(basename ${common_sources} ${src_ce0l_only}))) |
23 |
|
|
24 |
obj_gcm := $(addsuffix .o, $(sort $(basename ${common_sources} ${src_no_main_gcm_only}))) |
obj_gcm := $(addsuffix .o, $(sort $(basename ${common_sources} ${src_gcm_only}))) |
25 |
|
|
26 |
objects := $(addsuffix .o, $(basename ${src_no_main})) |
objects := $(addsuffix .o, $(basename ${sources})) |
27 |
|
execut = ce0l gcm |
28 |
|
|
29 |
# 3. Compiler-dependent part |
# 3. Compiler-dependent part |
30 |
|
|
39 |
%.o: %.f90 |
%.o: %.f90 |
40 |
$(COMPILE.f90) $(OUTPUT_OPTION) $< |
$(COMPILE.f90) $(OUTPUT_OPTION) $< |
41 |
|
|
|
%: %.f90 |
|
|
$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@ |
|
|
|
|
42 |
.DELETE_ON_ERROR: |
.DELETE_ON_ERROR: |
43 |
.PHONY: all clean clobber depend |
.PHONY: all clean clobber depend |
44 |
all: ce0l gcm trace |
all: ${execut} log |
45 |
|
|
46 |
|
${execut}: |
47 |
|
$(FC) $(LDFLAGS) $^ $(LDLIBS) -o $@ |
48 |
|
|
49 |
ce0l: ${obj_ce0l} |
ce0l: ${obj_ce0l} |
50 |
gcm: ${obj_gcm} |
gcm: ${obj_gcm} |
51 |
|
|
52 |
depend ${src_root}/depend.mk: |
depend ${src_root}/depend.mk: |
53 |
makedepf90 -Wmissing -Wconfused $(addprefix -I, ${VPATH}) -nosrc $(addprefix -u , netcdf numer_rec_95 netcdf95 nr_util jumble) ${src_no_main} >${src_root}/depend.mk |
makedepf90 -Wmissing -Wconfused $(addprefix -I, ${VPATH}) -nosrc $(addprefix -u , netcdf numer_rec_95 netcdf95 nr_util jumble) ${sources} >${src_root}/depend.mk |
54 |
|
|
55 |
${src_root}/TAGS: ${src_no_main} ce0l.f90 gcm.f90 |
${src_root}/TAGS: ${sources} |
56 |
ctags -e --language-force=fortran -f $@ $^ |
ctags -e --language-force=fortran -f $@ $^ |
57 |
|
|
58 |
clean: |
clean: |
59 |
rm -f ce0l gcm ${objects} trace |
rm -f ${execut} ${objects} log |
60 |
|
|
61 |
clobber: clean |
clobber: clean |
62 |
rm -f *.mod ${src_root}/depend.mk ${src_root}/TAGS |
rm -f *.mod ${src_root}/depend.mk ${src_root}/TAGS |
63 |
|
|
64 |
trace: |
log: |
65 |
${FC} ${version_flag} >$@ 2>&1 |
hostname >$@ |
66 |
|
${FC} ${version_flag} >>$@ 2>&1 |
67 |
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}" >>$@ |
68 |
|
|
69 |
ifneq ($(MAKECMDGOALS), clobber) |
ifneq ($(MAKECMDGOALS), clobber) |