forked from jcmvbkbc/crosstool-NG
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.in
408 lines (331 loc) · 13.5 KB
/
Makefile.in
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# Makefile.in for building crosstool-NG
# This file serves as source for the ./configure operation
# This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS
# to set additional flags in the current Makfile ( see:
# http://savannah.gnu.org/bugs/?20501 ), although the make manual says it
# should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion )
# so we have to work it around by calling ourselves back if needed
# So why do we need not to use the built rules and variables? Because we
# need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in
# and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite
# nor a command associated, and that built-in implicit rule takes precedence
# over our non-built-in implicit rule '%: %.in', below.
# CT_MAKEFLAGS will be used later, below...
# Do not print directories as we descend into them
ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
CT_MAKEFLAGS += --no-print-directory
endif
# Use neither builtin rules, nor builtin variables
# Note: dual test, because if -R and -r are given on the command line
# (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding
# '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' )
# Further: quad test because the flags 'rR' and '-rR' can be reordered.
ifeq ($(filter Rr,$(MAKEFLAGS)),)
ifeq ($(filter -Rr,$(MAKEFLAGS)),)
ifeq ($(filter rR,$(MAKEFLAGS)),)
ifeq ($(filter -rR,$(MAKEFLAGS)),)
CT_MAKEFLAGS += -Rr
endif # No -rR
endif # No rR
endif # No -Rr
endif # No Rr
# Remove any suffix rules
.SUFFIXES:
all: Makefile build
###############################################################################
# Configuration variables
# Stuff found by ./configure
export DATE := @DATE@
export LOCAL := @enable_local@
export PROG_SED := @program_transform_name@
export PACKAGE_TARNAME := @PACKAGE_TARNAME@
export VERSION := @PACKAGE_VERSION@
export prefix := @prefix@
export exec_prefix := @exec_prefix@
export bindir := @bindir@
export libdir := @libdir@@sublibdir@
export docdir := @docdir@@subdocdir@
export mandir := @mandir@
export datarootdir := @datarootdir@
export install := @INSTALL@
export bash := @_BASH@
export awk := @_AWK@
export grep := @GREP@
export make := @MAKE@
export sed := @SED@
export libtool := @LIBTOOL@
export libtoolize := @LIBTOOLIZE@
export objcopy := @OBJCOPY@
export objdump := @OBJDUMP@
export readelf := @READELF@
export patch := @PATCH@
export gperf := @GPERF@
export gperf_len_type := @GPERF_LEN_TYPE@
export CC := @CC@
export CPP := @CPP@
export CPPFLAGS := @CPPFLAGS@
export CFLAGS := @CFLAGS@
export LDFLAGS := @LDFLAGS@
export LIBS := @LIBS@
export INTL_LIBS := @INTL_LIBS@
export curses_hdr := @ac_ct_curses_hdr@
export gettext := @gettext@
# config options to push down to kconfig
KCONFIG:= @kconfig_options@
###############################################################################
# Non-configure variables
MAN_SECTION := 1
MAN_SUBDIR := /man$(MAN_SECTION)
PROG_NAME := $(shell echo 'ct-ng' |$(sed) -r -e '$(PROG_SED)' )
###############################################################################
# Sanity checks
# Check if Makefile is up to date:
Makefile: Makefile.in
@echo "$< did changed: you must re-run './configure'"
@false
# If installing with DESTDIR, check it's an absolute path
ifneq ($(strip $(DESTDIR)),)
ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
$(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
endif
endif
###############################################################################
# Global make rules
# If any extra MAKEFLAGS were added, re-run ourselves
# See top of file for an explanation of why this is needed...
ifneq ($(strip $(CT_MAKEFLAGS)),)
# Somehow, the new auto-completion for make in the recent distributions
# trigger a behavior where our Makefile calls itself recursively, in a
# never-ending loop (except on lack of ressources, swap, PIDs...)
# Avoid this situation by cutting the recursion short at the first
# level.
# This has the side effect of only showing the real targets, and hiding our
# internal ones. :-)
ifneq ($(MAKELEVEL),0)
$(error Recursion detected, bailing out...)
endif
MAKEFLAGS += $(CT_MAKEFLAGS)
build install clean distclean mrproper uninstall:
@$(MAKE) $@
else
# There were no additional MAKEFLAGS to add, do the job
TARGETS := bin lib lib-kconfig doc man
build: $(patsubst %,build-%,$(TARGETS))
install: build real-install
clean: $(patsubst %,clean-%,$(TARGETS))
distclean: clean
@echo " RM 'Makefile'"
@rm -f Makefile
mrproper: distclean
@echo " RM 'autostuff'"
@ rm -rf autom4te.cache config.log config.status configure
uninstall: real-uninstall
###############################################################################
# Specific make rules
#--------------------------------------
# Build rules
build-bin: $(PROG_NAME) \
scripts/crosstool-NG.sh \
scripts/saveSample.sh \
scripts/showTuple.sh
@chmod 755 $^
build-lib: config/configure.in \
paths.mk \
paths.sh
build-lib-kconfig:
@$(MAKE) -C kconfig
build-doc:
build-man: docs/$(PROG_NAME).1.gz
docs/$(PROG_NAME).1.gz: docs/$(PROG_NAME).1
@echo " GZIP '$@'"
@gzip -c9 $< >$@
define sed_it
@echo " SED '$@'"
@$(sed) -r -e 's,@@CT_BINDIR@@,$(bindir),g;' \
-e 's,@@CT_LIBDIR@@,$(libdir),g;' \
-e 's,@@CT_DOCDIR@@,$(docdir),g;' \
-e 's,@@CT_MANDIR@@,$(mandir),g;' \
-e 's,@@CT_PROG_NAME@@,$(PROG_NAME),g;' \
-e 's,@@CT_VERSION@@,$(VERSION),g;' \
-e 's,@@CT_DATE@@,$(DATE),g;' \
-e 's,@@CT_make@@,$(make),g;' \
-e 's,@@CT_bash@@,$(bash),g;' \
-e 's,@@CT_awk@@,$(awk),g;' \
$< >$@
endef
docs/$(PROG_NAME).1: docs/ct-ng.1.in Makefile
$(call sed_it)
$(PROG_NAME): ct-ng.in Makefile
$(call sed_it)
%: %.in Makefile
$(call sed_it)
# We create a script fragment that is parseable from inside a Makefile,
# and one from inside a shell script
paths.mk: FORCE
@echo " GEN '$@'"
@(echo 'export install=$(install)'; \
echo 'export bash=$(bash)'; \
echo 'export awk=$(awk)'; \
echo 'export grep=$(grep)'; \
echo 'export make=$(make)'; \
echo 'export sed=$(sed)'; \
echo 'export libtool=$(libtool)'; \
echo 'export libtoolize=$(libtoolize)'; \
echo 'export objcopy=$(objcopy)'; \
echo 'export objdump=$(objdump)'; \
echo 'export readelf=$(readelf)'; \
echo 'export patch=$(patch)'; \
echo 'export gperf=$(gperf)'; \
) >$@
paths.sh: FORCE
@echo " GEN '$@'"
@(echo 'export install="$(install)"'; \
echo 'export bash="$(bash)"'; \
echo 'export awk="$(awk)"'; \
echo 'export grep="$(grep)"'; \
echo 'export make="$(make)"'; \
echo 'export sed="$(sed)"'; \
echo 'export libtool="$(libtool)"'; \
echo 'export libtoolize="$(libtoolize)"'; \
echo 'export objcopy="$(objcopy)"'; \
echo 'export objdump="$(objdump)"'; \
echo 'export readelf="$(readelf)"'; \
echo 'export patch="$(patch)"'; \
echo 'export gperf="$(gperf)"'; \
) >$@
config/configure.in: FORCE
@echo " GEN '$@'"
@{ printf "# Generated file, do not edit\n"; \
printf "# Default values as found by ./configure\n"; \
for var in $(KCONFIG); do \
printf "\n"; \
printf "config CONFIGURE_$${var%%=*}\n"; \
if [ "$${var#*=}" = "y" ]; then \
printf " def_bool y\n"; \
else \
printf " bool\n"; \
fi; \
done; \
} >$@
FORCE:
#--------------------------------------
# Clean rules
clean-bin:
@echo " RM '$(PROG_NAME)'"
@rm -f $(PROG_NAME)
@echo " RM 'scripts/crosstool-NG.sh'"
@rm -f scripts/crosstool-NG.sh
@echo " RM 'scripts/saveSample.sh'"
@rm -f scripts/saveSample.sh
@echo " RM 'scripts/showTuple.sh'"
@rm -f scripts/showTuple.sh
clean-lib:
@echo " RM 'paths'"
@rm -f paths.mk paths.sh
@echo " RM 'config/configure.in'"
@rm -f config/configure.in
clean-lib-kconfig:
@$(MAKE) -C kconfig clean
clean-doc:
clean-man:
@echo " RM 'docs/$(PROG_NAME).1'"
@rm -f docs/$(PROG_NAME).1
@echo " RM 'docs/$(PROG_NAME).1.gz'"
@rm -f docs/$(PROG_NAME).1.gz
#--------------------------------------
# Check for --local setup
ifeq ($(strip $(LOCAL)),yes)
real-install:
@true
real-uninstall:
@true
else
#--------------------------------------
# Install rules
real-install: $(patsubst %,install-%,$(TARGETS)) install-post
install-bin: $(DESTDIR)$(bindir)
@echo " INST '$(PROG_NAME)'"
@$(install) -m 755 $(PROG_NAME) "$(DESTDIR)$(bindir)/$(PROG_NAME)"
# If one is hacking crosstool-NG, the patch set might change between any two
# installations of the same VERSION, thus the patches must be removed prior
# to being installed. It is the responsibility of the user to call uninstall
# first, if (s)he deems it necessary
install-lib: $(DESTDIR)$(libdir) \
install-lib-main \
install-lib-samples
LIB_SUB_DIR := config contrib patches scripts
$(patsubst %,install-lib-%-copy,$(LIB_SUB_DIR)): $(DESTDIR)$(libdir)
@echo " INSTDIR '$(patsubst install-lib-%-copy,%,$(@))/'"
@tar cf - --exclude='*.sh.in' $(patsubst install-lib-%-copy,%,$(@)) \
|(cd "$(DESTDIR)$(libdir)"; tar xf -)
# Huh? It seems we need at least one command to make this rule kick-in.
install-lib-%: install-lib-%-copy; @true
# Huh? that one does not inherit the -opy dependency, above...
install-lib-scripts: install-lib-scripts-copy
@chmod a+x $(DESTDIR)$(libdir)/scripts/crosstool-NG.sh
@chmod a+x $(DESTDIR)$(libdir)/scripts/saveSample.sh
@rm -f "$(DESTDIR)$(libdir)/scripts/addToolVersion.sh"
install-lib-main: $(DESTDIR)$(libdir) $(patsubst %,install-lib-%,$(LIB_SUB_DIR))
@echo " INST 'steps.mk'"
@$(install) -m 644 steps.mk "$(DESTDIR)$(libdir)/steps.mk"
@echo " INST 'paths'"
@$(install) -m 644 paths.mk paths.sh "$(DESTDIR)$(libdir)"
# Samples need a little love:
# - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
install-lib-samples: $(DESTDIR)$(libdir) install-lib-main
@echo " INSTDIR 'samples/'"
@for samp_dir in samples/*/; do \
mkdir -p "$(DESTDIR)$(libdir)/$${samp_dir}"; \
$(sed) -r -e 's:\$$\{CT_TOP_DIR\}:\$$\{CT_LIB_DIR\}:;' \
-e 's:^(CT_WORK_DIR)=.*:\1="\$${CT_TOP_DIR}/.build":;' \
$${samp_dir}/crosstool.config \
>"$(DESTDIR)$(libdir)/$${samp_dir}/crosstool.config"; \
$(install) -m 644 "$${samp_dir}/reported.by" \
"$(DESTDIR)$(libdir)/$${samp_dir}"; \
for libc_cfg in "$${samp_dir}/"*libc*.config; do \
[ -f "$${libc_cfg}" ] || continue; \
$(install) -m 644 "$${libc_cfg}" \
"$(DESTDIR)$(libdir)/$${samp_dir}"; \
done; \
done
@$(install) -m 644 samples/samples.mk "$(DESTDIR)$(libdir)/samples/samples.mk"
KCONFIG_FILES := conf mconf nconf kconfig.mk
install-lib-kconfig: $(DESTDIR)$(libdir) install-lib-main
@echo " INST 'kconfig/'"
@mkdir -p "$(DESTDIR)$(libdir)/kconfig"
@for f in $(KCONFIG_FILES); do \
install "kconfig/$${f}" "$(DESTDIR)$(libdir)/kconfig/$${f}"; \
done
install-doc: $(DESTDIR)$(docdir)
@echo " INST 'docs/*.txt'"
@for doc_file in docs/*.txt; do \
$(install) -m 644 "$${doc_file}" "$(DESTDIR)$(docdir)"; \
done
install-man: $(DESTDIR)$(mandir)$(MAN_SUBDIR)
@echo " INST '$(PROG_NAME).1.gz'"
@$(install) -m 644 docs/$(PROG_NAME).1.gz "$(DESTDIR)$(mandir)$(MAN_SUBDIR)"
$(sort $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)$(MAN_SUBDIR)):
@echo " MKDIR '$@/'"
@$(install) -m 755 -d "$@"
install-post:
@echo
@echo "For auto-completion, do not forget to install '$(PROG_NAME).comp' into"
@echo "your bash completion directory (usually /etc/bash_completion.d)"
#--------------------------------------
# Uninstall rules
real-uninstall: $(patsubst %,uninstall-%,$(filter-out lib-kconfig,$(TARGETS)))
uninstall-bin:
@echo " RM '$(DESTDIR)$(bindir)/$(PROG_NAME)'"
@rm -f "$(DESTDIR)$(bindir)/$(PROG_NAME)"
uninstall-lib:
@echo " RMDIR '$(DESTDIR)$(libdir)/'"
@rm -rf "$(DESTDIR)$(libdir)"
uninstall-doc:
@echo " RMDIR '$(DESTDIR)$(docdir)/'"
@rm -rf "$(DESTDIR)$(docdir)"
uninstall-man:
@echo " RM '$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1.gz'"
@rm -f "$(DESTDIR)$(mandir)$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
endif # Not --local
endif # No extra MAKEFLAGS were added
.PHONY: build $(patsubst %,build-%,$(TARGETS)) install