forked from MG-RAST/M5nr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
276 lines (208 loc) · 8.35 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
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
########################################################################
# Top level makefile for ReleaseTools. Will be copied into work
# directory as Makefile. Our job here is to define basic environment
# and then iterate over the checked outpackages in the work directory,
# invoking make methods there. This is one level! Not recursive.
#
# Ed Frank, Argonne National Laboratory
# Based upon work of Bob Jacobsen, Lawrence Berkeley National Lab
########################################################################
########################################################################
# The basic environment, macros etc. Our only external environment
# variables are:
# RTDIST
# RTARCH
# RTCURRENT
########################################################################
SHELL = /bin/sh
# these two used to be "if ndef". why?
export PWD := $(shell pwd)
export TOPDIR := $(shell /bin/pwd)
# expect includes of the form #include "PackageName/item.h"
CPPFLAGS += -I$(PWD)
LDFLAGS += -L$(PWD)/$(RTARCH)/lib
MAKEINCLUDE := -I$(PWD)/ReleaseTools
# this isn't right...should look at rtDist to figure out
# where THIS workdir came from
ifdef RTCURRENT
CPPFLAGS += -I$(RTDIST)/releases/$(RTCURRENT)/$(RTARCH)/include
LDFLAGS += -L$(RTDIST)/releases/$(RTCURRENT)/$(RTARCH)/lib
MAKEINCLUDE += -I$(RTDIST)/releases/$(RTCURRENT)/ReleaseTools
endif
libdir = $(PWD)/$(RTARCH)/lib
bindir = $(PWD)/$(RTARCH)/bin
cgidir = $(PWD)/$(RTARCH)/CGI
workdir =$(PWD)/$(RTARCH)/tmp
tutdir = $(PWD)/$(RTARCH)/Tutorial
TOOL_HDR := $(TOPDIR)/$(RTARCH)/tool_hdr
TOOL_HDR_PY := $(TOPDIR)/$(RTARCH)/tool_hdr_py
PACKAGES := $(subst /,, $(dir $(wildcard */Makefile)))
#
# OVERRIDES is a macro passed into children-makes to guide them.
#
OVERRIDES = \
$(MAKEINCLUDE) \
TOPDIR=$(TOPDIR) \
TOOL_HDR=$(PWD)/$(RTARCH)/tool_hdr \
TOOL_HDR_PY=$(PWD)/$(RTARCH)/tool_hdr_py \
libdir=$(libdir) \
bindir=$(bindir) \
cgidir=$(cgidir) \
PKGNAME=$(basename $@) \
CPPFLAGS="$(CPPFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
workdir=$(workdir)/$(basename $@) \
tutdir=$(tutdir)
########################################################################
#
# Targets- these are actually done by the packages, except for
# a few setup-like things, eg., installdirs.
#
# Note that the behavior of package makefiles is centralized
# into ReleaseTools/standard.mk. The package makefiles only
# define a few macros to define their needs, whenever possible.
#
########################################################################
.PHONY: lib bin schematools stDeclFiles stGeneratedFiles clean test purge check_env
# if you change all: make sure all: in standard.mk is consistent.
all: Makefile installdirs decouple schematools lib bin
schematools: stDeclFiles stGeneratedFiles
# The rule is that all the lib targets from the various packages can
# be built in any order. After that, all teh bins can go, again in
# any order. But there are a *very few* things that need to be built
# first and perhaps in order. The decouple: target handles those.
# The $(wildcard foo) trick returns an empty list of foo is not
# present, e.g., the package is not checked out. This lets the
# decouple target be declared without forcing people to check out
# those packages, i.e., they can just run off the versions in the
# base release. Thus, decouple is for from-scratch release builds
# and for development of these few, special core packages.
decouple: $(wildcard ReleaseTools) $(wildcard KahDataServices) $(TOOL_HDR) $(TOOL_HDR_PY)
# Use the PACKAGES macro to transform lib, bin, etc., targets
# into package level dependencies, e.g., lib -> PkgA.lib, PkgB.lib
# Rules below then cause PkgA.lib to do a make in PkgaA on lib:
ALL.LIB = check_env $(foreach var,$(PACKAGES),$(var).lib)
lib: Makefile $(ALL.LIB)
ALL.BIN = check_env $(foreach var,$(PACKAGES),$(var).bin)
bin: Makefile $(ALL.BIN)
ALL.STDECLFILES = check_env $(foreach var,$(PACKAGES),$(var).stDeclFiles)
stDeclFiles: Makefile $(ALL.STDECLFILES)
ALL.STGENERATEDFILES = check_env $(foreach var,$(PACKAGES),$(var).stGeneratedFiles)
stGeneratedFiles: Makefile $(ALL.STGENERATEDFILES)
ALL.TEST = check_env $(foreach var,$(PACKAGES),$(var).test)
test: Makefile $(ALL.TEST)
ALL.CLEAN = check_env $(foreach var,$(PACKAGES),$(var).clean)
#clean: $(ALL.CLEAN)
clean: Makefile check_env purge installdirs
purge: check_env
rm -rf $(RTARCH)/bin $(RTARCH)/lib $(RTARCH)/tmp $(RTARCH)/CGI
# Make sure the top-level makefile is up to date
# the wildcard below only returns something if ReleaseTools is checked out.
# Otherwise, if ReleaseTools was not checked out, make would complain and
# quit about "no such file"
Makefile: $(wildcard ReleaseTools/Makefile.top)
echo $(wildcard ReleaseTools/Makefile.top)
cp ReleaseTools/Makefile.top Makefile
@echo ""
@echo "A new makefile was installed; please rerun your make command."
@echo ""
@exit 1
check_env:
ifndef RTARCH
@echo ""
@echo "FIG build environment is not properly configured."
@echo "Did you source fig-user-env ?"
@echo ""
@exit 1
endif
##
# Targets to setup the expected directory structure for the
# work directory. The work directory should be created
# with the mkworkdir command.
###
# If make installdirs is called when no packages are checked out,
# then lib and tmp are not made. So we add two rules here
# to handle that case.
installdirs: check_env $(libdir) $(bindir) $(cgidir) $(cgidir)/Html $(cgidir)/Html/css $(workdir) $(tutdir)
- mkdir -p $(tutdir) $(tutdir)/python $(tutdir)/perl
- mkdir -p $(libdir)
- mkdir -p $(workdir)
- mkdir -p $(bindir)
- mkdir -p $(cgidir)
- mkdir -p $(cgidir)/p2p
# the subdirs are for putting python pyc etc. into
$(libdir): $(foreach var,$(PACKAGES),$(libdir)/$(var).installdirs)
$(libdir)/%.installdirs:
- mkdir -p $(@:.installdirs=)
- mkdir -p $(@:.installdirs=)Gen
- touch $(@:.installdirs=)Gen/__init__.py
$(bindir):
- mkdir -p $(bindir)
$(cgidir):
- mkdir $(cgidir)
- mkdir $(cgidir)/p2p
$(tutdir):
- mkdir $(tutdir)
- mkdir $(tutdir)/python
- mkdir $(tutdir)/perl
$(cgidir)/Html:
mkdir -p $(cgidir)/Html
$(cgidir)/Html/css:
mkdir -p $(cgidir)/Html/css
$(workdir): $(foreach var,$(PACKAGES),$(workdir)/$(var).installdirs)
$(workdir)/%.installdirs:
- mkdir -p $(@:.installdirs=)
########################################################################
# Rules
#
# These rules convert PACKAGENAME.rule into make operations
# in PACKAGENAME. Real rules live in standard.mk
########################################################################
%.all:
@$(MAKE) -C $(@:.lib=) $(OVERRIDES) all
%.lib:
@$(MAKE) -C $(@:.lib=) $(OVERRIDES) lib
%.bin:
@$(MAKE) -C $(@:.bin=) $(OVERRIDES) bin
%.schematools:
@$(MAKE) -C $(@:.schematools=) $(OVERRIDES) schematools
%.stDeclFiles:
@$(MAKE) -C $(@:.stDeclFiles=) $(OVERRIDES) stDeclFiles
%.stGeneratedFiles:
@$(MAKE) -C $(@:.stGeneratedFiles=) $(OVERRIDES) stGeneratedFiles
%.test:
@$(MAKE) -C $(@:.test=) $(OVERRIDES) test
%.clean:
@$(MAKE) -C $(@:.clean=) $(OVERRIDES) clean
# implementation of the decouple: steps that just build whole packages
# the .PHONY here lets us defer to the lib and bin in the package
.PHONY: KahDataServices
KahDataServices:
# this one we do by hand and a little out of order...
# we must get bin done here to have the programs that
# implement schematools target.
@$(MAKE) -C $(@:.clean=) $(OVERRIDES) lib
@$(MAKE) -C $(@:.clean=) $(OVERRIDES) bin
@$(MAKE) -C $(@:.clean=) $(OVERRIDES) schematools
.PHONY: ReleaseTools
ReleaseTools:
@$(MAKE) -C $(@:.clean=) $(OVERRIDES) all
##
# generation of the tool_header files. part of decouple
# these live in $(TOPDIR)/$(RTARCH) but should live
# in $(libdir).
#
# We use the wildcard trick again so that we have the dependency
# only if ReleaseTools is checked out. If not checked out, we
# are by definition satisfied with makeScriptHeaders in the base
# release. Note we must make the dependency be on the source file,
# not the $(bindir) file because if the latter does not exist, the
# wildcard fails and there's no dependency! But if the ReleaseTools/make*
# exists and is newer, then we just defer to the ReleaseTools target
# used above for decouple:
##
$(TOPDIR)/$(RTARCH)/tool_hdr: $(wildcard ReleaseTools/makeScriptHeaders)
cd $(TOPDIR); $(bindir)/makeScriptHeaders $(TOPDIR)
$(TOPDIR)/$(RTARCH)/tool_hdr_py: $(wildcard ReleaseTools/makeScriptHeaders)
cd $(TOPDIR); $(bindir)/makeScriptHeaders $(TOPDIR)
ReleaseTools/makeScriptHeaders: ReleaseTools