1 | # $Id: bootstrap.gmk 3143 2018-03-14 23:00:29Z bird $
|
---|
2 | ## @file
|
---|
3 | # GNU Make Compatible bootstrap Makefile.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (c) 2007-2010 knut st. osmundsen <[email protected]>
|
---|
8 | #
|
---|
9 | # This file is part of kBuild.
|
---|
10 | #
|
---|
11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
12 | # it under the terms of the GNU General Public License as published by
|
---|
13 | # the Free Software Foundation; either version 3 of the License, or
|
---|
14 | # (at your option) any later version.
|
---|
15 | #
|
---|
16 | # kBuild is distributed in the hope that it will be useful,
|
---|
17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | # GNU General Public License for more details.
|
---|
20 | #
|
---|
21 | # You should have received a copy of the GNU General Public License
|
---|
22 | # along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
---|
23 | #
|
---|
24 | #
|
---|
25 |
|
---|
26 | #
|
---|
27 | # ASSUMES:
|
---|
28 | # - KBUILD_TARGET, KBUILD_HOST, KBUILD_HOST_ARCH, and KBUILD_TYPE in the env.
|
---|
29 | # - KBUILD_PATH points to ./kBuild with an absolute path.
|
---|
30 | # - KBUILD_BIN_PATH and PATH_KBUILD_BIN must *NOT* be defined anywhere.
|
---|
31 | # - Current directory == bootstrap.gmk directory.
|
---|
32 | # - mkdir -p works.
|
---|
33 | # - ln -s works
|
---|
34 | # - cp -f works
|
---|
35 | # - cd somedir && command works.
|
---|
36 | # - echo done > some-file works.
|
---|
37 | # - Recent GNU make that implements CURDIR, $(error) and ifdef.
|
---|
38 | #
|
---|
39 | # Tip: kBuild/env.sh --full (g(nu))make -f bootstrap.gmk
|
---|
40 | #
|
---|
41 | # Note to self on bootstrapping solaris.sparc64:
|
---|
42 | # SED_MAKE_DEFS="SED=gsed" AUTOPOINT=true ACLOCAL=aclocal-1.10 AUTOMAKE=automake-1.10 nice ./kBuild/env.sh --full gmake -f bootstrap.gmk
|
---|
43 | #
|
---|
44 | # Note to self on bootstrapping openbsd:
|
---|
45 | # AUTOCONF_VERSION=2.59 AUTOMAKE_VERSION=1.9 ./kBuild/env.sh --full gmake -f bootstrap.gmk
|
---|
46 | #
|
---|
47 |
|
---|
48 | #
|
---|
49 | # OPTIONAL:
|
---|
50 | # Set env.var. NIX_INSTALL_DIR to /usr/local or /usr
|
---|
51 | # (see Config.kmk and wiki for details)
|
---|
52 | #
|
---|
53 |
|
---|
54 | #
|
---|
55 | # Deal with legacy env.vars. - no niceties here.
|
---|
56 | #
|
---|
57 | ifndef KBUILD_HOST
|
---|
58 | KBUILD_HOST := $(BUILD_PLATFORM)
|
---|
59 | endif
|
---|
60 | ifndef KBUILD_HOST_ARCH
|
---|
61 | KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
|
---|
62 | endif
|
---|
63 | ifndef KBUILD_HOST_CPU
|
---|
64 | KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
|
---|
65 | endif
|
---|
66 |
|
---|
67 | ifndef KBUILD_TARGET
|
---|
68 | KBUILD_TARGET := $(BUILD_TARGET)
|
---|
69 | endif
|
---|
70 | ifndef KBUILD_TARGET_ARCH
|
---|
71 | KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
|
---|
72 | endif
|
---|
73 | ifndef KBUILD_TARGET_CPU
|
---|
74 | KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
|
---|
75 | endif
|
---|
76 |
|
---|
77 | ifndef KBUILD_TYPE
|
---|
78 | KBUILD_TYPE := $(BUILD_TYPE)
|
---|
79 | endif
|
---|
80 |
|
---|
81 | ifndef KBUILD_PATH
|
---|
82 | KBUILD_PATH := $(PATH_KBUILD)
|
---|
83 | endif
|
---|
84 |
|
---|
85 | #
|
---|
86 | # Check (some of) the assumptions.
|
---|
87 | #
|
---|
88 | ifndef KBUILD_TARGET
|
---|
89 | $(error KBUILD_TARGET not set)
|
---|
90 | endif
|
---|
91 |
|
---|
92 | ifndef KBUILD_HOST
|
---|
93 | $(error KBUILD_HOST not set)
|
---|
94 | endif
|
---|
95 |
|
---|
96 | ifndef KBUILD_HOST_ARCH
|
---|
97 | $(error KBUILD_HOST_ARCH not set)
|
---|
98 | endif
|
---|
99 |
|
---|
100 | ifndef KBUILD_TYPE
|
---|
101 | $(error KBUILD_TYPE not set)
|
---|
102 | endif
|
---|
103 |
|
---|
104 | ifndef KBUILD_TYPE
|
---|
105 | $(error KBUILD_TYPE not set)
|
---|
106 | endif
|
---|
107 |
|
---|
108 | ifndef KBUILD_PATH
|
---|
109 | $(error KBUILD_PATH not set)
|
---|
110 | endif
|
---|
111 |
|
---|
112 | ifdef KBUILD_BIN_PATH
|
---|
113 | $(error KBUILD_BIN_PATH is set)
|
---|
114 | endif
|
---|
115 | ifdef PATH_KBUILD_BIN
|
---|
116 | $(error PATH_KBUILD_BIN is set)
|
---|
117 | endif
|
---|
118 |
|
---|
119 |
|
---|
120 | #
|
---|
121 | # Globals
|
---|
122 | #
|
---|
123 | SRCDIR = $(CURDIR)
|
---|
124 | OUTDIR = $(SRCDIR)/out/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)/$(KBUILD_TYPE)/bootstrap
|
---|
125 | SVN = svn
|
---|
126 |
|
---|
127 | # Override this on the make commandline if you need to (FreeBSD).
|
---|
128 | AUTORECONF = autoreconf
|
---|
129 |
|
---|
130 | all: stage1 stage2
|
---|
131 |
|
---|
132 |
|
---|
133 | #
|
---|
134 | # Stage 1 - Build bootstrap kmk, kmk_redirect and sed, refresh config.h caches, link
|
---|
135 | # up kmk_ash so $(OUTDIR)/kmk can serve as kBuild bin dir.
|
---|
136 | #
|
---|
137 | stage1: \
|
---|
138 | $(OUTDIR)/kmk/kmk \
|
---|
139 | $(OUTDIR)/kmk/kmk_ash \
|
---|
140 | $(OUTDIR)/kmk/kmk_sed \
|
---|
141 | $(OUTDIR)/kmk/kmk_echo \
|
---|
142 | $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
|
---|
143 | $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET)
|
---|
144 |
|
---|
145 | # kmk
|
---|
146 | $(OUTDIR)/kmk/ts-autoreconf:
|
---|
147 | mkdir -p $(@D)
|
---|
148 | cd $(SRCDIR)/src/kmk && $(AUTORECONF) -i -v
|
---|
149 | echo done > $@
|
---|
150 |
|
---|
151 | $(OUTDIR)/kmk/ts-configured: \
|
---|
152 | $(OUTDIR)/kmk/ts-autoreconf \
|
---|
153 | $(OUTDIR)/kmk/fts.h
|
---|
154 | cd $(OUTDIR)/kmk && $(SRCDIR)/src/kmk/configure --disable-load --without-guile
|
---|
155 | echo done > $@
|
---|
156 |
|
---|
157 | ifeq ($(KBUILD_HOST),solaris)
|
---|
158 | $(OUTDIR)/kmk/ts-configured: $(OUTDIR)/kmk/paths.h
|
---|
159 |
|
---|
160 | $(OUTDIR)/kmk/paths.h:
|
---|
161 | echo > $@
|
---|
162 | endif
|
---|
163 |
|
---|
164 | $(OUTDIR)/kmk/fts.h:
|
---|
165 | ln -s $(SRCDIR)/src/kmk/kmkbuiltin/ftsfake.h $@
|
---|
166 |
|
---|
167 | $(OUTDIR)/kmk/config.h: $(OUTDIR)/kmk/ts-configured
|
---|
168 |
|
---|
169 |
|
---|
170 | $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET): $(OUTDIR)/kmk/config.h
|
---|
171 | cp -f $(OUTDIR)/kmk/config.h $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET)
|
---|
172 | echo "" >> $@
|
---|
173 | echo '#include "inlined_memchr.h"' >> $@
|
---|
174 |
|
---|
175 | $(OUTDIR)/kmk/kmk: $(OUTDIR)/kmk/ts-configured
|
---|
176 | $(MAKE) -C $(@D)
|
---|
177 |
|
---|
178 | # sed
|
---|
179 | $(OUTDIR)/sed/ts-autoreconf:
|
---|
180 | mkdir -p $(@D)
|
---|
181 | @cd $(SRCDIR)/src/sed && $(AUTORECONF) -i -v --force
|
---|
182 | echo done > $@
|
---|
183 |
|
---|
184 | $(OUTDIR)/sed/ts-configured: $(OUTDIR)/sed/ts-autoreconf
|
---|
185 | cd $(OUTDIR)/sed && $(SRCDIR)/src/sed/configure --without-libintl --disable-nls
|
---|
186 | echo done > $@
|
---|
187 |
|
---|
188 | $(OUTDIR)/sed/config.h: $(OUTDIR)/sed/ts-configured
|
---|
189 |
|
---|
190 | $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET): $(OUTDIR)/sed/config.h
|
---|
191 | cp -f $< $@
|
---|
192 |
|
---|
193 | $(OUTDIR)/sed/sed/sed: $(OUTDIR)/sed/ts-configured
|
---|
194 | $(MAKE) $(SED_MAKE_DEFS) -C $(@D)/..
|
---|
195 |
|
---|
196 | $(OUTDIR)/kmk/kmk_sed: $(OUTDIR)/sed/sed/sed
|
---|
197 | cp -f $< $@
|
---|
198 |
|
---|
199 | $(OUTDIR)/kmk/kmk_ash:
|
---|
200 | ifeq ($(KBUILD_TARGET),solaris)
|
---|
201 | ln -s /usr/bin/bash $@
|
---|
202 | else
|
---|
203 | ln -s /bin/sh $@
|
---|
204 | endif
|
---|
205 |
|
---|
206 | $(OUTDIR)/kmk/kmk_echo:
|
---|
207 | ln -s /bin/echo $@
|
---|
208 |
|
---|
209 | #
|
---|
210 | # Stage 2 - Build kBuild using the bootstrap tools from the previous step
|
---|
211 | # and install it to kBuild/bin/x.y.
|
---|
212 | #
|
---|
213 | stage2: \
|
---|
214 | $(OUTDIR)/ts-stage2-build \
|
---|
215 | $(OUTDIR)/ts-stage2-install
|
---|
216 |
|
---|
217 | $(OUTDIR)/ts-stage2-build: \
|
---|
218 | $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
|
---|
219 | $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET) \
|
---|
220 | $(OUTDIR)/kmk/kmk
|
---|
221 | KBUILD_BIN_PATH=$(OUTDIR)/kmk $(OUTDIR)/kmk/kmk -C $(SRCDIR) KBUILD_BOOTSTRAP=1
|
---|
222 | echo done > $@
|
---|
223 |
|
---|
224 | $(OUTDIR)/ts-stage2-install: $(OUTDIR)/ts-stage2-build
|
---|
225 | KBUILD_BIN_PATH=$(OUTDIR)/kmk $(OUTDIR)/kmk/kmk -C $(SRCDIR) KBUILD_BOOTSTRAP=1 PATH_INS=$(SRCDIR) install
|
---|
226 | echo done > $@
|
---|
227 |
|
---|
228 |
|
---|
229 | #
|
---|
230 | # Clean the output files... Very enjoyable exercise.
|
---|
231 | #
|
---|
232 | clean:
|
---|
233 | rm -Rf $(SRCDIR)/out/ \
|
---|
234 | $(SRCDIR)/src/kmk/autom4te.cache/ \
|
---|
235 | $(SRCDIR)/src/sed/autom4te.cache/
|
---|
236 | rm -f $(SRCDIR)/src/kmk/Makefile.in \
|
---|
237 | $(SRCDIR)/src/kmk/config.h.in \
|
---|
238 | $(SRCDIR)/src/kmk/configure \
|
---|
239 | $(SRCDIR)/src/kmk/aclocal.m4 \
|
---|
240 | $(SRCDIR)/src/kmk/glob/Makefile.in \
|
---|
241 | $(SRCDIR)/src/kmk/config/Makefile.in \
|
---|
242 | $(SRCDIR)/src/kmk/config/depcomp \
|
---|
243 | $(SRCDIR)/src/kmk/config/compile \
|
---|
244 | $(SRCDIR)/src/kmk/config/missing \
|
---|
245 | $(SRCDIR)/src/kmk/config/config.guess \
|
---|
246 | $(SRCDIR)/src/kmk/config/config.sub \
|
---|
247 | $(SRCDIR)/src/kmk/config/install-sh \
|
---|
248 | $(SRCDIR)/src/kmk/w32/Makefile.in \
|
---|
249 | $(SRCDIR)/src/sed/config_h.in~ \
|
---|
250 | $(SRCDIR)/src/sed/intl/printf-args.h \
|
---|
251 | $(SRCDIR)/src/sed/intl/printf.c \
|
---|
252 | $(SRCDIR)/src/sed/intl/localcharset.h \
|
---|
253 | $(SRCDIR)/src/sed/intl/libgnuintl.h.in \
|
---|
254 | $(SRCDIR)/src/sed/intl/vasnwprintf.h \
|
---|
255 | $(SRCDIR)/src/sed/intl/vasnprintf.c \
|
---|
256 | $(SRCDIR)/src/sed/intl/vasnprintf.h \
|
---|
257 | $(SRCDIR)/src/sed/intl/wprintf-parse.h \
|
---|
258 | $(SRCDIR)/src/sed/intl/relocatable.c \
|
---|
259 | $(SRCDIR)/src/sed/intl/relocatable.h \
|
---|
260 | $(SRCDIR)/src/sed/intl/xsize.h \
|
---|
261 | $(SRCDIR)/src/sed/intl/printf-parse.c \
|
---|
262 | $(SRCDIR)/src/sed/intl/printf-parse.h \
|
---|
263 | $(SRCDIR)/src/sed/intl/log.c \
|
---|
264 | $(SRCDIR)/src/sed/intl/printf-args.c \
|
---|
265 | $(SRCDIR)/src/sed/po/remove-potcdate.sin \
|
---|
266 | $(SRCDIR)/src/sed/po/Makevars.template \
|
---|
267 | $(SRCDIR)/src/sed/config/printf-posix.m4 \
|
---|
268 | $(SRCDIR)/src/sed/config/uintmax_t.m4 \
|
---|
269 | $(SRCDIR)/src/sed/config/signed.m4 \
|
---|
270 | $(SRCDIR)/src/sed/config/longlong.m4 \
|
---|
271 | $(SRCDIR)/src/sed/config/inttypes.m4 \
|
---|
272 | $(SRCDIR)/src/sed/config/inttypes_h.m4 \
|
---|
273 | $(SRCDIR)/src/sed/config/longdouble.m4 \
|
---|
274 | $(SRCDIR)/src/sed/config/nls.m4 \
|
---|
275 | $(SRCDIR)/src/sed/config/intmax.m4 \
|
---|
276 | $(SRCDIR)/src/sed/config/mkinstalldirs \
|
---|
277 | $(SRCDIR)/src/sed/config/xsize.m4 \
|
---|
278 | $(SRCDIR)/src/sed/config/ulonglong.m4 \
|
---|
279 | $(SRCDIR)/src/sed/config/wint_t.m4 \
|
---|
280 | $(SRCDIR)/src/sed/config/inttypes-pri.m4 \
|
---|
281 | $(SRCDIR)/src/sed/config/stdint_h.m4 \
|
---|
282 | $(SRCDIR)/src/sed/config/intdiv0.m4 \
|
---|
283 | $(SRCDIR)/src/sed/config/isc-posix.m4 \
|
---|
284 | $(SRCDIR)/src/sed/config/po.m4 \
|
---|
285 | $(SRCDIR)/src/sed/config/size_max.m4 \
|
---|
286 | $(SRCDIR)/src/sed/config/wchar_t.m4 \
|
---|
287 | $(SRCDIR)/src/sed/*~ \
|
---|
288 | $(SRCDIR)/src/sed/config/*~ \
|
---|
289 | $(SRCDIR)/src/sed/intl/*~ \
|
---|
290 | $(SRCDIR)/src/sed/po/*~ \
|
---|
291 |
|
---|
292 | distclean: clean
|
---|
293 | $(SVN) revert \
|
---|
294 | src/sed/configure \
|
---|
295 | src/sed/Makefile.in \
|
---|
296 | src/sed/doc/Makefile.in \
|
---|
297 | src/sed/doc/stamp-vti \
|
---|
298 | src/sed/doc/sed.info \
|
---|
299 | src/sed/doc/sed.info-1 \
|
---|
300 | src/sed/doc/sed.info-2 \
|
---|
301 | src/sed/doc/version.texi \
|
---|
302 | src/sed/INSTALL \
|
---|
303 | src/sed/lib/Makefile.in \
|
---|
304 | src/sed/sed/Makefile.in \
|
---|
305 | src/sed/config_h.in \
|
---|
306 | src/sed/testsuite/Makefile.in \
|
---|
307 | src/sed/config/depcomp \
|
---|
308 | src/sed/config/config.guess \
|
---|
309 | src/sed/config/config.sub \
|
---|
310 | src/sed/config/mdate-sh \
|
---|
311 | src/sed/config/missing \
|
---|
312 | src/sed/config/texinfo.tex \
|
---|
313 | src/sed/config/install-sh \
|
---|
314 | src/sed/aclocal.m4 \
|
---|
315 | src/sed/ABOUT-NLS \
|
---|
316 | src/sed/doc/sed.1 \
|
---|
317 | src/sed/intl/plural-exp.h \
|
---|
318 | src/sed/intl/Makefile.in \
|
---|
319 | src/sed/intl/explodename.c \
|
---|
320 | src/sed/intl/localcharset.c \
|
---|
321 | src/sed/intl/VERSION \
|
---|
322 | src/sed/intl/dcigettext.c \
|
---|
323 | src/sed/intl/dngettext.c \
|
---|
324 | src/sed/intl/localealias.c \
|
---|
325 | src/sed/intl/textdomain.c \
|
---|
326 | src/sed/intl/bindtextdom.c \
|
---|
327 | src/sed/intl/ref-del.sin \
|
---|
328 | src/sed/intl/intl-compat.c \
|
---|
329 | src/sed/intl/dgettext.c \
|
---|
330 | src/sed/intl/dcgettext.c \
|
---|
331 | src/sed/intl/plural.c \
|
---|
332 | src/sed/intl/loadinfo.h \
|
---|
333 | src/sed/intl/localename.c \
|
---|
334 | src/sed/intl/ngettext.c \
|
---|
335 | src/sed/intl/ChangeLog \
|
---|
336 | src/sed/intl/locale.alias \
|
---|
337 | src/sed/intl/os2compat.c \
|
---|
338 | src/sed/intl/finddomain.c \
|
---|
339 | src/sed/intl/ref-add.sin \
|
---|
340 | src/sed/intl/gettextP.h \
|
---|
341 | src/sed/intl/dcngettext.c \
|
---|
342 | src/sed/intl/osdep.c \
|
---|
343 | src/sed/intl/config.charset \
|
---|
344 | src/sed/intl/l10nflist.c \
|
---|
345 | src/sed/intl/os2compat.h \
|
---|
346 | src/sed/intl/loadmsgcat.c \
|
---|
347 | src/sed/intl/gettext.c \
|
---|
348 | src/sed/intl/plural.y \
|
---|
349 | src/sed/intl/gmo.h \
|
---|
350 | src/sed/intl/plural-exp.c \
|
---|
351 | src/sed/intl/eval-plural.h \
|
---|
352 | src/sed/intl/hash-string.h \
|
---|
353 | src/sed/config.h.darwin \
|
---|
354 | src/sed/po/Makefile.in.in \
|
---|
355 | src/sed/po/Rules-quot \
|
---|
356 | src/sed/config/lib-prefix.m4 \
|
---|
357 | src/sed/config/lib-link.m4 \
|
---|
358 | src/sed/config/lib-ld.m4 \
|
---|
359 | src/sed/config/lcmessage.m4 \
|
---|
360 | src/sed/config/config.rpath \
|
---|
361 | src/sed/config/progtest.m4 \
|
---|
362 | src/sed/config/iconv.m4 \
|
---|
363 | src/sed/config/gettext.m4
|
---|
364 | $(SVN) revert \
|
---|
365 | src/kmk/config.h.solaris \
|
---|
366 | src/sed/config.h.solaris
|
---|
367 | $(SVN) status --no-ignore
|
---|
368 |
|
---|
369 |
|
---|
370 |
|
---|
371 | # can't hurt...
|
---|
372 | .NOTPARALLEL:
|
---|
373 |
|
---|