-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
412 lines (324 loc) · 12 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
409
410
411
412
#!@MAKE@
# vim: syntax=make
# This file is part of the crosslinux software.
# The license which this software falls under is GPLv2 as follows:
#
# Inspired by Makefile.in from crosstool-NG
# (C) 2013-2013 Douglas Jerome <djerome@crosslinux.org>
# (C) 2013 crosstool-NG authors. See complete list at:
# http://crosstool-ng.org/hg/crosstool-ng/log/tip/Makefile.in
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
# *****************************************************************************
#
# FILE DESCRIPTION
#
# This is the makefile used in making the crosslinux build tool.
#
# Conventions
#
# Although the needed programs are known to exists, because
# ./configure has successfully created this Makefile, use variables
# such as $(install) for most all programs. The reasons for this
# are:
# 1) the path to the program may be unusual and ./configure has
# found the path
# 2) to use the variables as they are set by ./configure, so when a
# variable doesn't work then a needed program is found that is
# not checked by ./configure.
# The exceptions are the basic programs that a Linux system needs to
# work, such as rm, rmdir, ls, cat, etc. For any other programs
# that could be not yet installed, or in an unusual path, use the
# variables.
#
# CHANGE LOG
#
# 2013-06-14 drj File creation.
#
# *****************************************************************************
# *************************************************************************** #
# Make MAKEFLAGS and Configuration #
# *************************************************************************** #
# NOTICE (if this makefile need to re-invoke make on itself):
# GNU make 3.81 does not use MAKEFLAGS to set additional flags for the
# currently running make: http://savannah.gnu.org/bugs/?20501
# The make manual says it should:
# http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion
# Do not print directories as descend into or ascended from.
#
ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
CL_MAKEFLAGS += --no-print-directory
endif
## This is useful if this makefile need to re-invoke make on itself.
## Do not to use the built rules and variables because at least one shell script
## will be generated from a .sh.in file 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 this makefile's non-built-in
## implicit rule '%: %.in' below.
##
## Use neither builtin rules, nor builtin variables. The two tests are because
## if -R and -r are given on the command line, MAKEFLAGS contains 'Rr' instead
## of '-Rr'. Adding '-Rr' to MAKEFLAGS adds it literally, not 'Rr'.
##
#ifeq ($(filter Rr,$(MAKEFLAGS)),)
# ifeq ($(filter -Rr,$(MAKEFLAGS)),)
# CL_MAKEFLAGS += -Rr
# endif
#endif
MAKEFLAGS += $(CL_MAKEFLAGS)
# Remove suffix rules. because at least one shell script will be generated
# from a .sh.in file 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 this makefile's non-built-in implicit rule
# '%: %.in' below.
#
.SUFFIXES:
# *************************************************************************** #
# Configuration Variables from ./configure #
# *************************************************************************** #
export DATE := @DATE@
export LOCAL := @enable_local@
export PACKAGE_TARNAME := @PACKAGE_TARNAME@
export PACKAGE_VERSION := @PACKAGE_VERSION@
export PROG_TXFORM := @program_transform_name@
export awk := @AWK@
export bash := @BASH@
export bzip2 := @BZIP2@
export find := @FIND@
export grep := @EGREP@
export gzip := @GZIP@
export install := @INSTALL@
export ln := @LN@
export make := @MAKE@
export sed := @SED@
export tar := @TAR@
export wget := @WGET@
export xz := @XZ@
export prefix := @prefix@
export exec_prefix := @exec_prefix@
export datarootdir := @datarootdir@
export bindir := @bindir@
export libdir := @libdir@@sublibdir@
export docdir := @docdir@@subdocdir@
export mandir := @mandir@
# *************************************************************************** #
# Make Variables and Default Rule #
# *************************************************************************** #
export SHELL=@BASH@
# GREP_OPTIONS=--color=always breaks the generated .in files, so clear it.
#
export GREP_OPTIONS=
PROG_NAME := $(shell echo 'cl-bt' | $(sed) -r -e '$(PROG_TXFORM)' )
TARGETS := kconfig bin lib host-tools doc man
MAN_SECTION := 1
MAN_SUBDIR := man$(MAN_SECTION)
KCONFIG_FILES := \
pkg-cfg/Kconfig \
pkg-cfg/Kconfig-bootcfg \
pkg-cfg/Kconfig-loaders \
pkg-cfg/Kconfig-pkgcfg \
pkg-cfg/Kconfig-xtcfg \
SCRIPT_FILES := $(shell ls scripts/* | $(sed) -e "s/\.in//")
.PHONY: default
default: Makefile build
# Make sure this makefile is up to date.
#
Makefile: Makefile.in
@echo "$< changed: you must re-run './configure'"
@false
# *************************************************************************** #
# User Make Targets #
# *************************************************************************** #
.PHONY: build clean distclean mrproper install uninstall
build: $(patsubst %,build-%,$(TARGETS))
clean: $(patsubst %,clean-%,$(TARGETS))
distclean: clean
@if [[ -f kconfig/Makefile ]]; then \
$(MAKE) -C kconfig distclean; \
fi
@if [[ -f host-tools/Makefile ]]; then \
$(MAKE) -C host-tools distclean;\
fi
@echo "RM Makefile"
@rm -f Makefile
@echo ""
@echo "=> You must run ./configure before building."
@echo ""
mrproper: clean
@if [[ -f kconfig/Makefile ]]; then \
$(MAKE) -C kconfig distclean; \
fi
@if [[ -f host-tools/Makefile ]]; then \
$(MAKE) -C host-tools distclean;\
fi
@echo "RM Makefile"
@rm -f Makefile
@echo "RM autostuff"
@rm -rf autom4te.cache config.log config.status configure Makefile
@echo ""
@echo "=> You must run ./bootstrap and ./configure before building."
@echo ""
install: build real-install
uninstall: real-uninstall
# *************************************************************************** #
# Internal build Targets #
# *************************************************************************** #
.PHONY: $(patsubst %,build-%,$(TARGETS))
build-kconfig:
@echo "=> Making kconfg."
@$(MAKE) -C kconfig
@echo "=> Done making kconfg."
build-bin: $(PROG_NAME) setenv.sh
@chmod 755 $^
build-lib: $(KCONFIG_FILES) $(SCRIPT_FILES)
@chmod 755 $(SCRIPT_FILES)
build-host-tools:
@$(MAKE) -C host-tools build
build-doc:
build-man: doc/$(PROG_NAME).1.gz
doc/$(PROG_NAME).1.gz: doc/$(PROG_NAME).1
@echo "GZIP $@"
@$(gzip) -c9 $< >$@
define sed_it
@echo "SED $< --> $@"
@$(sed) -r \
-e 's,@@CL_DATE@@,$(DATE),g;' \
-e 's,@@CL_LOCAL@@,$(LOCAL),g;' \
-e 's,@@CL_PROG_NAME@@,$(PROG_NAME),g;' \
-e 's,@@CL_VERSION@@,$(PACKAGE_VERSION),g;' \
-e 's,@@CL_AWK@@,$(awk),g;' \
-e 's,@@CL_BASH@@,$(bash),g;' \
-e 's,@@CL_BZIP2@@,$(bzip2),g;' \
-e 's,@@CL_FIND@@,$(find),g;' \
-e 's,@@CL_GREP@@,$(grep),g;' \
-e 's,@@CL_GZIP@@,$(gzip),g;' \
-e 's,@@CL_INSTALL@@,$(install),g;' \
-e 's,@@CL_LN@@,$(ln),g;' \
-e 's,@@CL_MAKE@@,$(make),g;' \
-e 's,@@CL_SED@@,$(sed),g;' \
-e 's,@@CL_TAR@@,$(tar),g;' \
-e 's,@@CL_WGET@@,$(wget),g;' \
-e 's,@@CL_XZ@@,$(xz),g;' \
-e 's,@@CL_BINDIR@@,$(bindir),g;' \
-e 's,@@CL_LIBDIR@@,$(libdir),g;' \
-e 's,@@CL_DOCDIR@@,$(docdir),g;' \
-e 's,@@CL_MANDIR@@,$(mandir),g;' \
$< >$@
endef
%: %.in Makefile
$(call sed_it)
$(PROG_NAME): cl-bt.in Makefile
$(call sed_it)
doc/$(PROG_NAME).1: doc/cl-bt.1.in Makefile
$(call sed_it)
# *************************************************************************** #
# Internal clean Targets #
# *************************************************************************** #
.PHONY: $(patsubst %,clean-%,$(TARGETS))
clean-kconfig:
@echo "=> Make clean kconfg."
@$(MAKE) -C kconfig clean
@echo "=> Done cleaning kconfg."
clean-bin:
@echo "RM $(PROG_NAME) setenv.sh"
@rm -f $(PROG_NAME) setenv.sh
clean-lib:
@echo "RM $(KCONFIG_FILES)"
@rm -f $(KCONFIG_FILES)
@echo "RM scripts/*.sh"
@rm -f scripts/*.sh
clean-host-tools:
@$(MAKE) -C host-tools clean
clean-doc:
clean-man:
@echo "RM doc/$(PROG_NAME).1 doc/$(PROG_NAME).1.gz"
@rm -f doc/$(PROG_NAME).1 doc/$(PROG_NAME).1.gz
# *************************************************************************** #
# Internal install Targets #
# *************************************************************************** #
.PHONY: real-install $(patsubst %,install-%,$(TARGETS))
ifeq ($(strip $(LOCAL)),yes)
real-install:
@echo "INST kconfig"
@mkdir -p "$(libdir)/kconfig-exec"
@$(MAKE) -C kconfig install-exec
@$(MAKE) -C host-tools install
else
real-install: $(patsubst %,install-%,$(TARGETS))
install-kconfig: $(libdir)
@echo "INST kconfig"
@mkdir -p "$(libdir)/kconfig-exec"
@$(MAKE) -C kconfig install-exec
install-bin: $(bindir)
@echo "INST $(PROG_NAME)"
@$(install) -m 755 $(PROG_NAME) "$(bindir)/$(PROG_NAME)"
@echo "INST setenv.sh"
@$(install) -m 755 setenv.sh "$(bindir)/setenv.sh"
LIB_SUB_DIR := boards pkg-cfg scripts
install-lib: $(libdir)
@for dir in $(LIB_SUB_DIR); do \
echo "INST $${dir}/"; \
$(tar) cf - --exclude='*.in' $${dir}/ \
| (cd "$(libdir)"; $(tar) xf -); \
done
install-host-tools: $(libdir)
@$(MAKE) -C host-tools install
install-doc: $(docdir)
@echo "INST doc/*.txt"
@for doc_file in doc/*.txt; do \
if [[ -f $${doc_file} ]]; then \
$(install) -m 644 "$${doc_file}" "$(docdir)"; \
fi \
done
install-man: $(mandir)
@echo "INST $(PROG_NAME).1.gz"
@mkdir -p "$(mandir)/$(MAN_SUBDIR)"
@$(install) -m 644 doc/$(PROG_NAME).1.gz "$(mandir)/$(MAN_SUBDIR)"
$(sort $(bindir) $(libdir) $(docdir) $(mandir)):
@echo "MKDIR $@/"
@$(install) -m 755 -d "$@"
endif
# *************************************************************************** #
# Internal uninstall Targets #
# *************************************************************************** #
.PHONY: real-uninstall $(patsubst %,uninstall-%,$(TARGETS))
ifeq ($(strip $(LOCAL)),yes)
real-uninstall:
@true
@echo "RM kconfig installation"
@rm -rf kconfig-exec
@$(MAKE) -C host-tools uninstall
else
real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
uninstall-kconfig:
@true
uninstall-bin:
@echo "RM $(bindir)/$(PROG_NAME)"
@rm -f "$(bindir)/$(PROG_NAME)"
@echo "RM $(bindir)/setenv.sh"
@rm -f "$(bindir)/setenv.sh"
uninstall-lib:
@echo "RMDIR $(libdir)/"
@rm -rf "$(libdir)"
uninstall-host-tools:
@$(MAKE) -C host-tools uninstall
uninstall-doc:
@echo "RMDIR $(docdir)/"
@rm -rf "$(docdir)"
uninstall-man:
@echo "RM $(mandir)/$(MAN_SUBDIR)/$(PROG_NAME).1.gz"
@rm -f "$(mandir)/$(MAN_SUBDIR)/$(PROG_NAME).1"{,.gz}
endif
# end of Makefile