1 |
# This is a makefile for GNU make. |
2 |
|
3 |
# This makefile builds LMDZE. |
4 |
|
5 |
# Suffixes are: |
6 |
# "f90" for free format, no preprocessing |
7 |
# "f" for fixed format, no preprocessing |
8 |
|
9 |
# 1. Source files |
10 |
|
11 |
src_root = . |
12 |
|
13 |
VPATH := ${src_root} $(addprefix ${src_root}/, $(shell cat ${src_root}/directories)) |
14 |
|
15 |
common_sources := $(shell cat ${src_root}/common_sources) |
16 |
src_ce0l_only := $(shell cat ${src_root}/src_ce0l_only) |
17 |
src_gcm_only := $(shell cat ${src_root}/src_gcm_only) |
18 |
sources = ${src_ce0l_only} ${src_gcm_only} ${common_sources} |
19 |
|
20 |
# 2. Objects and executable files |
21 |
|
22 |
obj_ce0l := $(addsuffix .o, $(sort $(basename ${common_sources} ${src_ce0l_only}))) |
23 |
|
24 |
obj_gcm := $(addsuffix .o, $(sort $(basename ${common_sources} ${src_gcm_only}))) |
25 |
|
26 |
objects := $(addsuffix .o, $(basename ${sources})) |
27 |
execut = ce0l gcm |
28 |
|
29 |
# 3. Compiler-dependent part |
30 |
|
31 |
mode = debug |
32 |
include Compiler_options/${FC}_${mode}.mk |
33 |
|
34 |
# 4. Rules |
35 |
|
36 |
SHELL = bash |
37 |
COMPILE.f90 = $(FC) $(F90FLAGS) $(TARGET_ARCH) -c |
38 |
|
39 |
%.o: %.f90 |
40 |
$(COMPILE.f90) $(OUTPUT_OPTION) $< |
41 |
|
42 |
.DELETE_ON_ERROR: |
43 |
.PHONY: all clean clobber depend |
44 |
all: ${execut} log |
45 |
|
46 |
${execut}: |
47 |
$(FC) $(LDFLAGS) $^ $(LDLIBS) -o $@ |
48 |
|
49 |
ce0l: ${obj_ce0l} |
50 |
gcm: ${obj_gcm} |
51 |
|
52 |
depend ${src_root}/depend.mk: |
53 |
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: ${sources} |
56 |
ctags -e --language-force=fortran -f $@ $^ |
57 |
|
58 |
clean: |
59 |
rm -f ${execut} ${objects} log |
60 |
|
61 |
clobber: clean |
62 |
rm -f *.mod ${src_root}/depend.mk ${src_root}/TAGS |
63 |
|
64 |
log: |
65 |
hostname >$@ |
66 |
${FC} ${version_flag} >>$@ 2>&1 |
67 |
echo -e "\nFC = ${FC}\n\nFFLAGS = ${FFLAGS}\n\nLDLIBS = ${LDLIBS}\n\nLDFLAGS = ${LDFLAGS}" >>$@ |
68 |
|
69 |
ifneq ($(MAKECMDGOALS), clobber) |
70 |
include ${src_root}/depend.mk |
71 |
endif |
72 |
|
73 |
-include grep.mk |
74 |
-include nag_rules.mk |