source: trunk/bootstrap.gmk@ 1512

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

Added a --full option and not exporting defaults.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.8 KB
RevLine 
[995]1# $Id: bootstrap.gmk 1512 2008-04-09 01:36:57Z bird $
2## @file
3# GNU Make Compatible bootstrap Makefile.
4#
[1512]5
6#
[995]7# Copyright (c) 2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
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:
[1506]30# - KBUILD_TARGET, KBUILD_HOST, KBUILD_HOST_ARCH, and KBUILD_TYPE in the env.
[995]31# - PATH_KBUILD points to ./kBuild with an absolute path.
[996]32# - PATH_KBUILD_BIN must *NOT* be defined anywhere.
[995]33# - Current directory == bootstrap.gmk directory.
34# - mkdir -p works.
35# - ln -s works
36# - cp -f works
37# - cd somedir && command works.
[1506]38# - echo done > some-file works.
[996]39# - GNU make implements CURDIR, if not please define SRCDIR.
[995]40#
[1512]41# Tip: kBuild/env.sh --full (g)make -f bootstrap.kmk
[995]42#
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
82
83#
84# Globals
85#
[996]86SRCDIR = $(CURDIR)
[1506]87OUTDIR = $(SRCDIR)/out/$(KBUILD_HOST).$(KBUILD_HOST_ARCH)/$(KBUILD_TYPE)/bootstrap
[995]88
[1068]89# Override this on the make commandline if you need to (FreeBSD).
90AUTORECONF = autoreconf
[995]91
[996]92all: stage1 stage2
[995]93
[996]94
[995]95#
[1339]96# Stage 1 - Build bootstrap kmk, kmk_redirect and sed, refresh config.h caches, link
[995]97# up kmk_ash so $(OUTDIR)/kmk can serve as kBuild bin dir.
98#
99stage1: \
100 $(OUTDIR)/kmk/kmk \
101 $(OUTDIR)/kmk/kmk_ash \
102 $(OUTDIR)/kmk/kmk_sed \
[1506]103 $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
104 $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET)
[995]105
106# kmk
[996]107$(OUTDIR)/kmk/ts-autoreconf:
108 mkdir -p $(@D)
[1068]109 cd $(SRCDIR)/src/kmk && $(AUTORECONF) -i -v
[996]110 echo done > $@
[995]111
112$(OUTDIR)/kmk/ts-configured: $(OUTDIR)/kmk/ts-autoreconf
[996]113 cd $(OUTDIR)/kmk && $(SRCDIR)/src/kmk/configure
114 echo done > $@
[995]115
116$(OUTDIR)/kmk/config.h: $(OUTDIR)/kmk/ts-configured
117
[1506]118$(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET): $(OUTDIR)/kmk/config.h
119 cp -f $(OUTDIR)/kmk/config.h $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET)
[995]120
121$(OUTDIR)/kmk/kmk: $(OUTDIR)/kmk/ts-configured
[996]122 $(MAKE) -C $(@D)
[995]123
124# sed
[996]125$(OUTDIR)/sed/ts-autoreconf:
126 mkdir -p $(@D)
[1159]127 @cd $(SRCDIR)/src/sed && $(AUTORECONF) -i -v --force
[996]128 echo done > $@
[995]129
130$(OUTDIR)/sed/ts-configured: $(OUTDIR)/sed/ts-autoreconf
[996]131 cd $(OUTDIR)/sed && $(SRCDIR)/src/sed/configure --without-libintl --disable-nls
132 echo done > $@
[995]133
134$(OUTDIR)/sed/config.h: $(OUTDIR)/sed/ts-configured
135
[1506]136$(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET): $(OUTDIR)/sed/config.h
[996]137 cp -f $< $@
[995]138
[996]139$(OUTDIR)/sed/sed/sed: $(OUTDIR)/sed/ts-configured
140 $(MAKE) -C $(@D)/..
[995]141
[996]142$(OUTDIR)/kmk/kmk_sed: $(OUTDIR)/sed/sed/sed
143 cp -f $< $@
[995]144
145$(OUTDIR)/kmk/kmk_ash:
[996]146 ln -s /bin/sh $@
[995]147
148#
149# Stage 2 - Build kBuild using the bootstrap tools from the previous step
150# and install it to kBuild/bin/x.y.
151#
152stage2: \
153 $(OUTDIR)/ts-stage2-build \
154 $(OUTDIR)/ts-stage2-install
155
[996]156$(OUTDIR)/ts-stage2-build: \
[1506]157 $(SRCDIR)/src/kmk/config.h.$(KBUILD_TARGET) \
158 $(SRCDIR)/src/sed/config.h.$(KBUILD_TARGET) \
[996]159 $(OUTDIR)/kmk/kmk
160 $(OUTDIR)/kmk/kmk -C $(SRCDIR)
161 echo done > $@
[995]162
[996]163$(OUTDIR)/ts-stage2-install: $(OUTDIR)/ts-stage2-build
[998]164 $(OUTDIR)/kmk/kmk -C $(SRCDIR) PATH_INS=$(SRCDIR) install
[996]165 echo done > $@
[995]166
[996]167
[999]168#
169# Clean the output files...
170#
171clean:
172 rm -Rf $(SRCDIR)/out/ \
173 $(SRCDIR)/src/kmk/autom4te.cache/ \
174 $(SRCDIR)/src/sed/autom4te.cache/
175 rm -f $(SRCDIR)/src/kmk/Makefile.in \
176 $(SRCDIR)/src/kmk/config.h.in \
177 $(SRCDIR)/src/kmk/configure \
178 $(SRCDIR)/src/kmk/aclocal.m4 \
179 $(SRCDIR)/src/kmk/glob/Makefile.in \
180 $(SRCDIR)/src/kmk/config/Makefile.in \
181 $(SRCDIR)/src/kmk/config/depcomp \
182 $(SRCDIR)/src/kmk/config/compile \
183 $(SRCDIR)/src/kmk/config/missing \
184 $(SRCDIR)/src/kmk/config/config.guess \
185 $(SRCDIR)/src/kmk/config/config.sub \
186 $(SRCDIR)/src/kmk/config/install-sh \
187 $(SRCDIR)/src/kmk/w32/Makefile.in
[996]188
189
190# can't hurt...
191.NOTPARALLEL:
192
Note: See TracBrowser for help on using the repository browser.