1 | # $Id: bootstrap.gmk 995 2007-05-29 20:52:03Z bird $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # GNU Make Compatible bootstrap Makefile.
|
---|
5 | #
|
---|
6 | # Copyright (c) 2007 knut st. osmundsen <[email protected]>
|
---|
7 | #
|
---|
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 2 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, write to the Free Software
|
---|
23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | #
|
---|
25 | #
|
---|
26 |
|
---|
27 |
|
---|
28 | #
|
---|
29 | # ASSUMES:
|
---|
30 | # - BUILD_TARGET, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU in the env.
|
---|
31 | # - PATH_KBUILD points to ./kBuild with an absolute path.
|
---|
32 | # - Current directory == bootstrap.gmk directory.
|
---|
33 | # - mkdir -p works.
|
---|
34 | # - ln -s works
|
---|
35 | # - cp -f works
|
---|
36 | # - cd somedir && command works.
|
---|
37 | # - echo done > file works.
|
---|
38 | #
|
---|
39 | # Tip. kBuild/env.sh (g)make -f bootstrap.kmk
|
---|
40 | #
|
---|
41 | #
|
---|
42 |
|
---|
43 | #
|
---|
44 | # OPTIONAL:
|
---|
45 | # Set env.var. NIX_INSTALL_DIR to /usr/local or /usr
|
---|
46 | # (see Config.kmk and wiki for details)
|
---|
47 | #
|
---|
48 |
|
---|
49 | srcdir = .
|
---|
50 | OUTDIR = $(srcdir)/out/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)/$(BUILD_TYPE)/bootstrap
|
---|
51 |
|
---|
52 | .NOTPARALLEL:
|
---|
53 |
|
---|
54 | .PHONEY: all stage1 stage2
|
---|
55 | all: stage1
|
---|
56 |
|
---|
57 | #
|
---|
58 | # Stage 1 - Build bootstrap kmk and sed, refresh config.h caches, link
|
---|
59 | # up kmk_ash so $(OUTDIR)/kmk can serve as kBuild bin dir.
|
---|
60 | #
|
---|
61 | stage1: \
|
---|
62 | $(OUTDIR)/kmk/kmk \
|
---|
63 | $(OUTDIR)/kmk/kmk_ash \
|
---|
64 | $(OUTDIR)/kmk/kmk_sed \
|
---|
65 | $(srcdir)/src/kmk/config.h.$(BUILD_TARGET) \
|
---|
66 | $(srcdir)/src/sed/config.h.$(BUILD_TARGET)
|
---|
67 |
|
---|
68 | # kmk
|
---|
69 | $(OUTDIR)/kmk/:
|
---|
70 | mkdir -p $@
|
---|
71 |
|
---|
72 | $(OUTDIR)/kmk/ts-autoreconf: $(OUTDIR)/kmk/
|
---|
73 | cd $(srcdir)/src/kmk && autoreconf -i -v
|
---|
74 | echo done > $@
|
---|
75 |
|
---|
76 | $(OUTDIR)/kmk/ts-configured: $(OUTDIR)/kmk/ts-autoreconf
|
---|
77 | cd $(OUTDIR)/kmk && $(srcdir)/src/kmk/configure
|
---|
78 | echo done > $@
|
---|
79 |
|
---|
80 | $(OUTDIR)/kmk/config.h: $(OUTDIR)/kmk/ts-configured
|
---|
81 |
|
---|
82 | $(srcdir)/src/kmk/config.h.$(BUILD_TARGET): $(OUTDIR)/kmk/config.h
|
---|
83 | cp -f $(OUTDIR)/kmk/config.h $(srcdir)/src/kmk/config.h.$(BUILD_TARGET)
|
---|
84 |
|
---|
85 | $(OUTDIR)/kmk/kmk: $(OUTDIR)/kmk/ts-configured
|
---|
86 | $(MAKE) -C $(@D)
|
---|
87 |
|
---|
88 | # sed
|
---|
89 | $(OUTDIR)/sed/:
|
---|
90 | mkdir -p $@
|
---|
91 |
|
---|
92 | $(OUTDIR)/sed/ts-autoreconf: $(OUTDIR)/sed/
|
---|
93 | cd $(srcdir)/src/sed && autoreconf -i -v
|
---|
94 | echo done > $@
|
---|
95 |
|
---|
96 | $(OUTDIR)/sed/ts-configured: $(OUTDIR)/sed/ts-autoreconf
|
---|
97 | cd $(OUTDIR)/sed && $(srcdir)/src/sed/configure --without-libintl --disable-nls
|
---|
98 | echo done > $@
|
---|
99 |
|
---|
100 | $(OUTDIR)/sed/config.h: $(OUTDIR)/sed/ts-configured
|
---|
101 |
|
---|
102 | $(srcdir)/src/sed/config.h.$(BUILD_TARGET): $(OUTDIR)/sed/config.h
|
---|
103 | cp -f $< $@
|
---|
104 |
|
---|
105 | $(OUTDIR)/sed/src/sed: $(OUTDIR)/sed/ts-configured
|
---|
106 | $(MAKE) -C $(@D)
|
---|
107 |
|
---|
108 | $(OUTDIR)/kmk/kmk_sed: $(OUTDIR)/sed/src/sed
|
---|
109 | cp -f $< $@
|
---|
110 |
|
---|
111 | $(OUTDIR)/kmk/kmk_ash:
|
---|
112 | ln -s /bin/sh $@
|
---|
113 |
|
---|
114 | #
|
---|
115 | # Stage 2 - Build kBuild using the bootstrap tools from the previous step
|
---|
116 | # and install it to kBuild/bin/x.y.
|
---|
117 | #
|
---|
118 | stage2: \
|
---|
119 | $(OUTDIR)/ts-stage2-build \
|
---|
120 | $(OUTDIR)/ts-stage2-install
|
---|
121 |
|
---|
122 | $(OUTDIR)/ts-stage2-build:
|
---|
123 | PATH_KBUILD_BIN=$(OUTDIR)/kmk $(OUTDIR)/kmk -C $(srcdir)
|
---|
124 | echo done > $@
|
---|
125 |
|
---|
126 | $(OUTDIR)/ts-stage2-install:
|
---|
127 | PATH_KBUILD_BIN=$(OUTDIR)/kmk $(OUTDIR)/kmk -C $(srcdir) PATH_INS=$(srcdir) install
|
---|
128 | echo done > $@
|
---|
129 |
|
---|