-
Notifications
You must be signed in to change notification settings - Fork 17
/
makefile
119 lines (104 loc) · 2.8 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/make
# defaults
STATIC = no
COMPILER = gnu
#main building variables
ifeq "$(STATIC)" "yes"
DOBJ = static/obj/
DMOD = static/mod/
DEXE = static/
MAKELIB = ar -rcs $(DEXE)libwenoof.a $(DOBJ)*.o ; ranlib $(DEXE)libwenoof.a
RULE = WENOOF
else
DOBJ = tests/obj/
DMOD = tests/mod/
DEXE = tests/
RULE = $(DEXE)sin_reconstruction $(DEXE)modules_imports
endif
DSRC = src/
LIBS =
ifeq "$(COMPILER)" "gnu"
FC = gfortran
OPTSC = -cpp -c -frealloc-lhs -O2 -J $(DMOD)
OPTSL = -J $(DMOD)
endif
ifeq "$(COMPILER)" "ibm"
FC = bgxlf2008_r
OPTSC = -c -O2 -qmoddir=$(DMOD) -I$(DMOD)
OPTSL = -qmoddir=$(DMOD) -I$(DMOD)
endif
VPATH = $(DSRC) $(DOBJ) $(DMOD)
MKDIRS = $(DOBJ) $(DMOD) $(DEXE)
LCEXES = $(shell echo $(EXES) | tr '[:upper:]' '[:lower:]')
EXESPO = $(addsuffix .o,$(LCEXES))
EXESOBJ = $(addprefix $(DOBJ),$(EXESPO))
#auxiliary variables
COTEXT = "Compiling $(<F)"
LITEXT = "Assembling $@"
RUTEXT = "Executed rule $@"
firsrule: $(RULE)
#building rules
$(DEXE)sin_reconstruction: $(MKDIRS) $(DOBJ)sin_reconstruction.o
@rm -f $(filter-out $(DOBJ)sin_reconstruction.o,$(EXESOBJ))
@echo $(LITEXT)
@$(FC) $(OPTSL) $(DOBJ)*.o $(LIBS) -o $@
EXES := $(EXES) sin_reconstruction
$(DEXE)modules_imports: $(MKDIRS) $(DOBJ)modules_imports.o
@rm -f $(filter-out $(DOBJ)modules_imports.o,$(EXESOBJ))
@echo $(LITEXT)
@$(FC) $(OPTSL) $(DOBJ)*.o $(LIBS) -o $@
EXES := $(EXES) modules_imports
WENOOF: $(MKDIRS) $(DOBJ)wenoof.o
@echo $(LITEXT)
@$(MAKELIB)
#compiling rules
$(DOBJ)wenoof.o: src/lib/wenoof.f90 \
$(DOBJ)type_weno_interpolator.o \
$(DOBJ)type_weno_interpolator_upwind.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)type_weno_interpolator.o: src/lib/type_weno_interpolator.f90 \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)type_weno_interpolator_upwind.o: src/lib/type_weno_interpolator_upwind.f90 \
$(DOBJ)penf.o \
$(DOBJ)type_weno_interpolator.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)pyplot_module.o: src/third_party/pyplot-fortran/src/pyplot_module.f90
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)penf.o: src/third_party/PENF/src/lib/penf.F90
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)sin_reconstruction.o: src/tests/sin_reconstruction.f90 \
$(DOBJ)penf.o \
$(DOBJ)wenoof.o \
$(DOBJ)pyplot_module.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)modules_imports.o: src/tests/modules_imports.f90 \
$(DOBJ)wenoof.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
#phony auxiliary rules
.PHONY : $(MKDIRS)
$(MKDIRS):
@mkdir -p $@
.PHONY : cleanobj
cleanobj:
@echo deleting objects
@rm -fr $(DOBJ)
.PHONY : cleanmod
cleanmod:
@echo deleting mods
@rm -fr $(DMOD)
.PHONY : cleanexe
cleanexe:
@echo deleting exes
@rm -f $(addprefix $(DEXE),$(EXES))
.PHONY : clean
clean: cleanobj cleanmod
.PHONY : cleanall
cleanall: clean cleanexe