# $Id: bootstrap.gmk 1159 2007-09-30 03:03:50Z bird $ ## @file # # GNU Make Compatible bootstrap Makefile. # # Copyright (c) 2007 knut st. osmundsen # # # This file is part of kBuild. # # kBuild is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # kBuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with kBuild; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # # ASSUMES: # - BUILD_TARGET, BUILD_PLATFORM_ARCH, BUILD_PLATFORM_CPU and BUILD_TYPE in the env. # - PATH_KBUILD points to ./kBuild with an absolute path. # - PATH_KBUILD_BIN must *NOT* be defined anywhere. # - Current directory == bootstrap.gmk directory. # - mkdir -p works. # - ln -s works # - cp -f works # - cd somedir && command works. # - echo done > file works. # - GNU make implements CURDIR, if not please define SRCDIR. # # Tip. kBuild/env.sh (g)make -f bootstrap.kmk # # # # OPTIONAL: # Set env.var. NIX_INSTALL_DIR to /usr/local or /usr # (see Config.kmk and wiki for details) # SRCDIR = $(CURDIR) OUTDIR = $(SRCDIR)/out/$(BUILD_PLATFORM).$(BUILD_PLATFORM_ARCH)/$(BUILD_TYPE)/bootstrap # Override this on the make commandline if you need to (FreeBSD). AUTORECONF = autoreconf all: stage1 stage2 # # Stage 1 - Build bootstrap kmk and sed, refresh config.h caches, link # up kmk_ash so $(OUTDIR)/kmk can serve as kBuild bin dir. # stage1: \ $(OUTDIR)/kmk/kmk \ $(OUTDIR)/kmk/kmk_ash \ $(OUTDIR)/kmk/kmk_sed \ $(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET) \ $(SRCDIR)/src/sed/config.h.$(BUILD_TARGET) # kmk $(OUTDIR)/kmk/ts-autoreconf: mkdir -p $(@D) cd $(SRCDIR)/src/kmk && $(AUTORECONF) -i -v echo done > $@ $(OUTDIR)/kmk/ts-configured: $(OUTDIR)/kmk/ts-autoreconf cd $(OUTDIR)/kmk && $(SRCDIR)/src/kmk/configure echo done > $@ $(OUTDIR)/kmk/config.h: $(OUTDIR)/kmk/ts-configured $(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET): $(OUTDIR)/kmk/config.h cp -f $(OUTDIR)/kmk/config.h $(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET) $(OUTDIR)/kmk/kmk: $(OUTDIR)/kmk/ts-configured $(MAKE) -C $(@D) # sed $(OUTDIR)/sed/ts-autoreconf: mkdir -p $(@D) @cd $(SRCDIR)/src/sed && $(AUTORECONF) -i -v --force echo done > $@ $(OUTDIR)/sed/ts-configured: $(OUTDIR)/sed/ts-autoreconf cd $(OUTDIR)/sed && $(SRCDIR)/src/sed/configure --without-libintl --disable-nls echo done > $@ $(OUTDIR)/sed/config.h: $(OUTDIR)/sed/ts-configured $(SRCDIR)/src/sed/config.h.$(BUILD_TARGET): $(OUTDIR)/sed/config.h cp -f $< $@ $(OUTDIR)/sed/sed/sed: $(OUTDIR)/sed/ts-configured $(MAKE) -C $(@D)/.. $(OUTDIR)/kmk/kmk_sed: $(OUTDIR)/sed/sed/sed cp -f $< $@ $(OUTDIR)/kmk/kmk_ash: ln -s /bin/sh $@ # # Stage 2 - Build kBuild using the bootstrap tools from the previous step # and install it to kBuild/bin/x.y. # stage2: \ $(OUTDIR)/ts-stage2-build \ $(OUTDIR)/ts-stage2-install $(OUTDIR)/ts-stage2-build: \ $(SRCDIR)/src/kmk/config.h.$(BUILD_TARGET) \ $(SRCDIR)/src/sed/config.h.$(BUILD_TARGET) \ $(OUTDIR)/kmk/kmk $(OUTDIR)/kmk/kmk -C $(SRCDIR) echo done > $@ $(OUTDIR)/ts-stage2-install: $(OUTDIR)/ts-stage2-build $(OUTDIR)/kmk/kmk -C $(SRCDIR) PATH_INS=$(SRCDIR) install echo done > $@ # # Clean the output files... # clean: rm -Rf $(SRCDIR)/out/ \ $(SRCDIR)/src/kmk/autom4te.cache/ \ $(SRCDIR)/src/sed/autom4te.cache/ rm -f $(SRCDIR)/src/kmk/Makefile.in \ $(SRCDIR)/src/kmk/config.h.in \ $(SRCDIR)/src/kmk/configure \ $(SRCDIR)/src/kmk/aclocal.m4 \ $(SRCDIR)/src/kmk/glob/Makefile.in \ $(SRCDIR)/src/kmk/config/Makefile.in \ $(SRCDIR)/src/kmk/config/depcomp \ $(SRCDIR)/src/kmk/config/compile \ $(SRCDIR)/src/kmk/config/missing \ $(SRCDIR)/src/kmk/config/config.guess \ $(SRCDIR)/src/kmk/config/config.sub \ $(SRCDIR)/src/kmk/config/install-sh \ $(SRCDIR)/src/kmk/w32/Makefile.in # can't hurt... .NOTPARALLEL: