-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.objects
254 lines (196 loc) · 6.64 KB
/
Makefile.objects
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
######################################################### -*- Makefile -*-
#****e* /Makefile.objects
# NAME
# Makefile.objects
# PURPOSE
# SUB-Makefile for the BUU Code:
# to be used in the directory /objects and in .../testRun
#
# This is a template, which must be copied as a local "Makefile"
# into each directory in the tree where an exe-file should be produced.
# In particular it must be used in the directory "objects" and in
# each "testRun" directory.
#***
#########################################################
.SUFFIXES: # Delete the default suffixes
export SHELL := /bin/bash
### LOCAL VARIABLES:
include Makefile.local
export CALLINGDIR := $(CURDIR)
export OS = $(strip $(shell uname))
export noPrintDirectory=--no-print-directory
export ECHO = echo -e
export PERL = $(strip $(shell which perl 2>/dev/null))
ifeq ($(PERL),$(EMPTY))
export MAKEDEP = $(strip $(shell which makedepf90 2>/dev/null))
endif
ifeq ($(OS),Darwin)
export FIND = gfind
else
export FIND = find
endif
### FILES:
SRCf90 := $(wildcard *.f90)
SRCF90 := $(wildcard *.F90)
SRCf77 := $(wildcard *.f)
SRC := $(SRCf90) $(SRCF90) $(SRCf77)
SRC := $(filter-out $(FILEEXCL), $(SRC))
SRC := $(filter-out $(EXEFILE), $(SRC))
OBJ := $(patsubst %.f90, %.o, $(SRC))
OBJ := $(patsubst %.F90, %.o, $(OBJ))
OBJ := $(patsubst %.f, %.o, $(OBJ))
MOD := $(patsubst %.f90, %.o, $(SRC))
MOD := $(patsubst %.F90, %.o, $(MOD))
MOD := $(patsubst %.f, %.o, $(MOD))
EXEALL := $(patsubst %.f90, %.x, $(EXEFILE))
EXEALL := $(patsubst %.F90, %.x, $(EXEALL))
EXEALL := $(patsubst %.f, %.x, $(EXEALL))
# The following is only well defined when compiling the
# executable in OBJDIR (i.e. in the second call) or if
# you use this Makefile in a directory other than OBJDIR:
OBJDIROBJ := $(wildcard $(strip $(OBJDIR))/*.o)
OBJDIROBJ := $(filter-out $(strip $(OBJDIR))/PDFstub.orig.6225.o, $(OBJDIROBJ))
### SUBDIRS:
SUBDIRAUTO := $(sort $(notdir $(shell $(FIND) -maxdepth 1 ! -name ".*" -type d)))
SUBDIRAUTO := $(filter-out $(SUBDIR), $(SUBDIRAUTO))
SUBDIRAUTO := $(filter-out $(SUBDIREXCL), $(SUBDIRAUTO))
SUBDIRAUTO := $(filter-out $(wildcard *.dSYM), $(SUBDIRAUTO))
SUBDIR += $(SUBDIRAUTO)
### Compiler flags: (use as abbreviation)
FLAGSF77c=$(FLAGSF77) $(FLAGSDOUBLE) $(FLAGSFORALL) -I$(OBJDIR)
FLAGSF90c=$(FLAGSF90) $(FLAGSDOUBLE) $(FLAGSFORALL) -I$(OBJDIR)
FLAGSLD=-L$(strip $(LIBDIR)) -lPDF -lbz2
### RULES:
# This is the target called without any arguments:
# (empty target in order to ensure clean programming)
#all: ;
# (calling testRun instead:)
all: full
bw:
@$(MAKE) StartHeader= EndHeader= StartHeader_green= StartHeader_red= blue= endBlue=
# In the following "workdir" will be replaced automatically by the
# main Makefile directory:
quick:
@cd WORKDIR && $(MAKE) CalledFromTestRun
full:
@cd WORKDIR && $(MAKE) CalledFromTestRunFull
renew:
cd WORKDIR && $(MAKE) renew
clean:
cd WORKDIR && $(MAKE) clean
veryclean:
cd WORKDIR && $(MAKE) veryclean
#iterate: subdirs depend objects EXE
iterate: MakefileDepend objects EXE
compileOBJ:
@$(MAKE) subdirs
@$(MAKE) MakefileDepend
@$(MAKE) objects
objects: $(OBJ)
EXE: $(EXEALL)
# We assume here, that there are no .o and no .mod files
# generated in /testRun. If necessary, this has to be
# improved.
#
#linking:
# @for X in $(OBJ); do\
# (ln -sf $(CURDIR)/$$X $(OBJDIR)/$$X;)\
# done
# @for X in $(shell $(FIND) -maxdepth 1 -name "*.mod" ); do\
# (ln -sf $(CURDIR)/$$X $(OBJDIR)/$$X;)\
# done
print:
@echo "!!! CURDIR =" $(CURDIR)
@echo "!!! SUBDIR =" $(SUBDIR)
@echo "!!! SRC =" $(SRC)
subdirs:
@for X in $(SUBDIR); do\
(cd $$X && $(MAKE) iterate;)\
done
MakefileDepend: $(SRC)
ifneq ($(PERL),$(EMPTY))
@echo "Generating source code dependencies via perl script!"
@WORKDIR/scripts/Own_Makedepf90.pl $(SRC) > MakefileDepend
else
ifneq ($(MAKEDEP),$(EMPTY))
@echo "Generating source code dependencies via makedepf90!"
@$(MAKEDEP) -m "%f.o" $(SRC) > MakefileDepend
else
@echo "Error: Could not generate source code dependencies! (neither perl nor makedepf90 found)"
endif
endif
ModGraph:
@echo "Generating module dependency graph!"
@WORKDIR/scripts/MakeModGraph.pl $(SRC) $(EXEFILE) > modgraph.dot
time dot -Grankdir=LR -Tsvg -o WORKDIR/ModGraph.svg modgraph.dot
Makefiles: #print
@for X in $(SUBDIR); do\
(cp $(ROOTDIR)/Makefile.SUB $$X/Makefile; \
cd $$X && $(MAKE) Makefiles;)\
done
### Compiling:
%.o: %.f90
@$(ECHO) $(blue)File: `ls -l $< | awk '{print $$NF}'` $(endBlue)
$(FORT) $(FLAGSF90c) -c $<
%.o: %.F90
@$(ECHO) $(blue)File: `ls -l $< | awk '{print $$NF}'` $(endBlue)
$(FORT) $(FLAGSF90c) -D$(FORT_NOPATH) -c $<
%.o: %.f
@$(ECHO) $(blue)File: `ls -l $< | awk '{print $$NF}'` $(endBlue)
$(FORT) $(FLAGSF77c) -c $<
### Compiling and linking:
%.x: %.f90 $(OBJDIR)/version.o
@$(ECHO) $(StartHeader)"Compiling executable" $@ $(EndHeader)
@$(ECHO) "Flags: " $(FLAGSF90c) $(FLAGSLD)
@$(FORT) $(FLAGSF90c) -o $@ $< $(OBJDIROBJ) $(FLAGSLD)
@ln -sf $(CURDIR)/$@ $(EXEDIR)
@$(ECHO) $(StartHeader)"...done"$(EndHeader)
%.x: %.F90 $(OBJDIR)/version.o
@$(ECHO) $(StartHeader)"Compiling executable" $@ $(EndHeader)
@$(ECHO) "Flags: " $(FLAGSF90c) -D$(FORT_NOPATH) $(FLAGSLD)
@$(FORT) $(FLAGSF90c) -D$(FORT_NOPATH) -o $@ $< $(OBJDIROBJ) $(FLAGSLD)
@ln -sf $(CURDIR)/$@ $(EXEDIR)
@$(ECHO) $(StartHeader)"...done"$(EndHeader)
%.x: %.f $(OBJDIR)/version.o
@$(ECHO) $(StartHeader)"Compiling executable" $@ $(EndHeader)
@$(ECHO) "Flags: " $(FLAGSF77c) $(FLAGSLD)
@$(FORT) $(FLAGSF77c) -o $@ $< $(OBJDIROBJ) $(FLAGSLD)
@ln -sf $(CURDIR)/$@ $(EXEDIR)
@$(ECHO) $(StartHeader)"...done"$(EndHeader)
### Rules in order to produce specific libraries from *.o files:
# (This is only necessary in directory /objects)
buildLIBS: buildLIBpdfstub
@rm -f $(LIBDIR)/libPDF.a
ifeq ($(PDF),PDFLIB)
@echo "Using PDFLIB..."
@if [ -f $(LIBDIR)/libPDF8.04.a ]; then \
ln -s $(LIBDIR)/libPDF8.04.a $(LIBDIR)/libPDF.a; \
else \
echo "ERROR: $(LIBDIR)/libPDF8.04.a does not exist."; \
fi
endif
ifeq ($(PDF),LHAPDF)
@echo "Using LHAPDF..."
@if [ -f $(LIBDIR)/libLHAPDF.a ]; then \
ln -s $(LIBDIR)/libLHAPDF.a $(LIBDIR)/libPDF.a; \
else \
echo "ERROR: $(LIBDIR)/libLHAPDF.a does not exist."; \
fi
endif
@if [ ! -f $(LIBDIR)/libPDF.a ]; then \
echo "Using PDFstub..."; \
ln -s $(LIBDIR)/libPDFstub.orig.6225.a $(LIBDIR)/libPDF.a; \
fi
buildLIBpdfstub: libPDFstub.orig.6225.a
@-rm -f $(LIBDIR)/$<
@ln -s $(CURDIR)/$< $(LIBDIR)
lib%.a: %.o
-rm $@
ar r $@ $<
ar s $@
### Rules for specific files:
#Amplitudes.o :
# $(FORT) $(FLAGSDOUBLE) $(FLAGSFORALL) -nowarn -traceback -fpe0 -I$(OBJDIR) -c $<
# with all the checks "Amplitudes" compiles 22 minutes and throws tons of warnings during runtime.
### DEPENDENCIES:
include MakefileDepend