forked from szaghi/FLAP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
163 lines (142 loc) · 3.99 KB
/
makefile
File metadata and controls
163 lines (142 loc) · 3.99 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/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)libflap.a $(DOBJ)*.o ; ranlib $(DEXE)libflap.a
RULE = FLAP
else
DOBJ = tests/obj/
DMOD = tests/mod/
DEXE = tests/
RULE = $(DEXE)test_basic $(DEXE)test_choices_logical $(DEXE)test_nested $(DEXE)test_string
endif
DSRC = src/
LIBS =
ifeq "$(COMPILER)" "gnu"
FC = gfortran
OPTSC = -cpp -c -frealloc-lhs -O2 -J $(DMOD) -ffree-line-length-none
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 = "Compile $(<F)"
LITEXT = "Assemble $@"
RUTEXT = "Executed rule $@"
firsrule: $(RULE)
#building rules
$(DEXE)test_basic: $(MKDIRS) $(DOBJ)test_basic.o
@rm -f $(filter-out $(DOBJ)test_basic.o,$(EXESOBJ))
@echo $(LITEXT)
@$(FC) $(OPTSL) $(DOBJ)*.o $(LIBS) -o $@
EXES := $(EXES) test_basic
$(DEXE)test_choices_logical: $(MKDIRS) $(DOBJ)test_choices_logical.o
@rm -f $(filter-out $(DOBJ)test_choices_logical.o,$(EXESOBJ))
@echo $(LITEXT)
@$(FC) $(OPTSL) $(DOBJ)*.o $(LIBS) -o $@
EXES := $(EXES) test_choices_logical
$(DEXE)test_nested: $(MKDIRS) $(DOBJ)test_nested.o
@rm -f $(filter-out $(DOBJ)test_nested.o,$(EXESOBJ))
@echo $(LITEXT)
@$(FC) $(OPTSL) $(DOBJ)*.o $(LIBS) -o $@
EXES := $(EXES) test_nested
$(DEXE)test_string: $(MKDIRS) $(DOBJ)test_string.o
@rm -f $(filter-out $(DOBJ)test_string.o,$(EXESOBJ))
@echo $(LITEXT)
@$(FC) $(OPTSL) $(DOBJ)*.o $(LIBS) -o $@
EXES := $(EXES) test_string
FLAP: $(MKDIRS) $(DOBJ)flap.o
@echo $(LITEXT)
@$(MAKELIB)
#compiling rules
$(DOBJ)flap_command_line_interface_t.o: src/lib/flap_command_line_interface_t.F90 \
$(DOBJ)flap_command_line_argument_t.o \
$(DOBJ)flap_command_line_arguments_group_t.o \
$(DOBJ)flap_object_t.o \
$(DOBJ)flap_utils_m.o \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)flap_command_line_arguments_group_t.o: src/lib/flap_command_line_arguments_group_t.f90 \
$(DOBJ)flap_command_line_argument_t.o \
$(DOBJ)flap_object_t.o \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)flap_utils_m.o: src/lib/flap_utils_m.f90 \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)flap_command_line_argument_t.o: src/lib/flap_command_line_argument_t.F90 \
$(DOBJ)flap_object_t.o \
$(DOBJ)flap_utils_m.o \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)flap_object_t.o: src/lib/flap_object_t.f90 \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)flap.o: src/lib/flap.f90 \
$(DOBJ)flap_command_line_argument_t.o \
$(DOBJ)flap_command_line_arguments_group_t.o \
$(DOBJ)flap_command_line_interface_t.o \
$(DOBJ)penf.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)penf.o: src/third_party/PENF/src/lib/penf.F90
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)test_nested.o: src/tests/test_nested.f90 \
$(DOBJ)penf.o \
$(DOBJ)flap.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)test_choices_logical.o: src/tests/test_choices_logical.f90 \
$(DOBJ)penf.o \
$(DOBJ)flap.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)test_string.o: src/tests/test_string.f90 \
$(DOBJ)penf.o \
$(DOBJ)flap.o
@echo $(COTEXT)
@$(FC) $(OPTSC) $< -o $@
$(DOBJ)test_basic.o: src/tests/test_basic.f90 \
$(DOBJ)penf.o \
$(DOBJ)flap.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