source: trunk/bootstrap.gmk@ 2190

Last change on this file since 2190 was 2190, checked in by bird, 17 years ago

bootstrap.gmk,Config.kmk: Don't use NIX_INSTALL_DIR as installation directory while bootstrapping (governed by KBUILD_BOOSTRAP), otherwise kBuild/env.sh won't find stuff afterwards.

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