[995] | 1 | # $Id: bootstrap.gmk 2135 2008-12-25 15:22:04Z 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 | #
|
---|
| 54 | ifndef KBUILD_HOST
|
---|
| 55 | KBUILD_HOST := $(BUILD_PLATFORM)
|
---|
| 56 | endif
|
---|
| 57 | ifndef KBUILD_HOST_ARCH
|
---|
| 58 | KBUILD_HOST_ARCH := $(BUILD_PLATFORM_ARCH)
|
---|
| 59 | endif
|
---|
| 60 | ifndef KBUILD_HOST_CPU
|
---|
| 61 | KBUILD_HOST_CPU := $(BUILD_PLATFORM_CPU)
|
---|
| 62 | endif
|
---|
| 63 |
|
---|
| 64 | ifndef KBUILD_TARGET
|
---|
| 65 | KBUILD_TARGET := $(BUILD_TARGET)
|
---|
| 66 | endif
|
---|
| 67 | ifndef KBUILD_TARGET_ARCH
|
---|
| 68 | KBUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH)
|
---|
| 69 | endif
|
---|
| 70 | ifndef KBUILD_TARGET_CPU
|
---|
| 71 | KBUILD_TARGET_CPU := $(BUILD_TARGET_CPU)
|
---|
| 72 | endif
|
---|
| 73 |
|
---|
| 74 | ifndef KBUILD_TYPE
|
---|
| 75 | KBUILD_TYPE := $(BUILD_TYPE)
|
---|
| 76 | endif
|
---|
| 77 |
|
---|
| 78 | ifndef KBUILD_PATH
|
---|
| 79 | KBUILD_PATH := $(PATH_KBUILD)
|
---|
| 80 | endif
|
---|
| 81 |
|
---|
[1529] | 82 | #
|
---|
| 83 | # Check (some of) the assumptions.
|
---|
| 84 | #
|
---|
| 85 | ifndef KBUILD_TARGET
|
---|
| 86 | $(error KBUILD_TARGET not set)
|
---|
| 87 | endif
|
---|
[1506] | 88 |
|
---|
[1529] | 89 | ifndef KBUILD_HOST
|
---|
| 90 | $(error KBUILD_HOST not set)
|
---|
| 91 | endif
|
---|
| 92 |
|
---|
| 93 | ifndef KBUILD_HOST_ARCH
|
---|
| 94 | $(error KBUILD_HOST_ARCH not set)
|
---|
| 95 | endif
|
---|
| 96 |
|
---|
| 97 | ifndef KBUILD_TYPE
|
---|
| 98 | $(error KBUILD_TYPE not set)
|
---|
| 99 | endif
|
---|
| 100 |
|
---|
| 101 | ifndef KBUILD_TYPE
|
---|
| 102 | $(error KBUILD_TYPE not set)
|
---|
| 103 | endif
|
---|
| 104 |
|
---|
| 105 | ifndef KBUILD_PATH
|
---|
| 106 | $(error KBUILD_PATH not set)
|
---|
| 107 | endif
|
---|
| 108 |
|
---|
| 109 | ifdef KBUILD_BIN_PATH
|
---|
| 110 | $(error KBUILD_BIN_PATH is set)
|
---|
| 111 | endif
|
---|
| 112 | ifdef PATH_KBUILD_BIN
|
---|
| 113 | $(error PATH_KBUILD_BIN is set)
|
---|
| 114 | endif
|
---|
| 115 |
|
---|
| 116 |
|
---|
[1506] | 117 | #
|
---|
| 118 | # Globals
|
---|
| 119 | #
|
---|
[996] | 120 | SRCDIR = $(CURDIR)
|
---|
[1506] | 121 | OUTDIR = $(SRCDIR)/out/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)/$(KBUILD_TYPE)/bootstrap
|
---|
[995] | 122 |
|
---|
[1068] | 123 | # Override this on the make commandline if you need to (FreeBSD).
|
---|
| 124 | AUTORECONF = autoreconf
|
---|
[995] | 125 |
|
---|
[996] | 126 | all: stage1 stage2
|
---|
[995] | 127 |
|
---|
[996] | 128 |
|
---|
[995] | 129 | #
|
---|
[1339] | 130 | # Stage 1 - Build bootstrap kmk, kmk_redirect and sed, refresh config.h caches, link
|
---|
[995] | 131 | # up kmk_ash so $(OUTDIR)/kmk can serve as kBuild bin dir.
|
---|
| 132 | #
|
---|
| 133 | stage1: \
|
---|
| 134 | $(OUTDIR)/kmk/kmk \
|
---|
| 135 | $(OUTDIR)/kmk/kmk_ash \
|
---|
| 136 | $(OUTDIR)/kmk/kmk_sed \
|
---|
[2109] | 137 | $(OUTDIR)/kmk/kmk_echo \
|
---|
[1506] | 138 | $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
|
---|
| 139 | $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET)
|
---|
[995] | 140 |
|
---|
| 141 | # kmk
|
---|
[996] | 142 | $(OUTDIR)/kmk/ts-autoreconf:
|
---|
| 143 | mkdir -p $(@D)
|
---|
[1068] | 144 | cd $(SRCDIR)/src/kmk && $(AUTORECONF) -i -v
|
---|
[996] | 145 | echo done > $@
|
---|
[995] | 146 |
|
---|
[2110] | 147 | $(OUTDIR)/kmk/ts-configured: \
|
---|
| 148 | $(OUTDIR)/kmk/ts-autoreconf \
|
---|
| 149 | $(OUTDIR)/kmk/fts.h
|
---|
[996] | 150 | cd $(OUTDIR)/kmk && $(SRCDIR)/src/kmk/configure
|
---|
| 151 | echo done > $@
|
---|
[995] | 152 |
|
---|
[2111] | 153 | ifeq ($(KBUILD_HOST),solaris)
|
---|
| 154 | $(OUTDIR)/kmk/ts-configured: $(OUTDIR)/kmk/paths.h
|
---|
| 155 |
|
---|
| 156 | $(OUTDIR)/kmk/paths.h:
|
---|
| 157 | echo > $@
|
---|
| 158 | endif
|
---|
| 159 |
|
---|
[2109] | 160 | $(OUTDIR)/kmk/fts.h:
|
---|
| 161 | ln -s $(SRCDIR)/src/kmk/kmkbuiltin/ftsfake.h $@
|
---|
[995] | 162 |
|
---|
[2110] | 163 | $(OUTDIR)/kmk/config.h: $(OUTDIR)/kmk/ts-configured
|
---|
[2109] | 164 |
|
---|
[2110] | 165 |
|
---|
[1506] | 166 | $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET): $(OUTDIR)/kmk/config.h
|
---|
| 167 | cp -f $(OUTDIR)/kmk/config.h $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET)
|
---|
[2122] | 168 | echo "" >> $@
|
---|
| 169 | echo '#include "inlined_memchr.h"' >> $@
|
---|
[995] | 170 |
|
---|
| 171 | $(OUTDIR)/kmk/kmk: $(OUTDIR)/kmk/ts-configured
|
---|
[996] | 172 | $(MAKE) -C $(@D)
|
---|
[995] | 173 |
|
---|
| 174 | # sed
|
---|
[996] | 175 | $(OUTDIR)/sed/ts-autoreconf:
|
---|
| 176 | mkdir -p $(@D)
|
---|
[1159] | 177 | @cd $(SRCDIR)/src/sed && $(AUTORECONF) -i -v --force
|
---|
[996] | 178 | echo done > $@
|
---|
[995] | 179 |
|
---|
| 180 | $(OUTDIR)/sed/ts-configured: $(OUTDIR)/sed/ts-autoreconf
|
---|
[996] | 181 | cd $(OUTDIR)/sed && $(SRCDIR)/src/sed/configure --without-libintl --disable-nls
|
---|
| 182 | echo done > $@
|
---|
[995] | 183 |
|
---|
| 184 | $(OUTDIR)/sed/config.h: $(OUTDIR)/sed/ts-configured
|
---|
| 185 |
|
---|
[1506] | 186 | $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET): $(OUTDIR)/sed/config.h
|
---|
[996] | 187 | cp -f $< $@
|
---|
[995] | 188 |
|
---|
[996] | 189 | $(OUTDIR)/sed/sed/sed: $(OUTDIR)/sed/ts-configured
|
---|
[2112] | 190 | $(MAKE) $(SED_MAKE_DEFS) -C $(@D)/..
|
---|
[995] | 191 |
|
---|
[996] | 192 | $(OUTDIR)/kmk/kmk_sed: $(OUTDIR)/sed/sed/sed
|
---|
| 193 | cp -f $< $@
|
---|
[995] | 194 |
|
---|
| 195 | $(OUTDIR)/kmk/kmk_ash:
|
---|
[2120] | 196 | ifeq ($(KBUILD_TARGET),solaris)
|
---|
| 197 | ln -s /usr/bin/bash $@
|
---|
| 198 | else
|
---|
[996] | 199 | ln -s /bin/sh $@
|
---|
[2120] | 200 | endif
|
---|
[995] | 201 |
|
---|
[2109] | 202 | $(OUTDIR)/kmk/kmk_echo:
|
---|
| 203 | ln -s /bin/echo $@
|
---|
| 204 |
|
---|
[995] | 205 | #
|
---|
| 206 | # Stage 2 - Build kBuild using the bootstrap tools from the previous step
|
---|
| 207 | # and install it to kBuild/bin/x.y.
|
---|
| 208 | #
|
---|
| 209 | stage2: \
|
---|
| 210 | $(OUTDIR)/ts-stage2-build \
|
---|
| 211 | $(OUTDIR)/ts-stage2-install
|
---|
| 212 |
|
---|
[996] | 213 | $(OUTDIR)/ts-stage2-build: \
|
---|
[1506] | 214 | $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
|
---|
| 215 | $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET) \
|
---|
[996] | 216 | $(OUTDIR)/kmk/kmk
|
---|
| 217 | $(OUTDIR)/kmk/kmk -C $(SRCDIR)
|
---|
| 218 | echo done > $@
|
---|
[995] | 219 |
|
---|
[996] | 220 | $(OUTDIR)/ts-stage2-install: $(OUTDIR)/ts-stage2-build
|
---|
[998] | 221 | $(OUTDIR)/kmk/kmk -C $(SRCDIR) PATH_INS=$(SRCDIR) install
|
---|
[996] | 222 | echo done > $@
|
---|
[995] | 223 |
|
---|
[996] | 224 |
|
---|
[999] | 225 | #
|
---|
| 226 | # Clean the output files...
|
---|
| 227 | #
|
---|
| 228 | clean:
|
---|
| 229 | rm -Rf $(SRCDIR)/out/ \
|
---|
| 230 | $(SRCDIR)/src/kmk/autom4te.cache/ \
|
---|
| 231 | $(SRCDIR)/src/sed/autom4te.cache/
|
---|
| 232 | rm -f $(SRCDIR)/src/kmk/Makefile.in \
|
---|
| 233 | $(SRCDIR)/src/kmk/config.h.in \
|
---|
| 234 | $(SRCDIR)/src/kmk/configure \
|
---|
| 235 | $(SRCDIR)/src/kmk/aclocal.m4 \
|
---|
| 236 | $(SRCDIR)/src/kmk/glob/Makefile.in \
|
---|
| 237 | $(SRCDIR)/src/kmk/config/Makefile.in \
|
---|
| 238 | $(SRCDIR)/src/kmk/config/depcomp \
|
---|
| 239 | $(SRCDIR)/src/kmk/config/compile \
|
---|
| 240 | $(SRCDIR)/src/kmk/config/missing \
|
---|
| 241 | $(SRCDIR)/src/kmk/config/config.guess \
|
---|
| 242 | $(SRCDIR)/src/kmk/config/config.sub \
|
---|
| 243 | $(SRCDIR)/src/kmk/config/install-sh \
|
---|
| 244 | $(SRCDIR)/src/kmk/w32/Makefile.in
|
---|
[996] | 245 |
|
---|
[2135] | 246 | distclean: clean
|
---|
| 247 | svn revert \
|
---|
| 248 | src/kmk/config.h.solaris \
|
---|
| 249 | src/sed/config.h.solaris \
|
---|
| 250 | src/sed/configure \
|
---|
| 251 | src/sed/Makefile.in \
|
---|
| 252 | src/sed/doc/Makefile.in \
|
---|
| 253 | src/sed/doc/stamp-vti \
|
---|
| 254 | src/sed/doc/sed.info \
|
---|
| 255 | src/sed/doc/version.texi \
|
---|
| 256 | src/sed/INSTALL \
|
---|
| 257 | src/sed/lib/Makefile.in \
|
---|
| 258 | src/sed/sed/Makefile.in \
|
---|
| 259 | src/sed/config_h.in \
|
---|
| 260 | src/sed/testsuite/Makefile.in \
|
---|
| 261 | src/sed/config/depcomp \
|
---|
| 262 | src/sed/config/config.guess \
|
---|
| 263 | src/sed/config/config.sub \
|
---|
| 264 | src/sed/config/mdate-sh \
|
---|
| 265 | src/sed/config/missing \
|
---|
| 266 | src/sed/config/texinfo.tex \
|
---|
| 267 | src/sed/config/install-sh \
|
---|
| 268 | src/sed/aclocal.m4
|
---|
[996] | 269 |
|
---|
[2135] | 270 |
|
---|
| 271 |
|
---|
[996] | 272 | # can't hurt...
|
---|
| 273 | .NOTPARALLEL:
|
---|
| 274 |
|
---|