-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.new
168 lines (147 loc) · 5.02 KB
/
Makefile.new
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
# Makefile for Reduce
###########################################################################
###########################################################################
## This version starts off as EXPERIMENTAL. If (and when!) it works it ##
## will arrange for parallel builds of hosts that have multi-core CPUS. ##
##
###########################################################################
###########################################################################
# There are two things that this Makefile is trying to do.
#
# Firstly there are multiple variant build directories (within cslbuild
# and pslbuild). When I go "make target" I generally want that target
# re-built in each relevant directory.
# However there need to be some targets which only get run in one of
# the variants.
#
# Secondly I want the builds all to run in parallel, even across the
# multiple directories. By default if you invoke "make" it will use as
# much parallelism as you have available "cpus". If you explicitly indicate
# a level of parallelism by invoking as say "make -j 3" then it should hold
# to the setting you specified, so "make -j 1" reverts to sequential builds
# everywhere.
#
# A messy issue is that of the phrase "relevent directory" above. Here I am
# supporting both a CSL and a PSL Lisp and for instance "bootstrapreduce.exe"
# and "c-code" are only relevant in the CSL world, while "all" applies
# everywhere.
csltargets := \
csl.exe csl.com csl.img \
bootstrapreduce bootstrapreduce.exe \
bootstrapreduce.com bootstrapreduce.img \
reduce reduce.exe reduce.com reduce.img \
flatcsl flatcsl.exe flatcsl.com flatcsl.img \
fwindemo fwindemo.exe fwindemo.com \
foxdemo foxdemo.exe foxdemo.com \
termdemo termdemo.exe termdemo.com \
fontdemo fontdemo.exe fontdemo.com \
showmathdemo showmathdemo.exe showmathdemo.com \
wxdemo wxdemo.exe wxdemo.com \
wxfontdemo wxfontdemo.exe wxfontdemo.com \
wxfontdemo1 wxfontdemo1.exe wxfontdemo1.com \
wxdvi wxdvi.exe wxdvi.com \
wxshowmath wxshowmath.exe wxshowmath.com \
wxshowmathdemo wxshowmathdemo.exe wxshowmathdemo.com \
wxpsl wxpsl.exe wxpsl.com \
bootstraprecompile recompile \
testslow testall testslow1 test1 count1 \
checkall cleanlog showhost
# Some of the CSL targets want to be run in just ONE of the build
# directories.
csltargets1 := \
profile profile-install c-code just-c-code \
standard-c-code partial-c-code full-c-code \
j-code smacros countall
csldirs := $(wildcard cslbuild/*-*-*/csl)
csldirs1 := $(firstword $(csldirs))
# The list of psltargets is extracted from psl/Makefile.am, and if new
# targets are introduced there then this list will need updating
psltargets := \
force red/bootstrap.img \
red/mma.awk red.qepcad.awk tryboot \
deps/core-packages.psl-make deps/core-packages.psl-depend \
deps/noncore-packages.psl-make deps/noncore-packages.psl-depend \
red/reduce.img install-exex-local uninstall-local
psldirs := $(wildcard pslbuild/*-*-*)
bothtargets = __all install uninstall
bothdirs := $(csldirs) $(psldirs)
# Find the number of available cpus and insert "-j N" if you are a top-level
# invocation of "make". If the user specified "-j N" or "--jobs=N" then
# their setting takes precedence and specifically "-j1" can be used to
# force a sequential build.
ifeq "0" "$(MAKELEVEL)"
MAKEFLAGS := -j$(shell nproc || sysctl -n hw.ncpu || printf "1") $(MAKEFLAGS)
endif
.PHONY: all $(bothtargets) clean $(csltargets) $(csltargets1) $(psltargets)
all $(bothtargets):
@c="$(bothdirs)" && t=$@ && ( printf "# Faked up Makefile\n" && \
i=1 && \
printf ".PHONY:\t" && \
for d in $$c; \
do printf " __$$i"; \
i=$$(($$i+1)); \
done && \
printf "\n\n" && \
i=1 && \
printf "all:\t" && \
for d in $$c; \
do printf " __$$i"; \
i=$$(($$i+1)); \
done && \
printf "\n\n" && \
i=1 && \
for d in $$c; \
do printf "__$$i:\n\t$(MAKE) -C $$d $$t\n\n"; \
i=$$(($$i+1)); \
done ) | $(MAKE) -f -
clean:
for d in `find cslbuild -name Makefile` `find pslbuild -name Makefile`; \
do $(MAKE) -C `dirname $$d` clean; \
$(MAKE) -C `dirname $d` uninstall; \
done
rm -rf cslbuild/generated-c/*.img cslbuild/generated-c/u*
$(csltargets):
@c="$(csldirs)" && t=$@ && ( printf "# Faked up Makefile\n" && \
i=1 && \
printf ".PHONY:\t" && \
for d in $$c; \
do printf " __$$i"; \
i=$$(($$i+1)); \
done && \
printf "\n\n" && \
i=1 && \
printf "all:\t" && \
for d in $$c; \
do printf " __$$i"; \
i=$$(($$i+1)); \
done && \
printf "\n\n" && \
i=1 && \
for d in $$c; \
do printf "__$$i:\n\t$(MAKE) -C $$d $$t\n\n"; \
i=$$(($$i+1)); \
done ) | $(MAKE) -f -
$(csltargets1):
$(MAKE) -C $(csldirs1) $@; \
$(psltargets):
@c="$(psldirs)" && t=$@ && ( printf "# Faked up Makefile\n" && \
i=1 && \
printf ".PHONY:\t" && \
for d in $$c; \
do printf " __$$i"; \
i=$$(($$i+1)); \
done && \
printf "\n\n" && \
i=1 && \
printf "all:\t" && \
for d in $$c; \
do printf " __$$i"; \
i=$$(($$i+1)); \
done && \
printf "\n\n" && \
i=1 && \
for d in $$c; \
do printf "__$$i:\n\t$(MAKE) -C $$d $$t\n\n"; \
i=$$(($$i+1)); \
done ) | $(MAKE) -f -
# end of Makefile