From 26713d42100ebb0f949777060102b8fa20c22ffd Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Sun, 1 Jul 2007 19:04:20 +0000 Subject: Merge the build system to trunk: ct-ng is now installable: - ./configure --prefix=/some/place - make - make install - export PATH="${PATH}:/some/place/bin" - ct-ng diff --git a/Makefile b/Makefile deleted file mode 100644 index 7a94e92..0000000 --- a/Makefile +++ /dev/null @@ -1,86 +0,0 @@ -# Makefile for crosstool-NG. -# Copyright 2006 Yann E. MORIN - -# Don't print directory as we descend into them -MAKEFLAGS += --no-print-directory - -export CT_TOP_DIR=$(shell pwd) - -# This is crosstool-ng version string -export CT_VERSION=$(shell cat $(CT_TOP_DIR)/version) - -export CT_STOP=$(STOP) -export CT_RESTART=$(RESTART) - -.PHONY: all -all: build - -HOST_CC = gcc -funsigned-char - -# Help system -help:: help-head help-config help-samples help-build help-distrib help-env help-tail - -help-head:: - @echo 'Available make targets:' - -help-config:: - @echo - @echo 'Configuration targets:' - -help-samples:: - @echo - @echo 'Preconfigured targets:' - -help-build:: - @echo - @echo 'Build targets:' - -help-distrib:: - @echo - @echo 'Distribution targets:' - -help-env:: - @echo - @echo 'Environement variables (see docs/overview.txt):' - -help-tail:: - @echo - @echo 'Execute "make" or "make all" to build all targets marked with [*]' - -# End help system - -help-build:: - @echo '* build - Build the toolchain' - @echo ' clean - Remove generated files' - @echo ' distclean - Remove generated files, configuration and build directories' - -include $(CT_TOP_DIR)/kconfig/Makefile -include $(CT_TOP_DIR)/samples/Makefile -include $(CT_TOP_DIR)/tools/Makefile -include $(CT_TOP_DIR)/Makefile.steps - -help-distrib:: - @echo ' tarball - Build a tarball of the configured toolchain' - -help-env:: - @echo ' STOP - Stop the build just after this step' - @echo ' RESTART - Restart the build just before this step' - -.config: - @echo "You must run either one of \"make config\" or \"make menuconfig\" first" - @false - -# Actual build -build: .config - @$(CT_TOP_DIR)/scripts/crosstool.sh - -.PHONY: tarball -tarball: - @$(CT_TOP_DIR)/scripts/tarball.sh - -.PHONY: distclean -distclean:: clean - @rm -f .config* ..config.tmp - @rm -f log.* - @[ ! -d "$(CT_TOP_DIR)/targets" ] || chmod -R u+w "$(CT_TOP_DIR)/targets" - @rm -rf "$(CT_TOP_DIR)/targets" diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..e899c8b --- /dev/null +++ b/Makefile.in @@ -0,0 +1,109 @@ +# Makefile.in for building crosstool-ng +# This file serves as source for the ./configure operation + +all: build + +############################################################################### +# Configuration variables + +VERSION:= @@VERSION@@ +BINDIR := @@BINDIR@@ +LIBDIR := @@LIBDIR@@/ct-ng-$(VERSION) +DOCDIR := @@DOCDIR@@/ct-ng-$(VERSION) +MANDIR := @@MANDIR@@/man1 +DATE := @@DATE@@ +MAKE := $(shell which make || type -p make || echo /usr/bin/make) + +############################################################################### +# Global make rules + +build: build-bin build-lib build-doc + +install: build install-bin install-lib install-doc + +clean: clean-bin clean-lib clean-doc + +distclean: clean + @rm -f Makefile + +uninstall: uninstall-bin uninstall-lib uninstall-doc + +############################################################################### +# Specific make rules + +#-------------------------------------- +# Build rules + +build-bin: ct-ng + +build-lib: + +build-doc: docs/ct-ng.1 + +%: %.in + @sed -r -e 's,@@CT_MAKE@@,$(MAKE),g;' \ + -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \ + -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \ + -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \ + -e 's,@@CT_MANDIR@@,$(MANDIR),g;' \ + -e 's,@@CT_VERSION@@,$(VERSION),g;' \ + -e 's,@@CT_DATE@@,$(DATE),g;' \ + $@.in >$@ + +#-------------------------------------- +# Clean rules + +clean-bin: + @rm -f ct-ng + +clean-lib: + +clean-doc: + @rm -f docs/ct-ng.1 + +#-------------------------------------- +# Install rules + +install-bin: $(BINDIR) + @install -m 755 ct-ng $(BINDIR)/ct-ng + +install-lib: $(LIBDIR) install-lib-main install-lib-samples + +install-lib-main: $(LIBDIR) + @for src_dir in config kconfig patches scripts tools; do \ + tar cf - --exclude=.svn $${src_dir} |(cd $(LIBDIR); tar xf -); \ + done + @for src_file in Makefile.steps version; do \ + install -m 644 $${src_file} $(LIBDIR)/$${src_file}; \ + done + +# Samples need a little love: +# - change every occurence of CT_TOP_DIR to CT_LIB_DIR +install-lib-samples: $(LIBDIR) install-lib-main + @tar cf - --exclude=.svn samples |(cd $(LIBDIR); tar xf -) + @for samp_file in $(LIBDIR)/samples/*/crosstool.config; do \ + sed -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file}; \ + done + +install-doc: $(DOCDIR) $(MANDIR) + @for doc_file in LICENSES licenses.d COPYING CREDITS docs/overview.txt; do \ + install -m 644 docs/overview.txt $(DOCDIR); \ + done + @install -m 644 docs/ct-ng.1 $(MANDIR) + +$(BINDIR) $(LIBDIR) $(DOCDIR) $(MANDIR): + @install -m 755 -d $@ + + +#-------------------------------------- +# Uninstall rules + +uninstall-bin: + @rm -f $(BINDIR)/ct-ng + +uninstall-lib: + @rm -rf $(LIBDIR) + +uninstall-doc: + @rm -rf $(DOCDIR) + @rm -f $(MANDIR)/ct-ng.1 diff --git a/Makefile.steps b/Makefile.steps index caf1566..7c1e41b 100644 --- a/Makefile.steps +++ b/Makefile.steps @@ -17,13 +17,13 @@ CT_STEPS := libc_check_config \ debug \ $(CT_STEPS): - @make -C "$(CT_TOP_DIR)" RESTART=$@ STOP=$@ + @make -C "$(CT_TOP_DIR)" -f $(CT_MAKEFILE) RESTART=$@ STOP=$@ $(patsubst %,-%,$(CT_STEPS)): - @make -C "$(CT_TOP_DIR)" STOP=$(patsubst -%,%,$@) + @make -C "$(CT_TOP_DIR)" -f $(CT_MAKEFILE) STOP=$(patsubst -%,%,$@) $(patsubst %,%-,$(CT_STEPS)): - @make -C "$(CT_TOP_DIR)" RESTART=$(patsubst %-,%,$@) + @make -C "$(CT_TOP_DIR)" -f $(CT_MAKEFILE) RESTART=$(patsubst %-,%,$@) help-build:: @echo ' liststeps - Lists all build steps' diff --git a/config/config.in b/config/config.in index d573ce7..e7c236c 100644 --- a/config/config.in +++ b/config/config.in @@ -5,5 +5,5 @@ source config/kernel.in source config/binutils.in source config/cc.in source config/libc.in -source config/tools.in -source config/debug.in +source config.gen/tools.in +source config.gen/debug.in diff --git a/configure b/configure new file mode 100755 index 0000000..6e1ecc4 --- /dev/null +++ b/configure @@ -0,0 +1,91 @@ +#!/bin/sh + +VERSION=$(cat version) +DATE=$(date +%Y%m%d) + +PREFIX=/usr/local +BINDIR="${PREFIX}/bin" +LIBDIR="${PREFIX}/lib" +DOCDIR="${PREFIX}/share/doc" +MANDIR="${PREFIX}/share/man" + +BINDIR_set= +LIBDIR_set= +DOCDIR_set= +MANDIR_set= + +get_optval(){ + local ret + case "$1" in + --*=?*) + echo "${1:9}" + ret=0 + ;; + *) + echo "${2}" + ret=1 + ;; + esac + return ${ret} +} + +set_prefix() { + local ret + PREFIX=$(get_optval "$1" "$2") + ret=$? + [ -z "${BINDIR_set}" ] && BINDIR="${PREFIX}/bin" + [ -z "${LIBDIR_set}" ] && LIBDIR="${PREFIX}/lib" + [ -z "${DOCDIR_set}" ] && DOCDIR="${PREFIX}/share/doc" + [ -z "${MANDIR_set}" ] && MANDIR="${PREFIX}/share/man" + return ${ret} +} + +set_bindir() { + local ret + BINDIR=$(get_optval "$1" "$2") + ret=$? + BINDIR_set=1 + return ${ret} +} + +set_libdir() { + local ret + LIBDIR=$(get_optval "$1" "$2") + ret=$? + LIBDIR_set=1 + return ${ret} +} + +set_docdir() { + local ret + DOCDIR=$(get_optval "$1" "$2") + ret=$? + DOCDIR_set=1 + return ${ret} +} + +set_mandir() { + local ret + MANDIR=$(get_optval "$1" "$2") + ret=$? + MANDIR_set=1 + return ${ret} +} + +while [ $# -ne 0 ]; do + case "$1" in + --prefix*) set_prefix "$1" "$2" && shift || shift 2;; + --bindir*) set_bindir "$1" "$2" && shift || shift 2;; + --libdir*) set_libdir "$1" "$2" && shift || shift 2;; + --docdir*) set_docdir "$1" "$2" && shift || shift 2;; + --mandir*) set_mandir "$1" "$2" && shift || shift 2;; + esac +done + +sed -r -e "s,@@BINDIR@@,${BINDIR},g;" \ + -e "s,@@LIBDIR@@,${LIBDIR},g;" \ + -e "s,@@DOCDIR@@,${DOCDIR},g;" \ + -e "s,@@MANDIR@@,${MANDIR},g;" \ + -e "s,@@VERSION@@,${VERSION},g;" \ + -e "s,@@DATE@@,${DATE},g;" \ + Makefile.in >Makefile diff --git a/ct-ng.in b/ct-ng.in new file mode 100644 index 0000000..11915d2 --- /dev/null +++ b/ct-ng.in @@ -0,0 +1,99 @@ +#!@@CT_MAKE@@ -f +# Makefile for crosstool-NG. +# Copyright 2006 Yann E. MORIN + +# Don't print directory as we descend into them +MAKEFLAGS += --no-print-directory + +# Remember the name of the Makefile +CT_MAKEFILE := $(lastword $(MAKEFILE_LIST)) +CT_NG := $(shell echo '$(CT_MAKEFILE)' |sed -r -e 's,($(subst :,|,$(PATH)))/,,;') + +export CT_TOP_DIR:=$(shell pwd) +export CT_LIB_DIR:=@@CT_LIBDIR@@ +export CT_DOC_DIR:=@@CT_DOCDIR@@ + +# This is crosstool-ng version string +export CT_VERSION=$(shell cat $(CT_LIB_DIR)/version) + +export CT_STOP=$(STOP) +export CT_RESTART=$(RESTART) + +.PHONY: $(PHONY) +PHONY += all +all: build + +HOST_CC = gcc -funsigned-char + +# Help system +help:: help-head help-config help-samples help-build help-distrib help-env help-tail + +help-head:: + @echo 'Available make rules:' + +help-config:: + @echo + @echo 'Configuration rules:' + +help-samples:: + @echo + @echo 'Preconfigured rules:' + +help-build:: + @echo + @echo 'Build rules:' + +help-distrib:: + @echo + @echo 'Distribution rules:' + +help-env:: + @echo + @echo 'Environement variables (see @@CT_DOCDIR@@/overview.txt):' + +help-tail:: + @echo + @echo 'Execute "$(CT_NG) config" or "$(CT_NG) menuconfig" to configure ct-ng' + @echo 'Execute "$(CT_NG)" or "$(CT_NG) all" to build all targets marked with [*]' + +# End help system + +help-build:: + @echo '* build - Build the toolchain' + @echo ' clean - Remove generated files' + @echo ' distclean - Remove generated files, configuration and build directories' + +include $(CT_LIB_DIR)/kconfig/Makefile +include $(CT_LIB_DIR)/samples/Makefile +include $(CT_LIB_DIR)/tools/Makefile +include $(CT_LIB_DIR)/Makefile.steps + +help-distrib:: + @echo ' tarball - Build a tarball of the configured toolchain' + +help-env:: + @echo ' STOP - Stop the build just after this step' + @echo ' RESTART - Restart the build just before this step' + +.config: + @echo 'You must run either one of "$(CT_NG) config" or "$(CT_NG) menuconfig" first' + @false + +# Actual build +build:: .config + @$(CT_LIB_DIR)/scripts/crosstool.sh + +PHONY += tarball +tarball: + @$(CT_LIB_DIR)/scripts/tarball.sh + +PHONY += clean +clean:: + @rm -f $(CT_TOP_DIR)/.config.* + +PHONY += distclean +distclean:: clean + @rm -f $(CT_TOP_DIR)/.config* $(CT_TOP_DIR)/..config.tmp + @rm -f $(CT_TOP_DIR)/log.* + @[ ! -d "$(CT_TOP_DIR)/targets" ] || chmod -R u+w "$(CT_TOP_DIR)/targets" + @rm -rf "$(CT_TOP_DIR)/targets" diff --git a/docs/ct-ng.1.in b/docs/ct-ng.1.in new file mode 100644 index 0000000..ac033dc --- /dev/null +++ b/docs/ct-ng.1.in @@ -0,0 +1,174 @@ +." crosstool-ng man page +." Copyright 2007 Yann E. MORIN +." Licensed under the Creative Commons BY-SA, v2.5 +." +." Beautifying URLs +.mso www.tmac +." +.TH ct-ng 1 "@@CT_DATE@@" "version @@CT_VERSION@@" "User Commands" +." +." +.SH NAME +ct-ng, crosstool-ng \- Build cross-toolchains +." +." +.SH SYNOPSIS +.B ct-ng ACTION +." +." +.SH DESCRIPTION +Building a cross-toolchain can be a real pain. +.PP +.B ct-ng +makes it easy to build cross-toolchains, and allows you to take all the juice +out of your target by configuring the differents components of the toolchain +accordingly to the targeted processor. +." +." +.SH ACTIONS +Here are the most commonly used actions. For other actions, please see +.I @@CT_DOCDIR@@/overview.txt +.TP +.B help +Prints a little help text. +." +.TP +.B menuconfig +Configures +.B ct-ng +using a configurator menu very similar to that of the Linux kernel. +." +.TP +.B oldconfig +Apply options found in an existing +.I .config +file, and ask for newer options if there are any. +." +.TP +.B saveconfig +Save the current +.B ct-ng +configuration, and associated components' config files, into a sample. Samples +are saved in their own sub-directory, named after the target's triplet, in the +.I samples +sub-directory of the current directory. +If that was not clear: +.I `pwd`/samples/${CT_TARGET}/ + +Samples can be later recalled by calling +.B ct-ng +with the target triplet they represent. +." +.TP +.B build +Builds the configured toolchain. If +.B ct-ng +is called without action, then +.B build +is impiled. +." +.TP +.B liststeps +Lists all build steps available (see +.BR ENVIRONMENT, +below). +." +.TP +.B clean +Remove files generated by +.B ct-ng +for itself (these are mostly the configurators' binaries). +." +.TP +.B distclean +Same as +.B clean +, but also removes the toolchain build directory, the downloaded files and the +.I .config +configuration file. The generated toolchain is left untouched, as well as +samples which are not removed. +." +.TP +.B regtest +Calls the +.B ct-ng +regression test suite. All samples are build, and the regression test suite is +run against every one of them. +." +.TP +.B updatetools +Updates the +.I config.guess +and +.I config.sub +scripts. These scripts are used by +.B ct-ng +to canonicalise the machines' name (host, build and target machines). +.TP +.B tarball +Builds a tarball of the generated toolchain, also saving the scripts from +.B ct-ng +that are needed to rebuild the target, and also saving the tarballs of the +componnents that were used. +." +.SH ENVIRONMENT +.TP +.B STOP, START +Respectively stops and restarts the build just before this step. To restart a +step, a previous build should have run at least to that step, or further. + +The list of steps is vailable with the action +.BR liststeps . +." +.SH EXIT VALUE +The +.B ct-ng +frontend is in fact a +.BR make (1) +script. See the man page for +.BR make (1) +to have the meaning of the exit values. +." +.SH BUGS +As of today (@@CT_DATE@@), building tarballs is broken. It is difficult to +foresee how every parts of +.B ct-ng +are going to be installed. Each parts is needed to build a tarball, as it +contains all that is needed to rebuild the toolchain from scratch: toolchain +components' sources, +.B ct-ng +configuration, but also all +.B ct-ng +scripts. +." +.SH SECURITY +.B Don't run as root! +Great care has been taken to avoid mistakes, but bug-free programs don't +exist. During normal operation, +.B ct-ng +removes entire directories. If you run as root, and there is a bug or you +mis-configured +.BR ct-ng , +entire important directories could be removed (eg. +.IR /usr ), +although +.B ct-ng +will refuse to install in some well known critical directories. +." +.SH AUTHORS +.MTO "yann.morin.1998@anciens.enib.fr" "Yann E. MORIN" "" +.URL "http://ymorin.is-a-geek.org" "" "" +reordered +.B crosstool +(see section titled +.BR "SEE ALSO" ) +scripts to be more easily maintainable, added the Kconfig configurator, some +patches. + +Please consult the file +.I @@CT_DOCDIR@@/CREDITS +for a list of contributors. +." +.SH SEE ALSO +Please have a look at the +.URL "http://www.kegel.com/crosstool" "original crosstool" " by Daniel KEGEL" diff --git a/docs/overview.txt b/docs/overview.txt index cd5c9f7..14dc0a2 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -110,9 +110,9 @@ CT_TARGET: /opt/x-tools/${CT_TARGET} CT_TOP_DIR: - The top directory where crosstool-NG sits. You shouldn't need it in most - cases. There is one case where you may need it: if you have local patches - and you store them in your copy of crosstool-NG, you can refer to them + The top directory where crosstool-NG is running. You shouldn't need it in + most cases. There is one case where you may need it: if you have local + patches and you store them in your running directory, you can refer to them by using CT_TOP_DIR, such as: ${CT_TOP_DIR}/patches.myproject @@ -274,13 +274,13 @@ Makefile-based. Makefile front-end | -------------------* -The Makefile defines a set of rules to call each action. You can get the -list, along with some terse description, by typing "make help" in your -favourite command line. +To Be Written later... -The Makefile sets the version variable from the version file in ${CT_TOP_DIR} -which is then available to others in the CT_VERSION environment variable. +Kconfig parser | +---------------* The kconfig language is a hacked version, vampirised from the toybox project -by Rob LANDLEY (http://www.landley.net/code/toybox/), adapted to my needs. +by Rob LANDLEY (http://www.landley.net/code/toybox/), itself coming from the +Linux kernel (http://www.linux.org/ http://www.kernel.org/), and (heavily) +adapted to my needs. diff --git a/kconfig/Makefile b/kconfig/Makefile index 95446f1..8604b12 100644 --- a/kconfig/Makefile +++ b/kconfig/Makefile @@ -6,9 +6,8 @@ export PROJECTVERSION=$(CT_VERSION) KCONFIG_TOP = config/config.in -obj = ./kconfig -PHONY += clean help oldconfig menuconfig config silentoldconfig \ - randconfig allyesconfig allnoconfig allmodconfig defconfig +obj = $(CT_TOP_DIR)/kconfig +PHONY += clean help oldconfig menuconfig config defoldconfig # Darwin (MacOS-X) does not have proper libintl support ifeq ($(shell uname -s),Darwin) @@ -20,14 +19,21 @@ CFLAGS += -DKBUILD_NO_NLS endif # Build a list of all config files -CONFIG_FILES = $(filter-out %debug.in,$(shell find $(CT_TOP_DIR)/config -type f -name '*.in')) -DEBUG_CONFIG_FILES = $(shell find $(CT_TOP_DIR)/config/debug -type f -name '*.in') -TOOLS_CONFIG_FILES = $(shell find $(CT_TOP_DIR)/config/tools -type f -name '*.in') +DEBUG_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config/debug -type f -name '*.in') +TOOLS_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config/tools -type f -name '*.in') -GEN_CONFIG_FILES=$(CT_TOP_DIR)/config/debug.in \ - $(CT_TOP_DIR)/config/tools.in +STATIC_CONFIG_FILES = $(shell find $(CT_LIB_DIR)/config -type f -name '*.in') +GEN_CONFIG_FILES=$(CT_TOP_DIR)/config.gen/debug.in \ + $(CT_TOP_DIR)/config.gen/tools.in -$(CT_TOP_DIR)/config/debug.in: $(DEBUG_CONFIG_FILES) +CONFIG_FILES=$(STATIC_CONFIG_FILES) $(GEN_CONFIG_FILES) + +$(GEN_CONFIG_FILES):: $(CT_TOP_DIR)/config.gen + +$(CT_TOP_DIR)/config.gen: + @mkdir -p $(CT_TOP_DIR)/config.gen + +$(CT_TOP_DIR)/config.gen/debug.in:: $(DEBUG_CONFIG_FILES) @echo "# Debug facilities menu" >$@ @echo "# Generated file, do not edit!!!" >>$@ @echo "menu \"Debug facilities\"" >>$@ @@ -36,7 +42,7 @@ $(CT_TOP_DIR)/config/debug.in: $(DEBUG_CONFIG_FILES) done >>$@ @echo "endmenu" >>$@ -$(CT_TOP_DIR)/config/tools.in: $(TOOLS_CONFIG_FILES) +$(CT_TOP_DIR)/config.gen/tools.in:: $(TOOLS_CONFIG_FILES) @echo "# Tools facilities menu" >$@ @echo "# Generated file, do not edit!!!" >>$@ @echo "menu \"Tools facilities\"" >>$@ @@ -45,16 +51,21 @@ $(CT_TOP_DIR)/config/tools.in: $(TOOLS_CONFIG_FILES) done >>$@ @echo "endmenu" >>$@ -menuconfig: $(obj)/mconf $(GEN_CONFIG_FILES) +config menuconfig oldconfig defoldconfig:: $(KCONFIG_TOP) + +$(KCONFIG_TOP): + @ln -s $(CT_LIB_DIR)/config config + +menuconfig:: $(obj)/mconf $(CONFIG_FILES) @$< $(KCONFIG_TOP) -config: $(obj)/conf $(GEN_CONFIG_FILES) +config:: $(obj)/conf $(CONFIG_FILES) @$< $(KCONFIG_TOP) -oldconfig: $(obj)/conf $(GEN_CONFIG_FILES) +oldconfig:: $(obj)/conf $(CONFIG_FILES) @$< -s $(KCONFIG_TOP) -defoldconfig:$(obj)/conf $(GEN_CONFIG_FILES) +defoldconfig:: $(obj)/conf $(CONFIG_FILES) @yes "" |$< -s $(KCONFIG_TOP) >/dev/null # Help text used by make help @@ -65,18 +76,27 @@ help-config:: # Cheesy build -SHIPPED = kconfig/zconf.tab.c kconfig/lex.zconf.c kconfig/zconf.hash.c +SHIPPED = $(CT_LIB_DIR)/kconfig/zconf.tab.c $(CT_LIB_DIR)/kconfig/lex.zconf.c $(CT_LIB_DIR)/kconfig/zconf.hash.c %.c: %.c_shipped @ln -s $(notdir $<) $@ -kconfig/mconf: $(SHIPPED) kconfig/mconf.c - @$(HOST_CC) $(CFLAGS) -o $@ kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \ +$(obj)/conf $(obj)/mconf:: $(obj) + +$(obj): + @mkdir -p $(obj) + +$(obj)/mconf:: $(SHIPPED) $(CT_LIB_DIR)/kconfig/mconf.c + @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{mconf.c,zconf.tab.c,lxdialog/*.c} \ -lcurses "-DCURSES_LOC=" -kconfig/conf: $(SHIPPED) kconfig/conf.c - @$(HOST_CC) $(CFLAGS) -o $@ kconfig/{conf.c,zconf.tab.c} +$(obj)/conf:: $(SHIPPED) $(CT_LIB_DIR)/kconfig/conf.c + @$(HOST_CC) $(CFLAGS) -o $@ $(CT_LIB_DIR)/kconfig/{conf.c,zconf.tab.c} clean:: - @rm -f $(wildcard kconfig/*zconf*.c) kconfig/{conf,mconf} - @rm -f $(GEN_CONFIG_FILES) + @rm -f $(CT_TOP_DIR)/kconfig/{,m}conf + @rm -rf $(CT_TOP_DIR)/config.gen + +distclean:: + @rm -f $(CT_TOP_DIR)/config + @[ $(CT_LIB_DIR) = $(CT_TOP_DIR) ] || rm -rf $(CT_TOP_DIR)/kconfig diff --git a/samples/Makefile b/samples/Makefile index fb3f43b..6a3dc03 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -1,22 +1,31 @@ # Makefile to manage samples # Build the list of available samples -CT_SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config)) +CT_TOP_SAMPLES := $(patsubst $(CT_TOP_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_TOP_DIR)/samples/*/crosstool.config)) +CT_LIB_SAMPLES := $(filter-out $(CT_TOP_SAMPLES),$(patsubst $(CT_LIB_DIR)/samples/%/crosstool.config,%,$(wildcard $(CT_LIB_DIR)/samples/*/crosstool.config))) + +CT_SAMPLES := $(CT_TOP_SAMPLES) $(CT_LIB_SAMPLES) help-config:: @echo ' saveconfig - Save current config as a preconfigured target' help-samples:: - @$(CT_TOP_DIR)/scripts/showSamples.sh $(CT_SAMPLES) + @$(CT_LIB_DIR)/scripts/showSamples.sh $(CT_SAMPLES) help-build:: @echo ' regtest - Regtest-build all samples' # How we do build one sample -.PHONY: $(CT_SAMPLES) +PHONY += $(CT_SAMPLES) $(CT_SAMPLES): - @cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config" - @$(MAKE) oldconfig + @$(MAKE) -f $(CT_MAKEFILE) $(patsubst %,%_copy_config,$(@)) oldconfig + +$(patsubst %,%_copy_config,$(CT_SAMPLES)): + @if [ -f $(CT_TOP_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config ]; then \ + cp "$(CT_TOP_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ + else \ + cp "$(CT_LIB_DIR)/samples/$(patsubst %_copy_config,%,$(@))/crosstool.config" "$(CT_TOP_DIR)/.config"; \ + fi # And now for building all samples one after the other # We could use a simple rule like: 'regtest: $(CT_SAMPLES)', but that doesn't @@ -27,25 +36,25 @@ $(CT_SAMPLES): # Finaly, we can't use 'make sample-name' as we need to provide default values # if the options set has changed, but oldconfig does not like when stdin is # not a terminal (eg. it is a pipe). -.PHONY: regtest +PHONY += regtest regtest: @for samp in $(CT_SAMPLES); do \ echo -e "\rBuilding sample \"$${samp}\"" && \ - cp "$(CT_TOP_DIR)/samples/$${samp}/crosstool.config" "$(CT_TOP_DIR)/.config" && \ - yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1 && \ - sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config && \ + $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) $${samp}_copy_config && \ + yes "" |$(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) defoldconfig >/dev/null 2>&1 && \ + sed -i -r -e 's:^(CT_PREFIX_DIR=).*$$:\1"$${CT_TOP_DIR}/targets/tst/$${CT_TARGET}":;' .config && \ sed -i -r -e 's:^.*(CT_LOG_(WARN|INFO|EXTRA|DEBUG|ALL)).*$$:# \1 is not set:;' .config && \ sed -i -r -e 's:^.*(CT_LOG_ERROR).*$$:\1=y:;' .config && \ sed -i -r -e 's:^(CT_LOG_LEVEL_MAX)=.*$$:\1="ERROR":;' .config && \ sed -i -r -e 's:^.*(CT_LOG_TO_FILE).*$$:\1=y:;' .config && \ sed -i -r -e 's:^.*(CT_LOG_PROGRESS_BAR).*$$:\1=y:;' .config && \ - yes "" |make -C $(CT_TOP_DIR) defoldconfig >/dev/null 2>&1 && \ - make -C $(CT_TOP_DIR) && \ + yes "" |$(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) defoldconfig >/dev/null 2>&1 && \ + $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) && \ echo -e "\rMaking tarball for sample \"$${samp}\"" && \ - make -C $(CT_TOP_DIR) tarball; \ - echo -e "\rCleaning sample \"$${samp}\""; \ - make -C $(CT_TOP_DIR) distclean; \ + $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) tarball ; \ + echo -e "\rCleaning sample \"$${samp}\"" ; \ + $(MAKE) -C $(CT_TOP_DIR) -f $(CT_MAKEFILE) distclean ; \ done saveconfig: - $(CT_TOP_DIR)/scripts/saveSample.sh + $(CT_LIB_DIR)/scripts/saveSample.sh diff --git a/scripts/build/debug.sh b/scripts/build/debug.sh index 4a3a6cf..d2cca62 100644 --- a/scripts/build/debug.sh +++ b/scripts/build/debug.sh @@ -2,7 +2,7 @@ # List all debug facilities, and parse their scripts CT_DEBUG_FACILITY_LIST= -for f in "${CT_TOP_DIR}/scripts/build/debug/"*.sh; do +for f in "${CT_LIB_DIR}/scripts/build/debug/"*.sh; do is_enabled= . "${f}" f=`basename "${f}" .sh` diff --git a/scripts/build/tools.sh b/scripts/build/tools.sh index ebc8131..e61b16f 100644 --- a/scripts/build/tools.sh +++ b/scripts/build/tools.sh @@ -2,7 +2,7 @@ # List all tools facilities, and parse their scripts CT_TOOLS_FACILITY_LIST= -for f in "${CT_TOP_DIR}/scripts/build/tools/"*.sh; do +for f in "${CT_LIB_DIR}/scripts/build/tools/"*.sh; do is_enabled= . "${f}" f=`basename "${f}" .sh` diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh index 9b0fd95..4e4f294 100755 --- a/scripts/crosstool.sh +++ b/scripts/crosstool.sh @@ -12,17 +12,8 @@ # options. It also checks the existing environment for un-friendly variables, # and builds the tools. -# CT_TOP_DIR is set by the makefile. If we don't have it, something's gone horribly wrong... -if [ -z "${CT_TOP_DIR}" -o ! -d "${CT_TOP_DIR}" ]; then - # We don't have the functions right now, because we don't have CT_TOP_DIR. - # Do the print stuff by hand: - echo "CT_TOP_DIR not set, or not a directory. Something's gone horribly wrong." - echo "Please send a bug report (see README)" - exit 1 -fi - # Parse the common functions -. "${CT_TOP_DIR}/scripts/functions" +. "${CT_LIB_DIR}/scripts/functions" CT_STAR_DATE=`CT_DoDate +%s%N` CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S` @@ -41,7 +32,7 @@ renice ${CT_NICE} $$ |CT_DoLog DEBUG CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" CT_DoStep DEBUG "Dumping crosstool-NG configuration" -cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG +cat "${CT_TOP_DIR}/.config" |egrep '^(# |)CT_' |CT_DoLog DEBUG CT_EndStep # Some sanity checks in the environment and needed tools @@ -143,7 +134,7 @@ CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"` CT_SYS_MACHINE=`uname -m` CT_SYS_PROCESSOR=`uname -p` CT_SYS_GCC=`gcc -dumpversion` -CT_SYS_TARGET=`${CT_TOP_DIR}/tools/config.guess` +CT_SYS_TARGET=`CT_DoConfigGuess` CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}" CT_DoLog EXTRA "Preparing working directories" @@ -225,7 +216,8 @@ esac if [ -z "${CT_RESTART}" ]; then # Determine build system if not set by the user CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}" - CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`" + CT_BUILD="${CT_BUILD:-`CT_DoConfigGuess`}" + CT_BUILD=`CT_DoConfigSub "${CT_BUILD}"` # Arrange paths depending on wether we use sys-root or not. if [ "${CT_USE_SYSROOT}" = "y" ]; then @@ -345,14 +337,14 @@ fi # Include sub-scripts instead of calling them: that way, we do not have to # export any variable, nor re-parse the configuration and functions files. -. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh" -. "${CT_TOP_DIR}/scripts/build/binutils.sh" -. "${CT_TOP_DIR}/scripts/build/libfloat.sh" -. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh" -. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh" -. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh" -. "${CT_TOP_DIR}/scripts/build/debug.sh" -. "${CT_TOP_DIR}/scripts/build/tools.sh" +. "${CT_LIB_DIR}/scripts/build/kernel_${CT_KERNEL}.sh" +. "${CT_LIB_DIR}/scripts/build/binutils.sh" +. "${CT_LIB_DIR}/scripts/build/libfloat.sh" +. "${CT_LIB_DIR}/scripts/build/libc_${CT_LIBC}.sh" +. "${CT_LIB_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh" +. "${CT_LIB_DIR}/scripts/build/cc_${CT_CC}.sh" +. "${CT_LIB_DIR}/scripts/build/debug.sh" +. "${CT_LIB_DIR}/scripts/build/tools.sh" if [ -z "${CT_RESTART}" ]; then CT_DoStep INFO "Retrieving needed toolchain components' tarballs" diff --git a/scripts/functions b/scripts/functions index d66fe22..18ee969 100644 --- a/scripts/functions +++ b/scripts/functions @@ -425,7 +425,9 @@ CT_ExtractAndPatch() { cd "${file}" fi - [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}" + official_patch_dir= + custom_patch_dir= + [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_LIB_DIR}/patches/${base_file}/${ver_file}" [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}" for patch_dir in "${official_patch_dir}" "${custom_patch_dir}"; do if [ -n "${patch_dir}" -a -d "${patch_dir}" ]; then @@ -442,6 +444,24 @@ CT_ExtractAndPatch() { CT_Popd } +# Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR. +# Those from CT_TOP_DIR, if they exist, will be be more recent than those from CT_LIB_DIR. +CT_DoConfigGuess() { + if [ -x "${CT_TOP_DIR}/tools/config.guess" ]; then + "${CT_TOP_DIR}/tools/config.guess" + else + "${CT_LIB_DIR}/tools/config.guess" + fi +} + +CT_DoConfigSub() { + if [ -x "${CT_TOP_DIR}/tools/config.sub" ]; then + "${CT_TOP_DIR}/tools/config.sub" "$@" + else + "${CT_LIB_DIR}/tools/config.sub" "$@" + fi +} + # Compute the target triplet from what is provided by the user # Usage: CT_DoBuildTargetTriplet # In fact this function takes the environment variables to build the target @@ -482,7 +502,7 @@ CT_DoBuildTargetTriplet() { glibc) CT_TARGET="${CT_TARGET}-gnu";; uClibc) CT_TARGET="${CT_TARGET}-uclibc";; esac - CT_TARGET="`${CT_TOP_DIR}/tools/config.sub ${CT_TARGET}`" + CT_TARGET=`CT_DoConfigSub "${CT_TARGET}"` } # This function does pause the build until the user strikes "Return" diff --git a/scripts/saveSample.sh b/scripts/saveSample.sh index 7a5b57c..4aee0eb 100755 --- a/scripts/saveSample.sh +++ b/scripts/saveSample.sh @@ -8,7 +8,7 @@ # - the kernel .config file if specified # - the uClibc .config file if uClibc selected -. "${CT_TOP_DIR}/scripts/functions" +. "${CT_LIB_DIR}/scripts/functions" # Don't care about any log file exec >/dev/null @@ -31,12 +31,8 @@ CT_LOG_INFO=y CT_LOG_LEVEL_MAX="INFO" # Create the sample directory -# In case it was manually made, add it to svn -if [ -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then - # svn won't fail when adding a directory already managed by svn - svn add "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1 -else - svn mkdir "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1 +if [ ! -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ]; then + mkdir -p "${CT_TOP_DIR}/samples/${CT_TARGET}" fi # Save the crosstool-NG config file @@ -53,19 +49,24 @@ CT_DoAddFileToSample() { if [ "${inode_s}" != "${inode_d}" ]; then cp "${source}" "${dest}" fi - svn add "${dest}" >/dev/null 2>&1 } +if [ "${CT_TOP_DIR}" = "${CT_LIB_DIR}" ]; then + samp_top_dir="\${CT_LIB_DIR}" +else + samp_top_dir="\${CT_TOP_DIR}" +fi + # Save the kernel .config file if [ -n "${CT_KERNEL_LINUX_CONFIG_FILE}" ]; then # We save the file, and then point the saved sample to this file CT_DoAddFileToSample "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config" - sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \ + sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \ "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" else # remove any dangling files for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-"*.config; do - if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi + if [ -f "${f}" ]; then rm -f "${f}"; fi done fi @@ -73,17 +74,11 @@ fi if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then # We save the file, and then point the saved sample to this file CT_DoAddFileToSample "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config" - sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \ + sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"'"${samp_top_dir}"'/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \ "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" else # remove any dangling files for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-"*.config; do - if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi + if [ -f "${f}" ]; then rm -f "${f}"; fi done fi - -# We could svn add earlier, but it's better to -# add a frozen file than modifying it later -svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" >/dev/null 2>&1 - -svn stat "${CT_TOP_DIR}/samples/${CT_TARGET}" 2>/dev/null |CT_DoLog INFO diff --git a/scripts/showSamples.sh b/scripts/showSamples.sh index ac05e91..f814940 100755 --- a/scripts/showSamples.sh +++ b/scripts/showSamples.sh @@ -10,9 +10,16 @@ export GREP_OPTIONS= dump_single_sample() { local width="$1" local sample="$2" - printf " %-*s" ${width} "${sample}" - [ -f "${CT_TOP_DIR}/samples/${sample}/broken" ] && printf " (broken)" - echo + if [ -f "${CT_TOP_DIR}/samples/${sample}/crosstool.config" ]; then + sample_top="${CT_TOP_DIR}" + sample_type="local" + else + sample_top="${CT_LIB_DIR}" + sample_type="global" + fi + printf " %-*s (%s" ${width} "${sample}" "${sample_type}" + [ -f "${sample_top}/samples/${sample}/broken" ] && printf ",broken" + echo ")" } # Get largest sample width diff --git a/scripts/tarball.sh b/scripts/tarball.sh deleted file mode 100755 index 8e6c312..0000000 --- a/scripts/tarball.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash - -# This scripts makes a tarball of the configured toolchain -# Pre-requisites: -# - crosstool-NG is configured -# - components tarball are available -# - toolchain is built successfully - -# We need the functions first: -. "${CT_TOP_DIR}/scripts/functions" - -# Don't care about any log file -exec >/dev/null -rm -f "${tmp_log_file}" - -# Parse the configuration file: -. ${CT_TOP_DIR}/.config - -CT_DoBuildTargetTriplet - -# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR, -# re-parse them: -. "${CT_TOP_DIR}/.config" - -# Build a one-line list of files to include -CT_DoStep DEBUG "Building list of tarballs to add" -CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs" -CT_TARBALLS="" -for dir in '' tools debug; do - CT_DoStep DEBUG "Scanning directory \"${dir}\"" - for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do - CT_DoStep DEBUG "Testing component \"${script}\"" - [ -n "${script}" ] || continue - unset do_print_file_name - . "${script}" - for file in `do_print_filename`; do - CT_DoLog DEBUG "Finding tarball for \"${file}\"" - [ -n "${file}" ] || continue - ext=`CT_GetFileExtension "${file}"` - CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}" - CT_DoLog DEBUG "Found \"${file}${ext}\"" - CT_TARBALLS="${CT_TARBALLS} ${file}${ext}" - done - CT_EndStep - done - CT_EndStep -done -CT_EndStep - -# We need to emulate a build directory: -CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build" -mkdir -p "${CT_BUILD_DIR}" -CT_MktempDir tempdir - -# Save crosstool-ng, as it is configured for the current toolchain. -topdir=`basename "${CT_TOP_DIR}"` -CT_Pushd "${CT_TOP_DIR}/.." - -botdir=`pwd` - -# Build the list of files to exclude -CT_DoLog DEBUG "Building list of files to exclude" -exclude_list="${tempdir}/${CT_TARGET}.list" -{ echo ".svn"; \ - echo "${topdir}/log.*"; \ - echo "${topdir}/targets/src"; \ - echo "${topdir}/targets/tst"; \ - echo "${topdir}/targets/*-*-*-*"; \ - for t in `ls -1 "${topdir}/targets/tarballs/"`; do \ - case " ${CT_TARBALLS} " in \ - *" ${t} "*) ;; \ - *) echo "${topdir}/targets/tarballs/${t}";; \ - esac; \ - done; \ -} >"${exclude_list}" - -# Render the install directory writable -chmod u+w "${CT_PREFIX_DIR}" - -CT_DoLog INFO "Saving crosstool-ng into the toolchain directory" -tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" \ - --no-wildcards-match-slash \ - -X "${exclude_list}" \ - "${topdir}" 2>&1 |CT_DoLog ALL - -CT_Popd - -CT_DoLog INFO "Saving the toolchain" -tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}" 2>&1 |CT_DoLog ALL - -CT_DoLog DEBUG "Getting rid of working directories" -rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" -rm -rf "${tempdir}" - -if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then - # Render the install directory non-writable - chmod u-w "${CT_PREFIX_DIR}" -fi diff --git a/scripts/tarball.sh.broken b/scripts/tarball.sh.broken new file mode 100755 index 0000000..8e6c312 --- /dev/null +++ b/scripts/tarball.sh.broken @@ -0,0 +1,98 @@ +#!/bin/bash + +# This scripts makes a tarball of the configured toolchain +# Pre-requisites: +# - crosstool-NG is configured +# - components tarball are available +# - toolchain is built successfully + +# We need the functions first: +. "${CT_TOP_DIR}/scripts/functions" + +# Don't care about any log file +exec >/dev/null +rm -f "${tmp_log_file}" + +# Parse the configuration file: +. ${CT_TOP_DIR}/.config + +CT_DoBuildTargetTriplet + +# Kludge: if any of the config options needs either CT_TARGET or CT_TOP_DIR, +# re-parse them: +. "${CT_TOP_DIR}/.config" + +# Build a one-line list of files to include +CT_DoStep DEBUG "Building list of tarballs to add" +CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs" +CT_TARBALLS="" +for dir in '' tools debug; do + CT_DoStep DEBUG "Scanning directory \"${dir}\"" + for script in "${CT_TOP_DIR}/scripts/build/${dir}/"*.sh; do + CT_DoStep DEBUG "Testing component \"${script}\"" + [ -n "${script}" ] || continue + unset do_print_file_name + . "${script}" + for file in `do_print_filename`; do + CT_DoLog DEBUG "Finding tarball for \"${file}\"" + [ -n "${file}" ] || continue + ext=`CT_GetFileExtension "${file}"` + CT_TestOrAbort "Missing tarball for: \"${file}\"" -f "${CT_TOP_DIR}/targets/tarballs/${file}${ext}" + CT_DoLog DEBUG "Found \"${file}${ext}\"" + CT_TARBALLS="${CT_TARBALLS} ${file}${ext}" + done + CT_EndStep + done + CT_EndStep +done +CT_EndStep + +# We need to emulate a build directory: +CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build" +mkdir -p "${CT_BUILD_DIR}" +CT_MktempDir tempdir + +# Save crosstool-ng, as it is configured for the current toolchain. +topdir=`basename "${CT_TOP_DIR}"` +CT_Pushd "${CT_TOP_DIR}/.." + +botdir=`pwd` + +# Build the list of files to exclude +CT_DoLog DEBUG "Building list of files to exclude" +exclude_list="${tempdir}/${CT_TARGET}.list" +{ echo ".svn"; \ + echo "${topdir}/log.*"; \ + echo "${topdir}/targets/src"; \ + echo "${topdir}/targets/tst"; \ + echo "${topdir}/targets/*-*-*-*"; \ + for t in `ls -1 "${topdir}/targets/tarballs/"`; do \ + case " ${CT_TARBALLS} " in \ + *" ${t} "*) ;; \ + *) echo "${topdir}/targets/tarballs/${t}";; \ + esac; \ + done; \ +} >"${exclude_list}" + +# Render the install directory writable +chmod u+w "${CT_PREFIX_DIR}" + +CT_DoLog INFO "Saving crosstool-ng into the toolchain directory" +tar cvjf "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" \ + --no-wildcards-match-slash \ + -X "${exclude_list}" \ + "${topdir}" 2>&1 |CT_DoLog ALL + +CT_Popd + +CT_DoLog INFO "Saving the toolchain" +tar cvjf "${botdir}/${CT_TARGET}.tar.bz2" "${CT_PREFIX_DIR}" 2>&1 |CT_DoLog ALL + +CT_DoLog DEBUG "Getting rid of working directories" +rm -f "${CT_PREFIX_DIR}/${topdir}.${CT_TARGET}.tar.bzip2" +rm -rf "${tempdir}" + +if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then + # Render the install directory non-writable + chmod u-w "${CT_PREFIX_DIR}" +fi diff --git a/tools/Makefile b/tools/Makefile index 9985e3a..72416b8 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,11 +1,31 @@ +# Makefile for the tools/ sub-directory + +# Here, we can update the config.* scripts. +# If we're in CT_LIB_DIR, then CT_LIB_DIR == CT_TOP_DIR, and we can update those +# scripts for later inclusion mainline. If CT_LIB_DIR != CT_TOP_DIR, then those +# scripts are downloaded only for use in CT_TOP_DIR. + CONFIG_SUB_SRC="http://cvs.savannah.gnu.org/viewcvs/*checkout*/config/config/config.sub" CONFIG_SUB_DEST="$(CT_TOP_DIR)/tools/config.sub" CONFIG_GUESS_SRC="http://cvs.savannah.gnu.org/viewcvs/*checkout*/config/config/config.guess" CONFIG_GUESS_DEST="$(CT_TOP_DIR)/tools/config.guess" -updatetools: - @wget "$(CONFIG_SUB_SRC)" -O "$(CONFIG_SUB_DEST)" - @wget "$(CONFIG_GUESS_SRC)" -O "$(CONFIG_GUESS_DEST)" +$(CT_TOP_DIR)/tools: + @mkdir -p $(CT_TOP_DIR)/tools + +PHONY += updatetools +updatetools: $(CT_TOP_DIR)/tools $(CONFIG_SUB_DEST) $(CONFIG_GUESS_DEST) + +$(CONFIG_SUB_DEST): + @wget $(CONFIG_SUB_SRC) -O $@ + @chmod u+rwx,go+rx-w $@ + +$(CONFIG_GUESS_DEST): + @wget $(CONFIG_GUESS_SRC) -O $@ + @chmod u+rwx,go+rx-w $@ help-distrib:: @echo ' updatetools - Update the config tools' + +distclean:: + @[ $(CT_TOP_DIR) = $(CT_LIB_DIR) ] || rm -rf $(CT_TOP_DIR)/tools -- cgit v0.10.2-6-g49f6