Compare commits

..

22 Commits
master ... 1.4

Author SHA1 Message Date
Yann E. MORIN" 96d6087098 1.4: close branch 13 years ago
Yann E. MORIN" a839b5879c Tagging release 1.4.2 14 years ago
Yann E. MORIN" b864881d4a 1.4: update version to 1.4.2 14 years ago
Oron Peled fccc3ab4c0 [complib:mpfr] Fix building MPFR in some weird cases
The tmul test uses a compiled-in input file in $(srcdir).
The problem is that the Makefile passes it unquoted. The C code
tries to stringify it using clever macros, which may *usually* work.

In my case the source directory was named:
.../toolchain-powerpc-e500v2-linux-gnuspe-1.0-2.fc10/.../tests
And guess what? During testing I found out the program fails because
it tries to open:
.../toolchain-powerpc-e500v2-1-gnuspe-1.0-2.fc10/.../tests

Yes, CPP tokenized the macro before stringifying it and not surprisingly
the 'linux' part was converted to 1.
[on Fedora-10: cpp (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)]

So the attached patch simplify the macros and pass the path as string
from the Makefile.

Manually backported from 1449:8ad2773e7ae3
14 years ago
Oron Peled 803599b4bd [configure] Fix automake version check
The configure script fails on automake-1.11 (in Fedora-11) since
it looks for 3-digit version number.

"Yann E. MORIN", added the following comment:

The check for the automake version is not against a 3-digit number,
but really against a 3-part version number, a-la 'x.y.z'. Versions
such as 1.10 and 1.11 are also valid.
14 years ago
Yann E. MORIN" 790b15a352 Fix creating the .../lib/ directory structure in the non-sysroot case
The symbol link that is created in the sysroot directory only needs
to be made when the cross compiler is build with the sysroot option

Signed-off-by: Bart van der Meulen <bartvdrmeulen@gmail.com>
(transplanted from 0e49e6eddac4f5bbde6394eb3e6e36be75fc550c)
14 years ago
Yann E. MORIN" c3ad474734 Also set CT_DEBUGROOT_DIR for non sysroot-ed toolchains.
In the non-sysroot-ed case, the debuf-root directory would not be set;
debug tools would have been installed God-only-knows-where...

Spotted by Bart van der Meulen <bartvdrmeulen@gmail.com>.
(transplanted from 634ffd14d936154464fd714ed29ed44c8e16ae02)
14 years ago
Yann E. MORIN" f261ec42de Add .hgignore file.
List all generated or temp files in .hgignore, so they
don't clutter the screen when running hg status.
(transplanted from befdb88324e18e1e80260906d0459a56ea0eb37a)
14 years ago
Yann E. MORIN" 28eca3e8d0 populate: fix installing dynamic linker 'ld.so'
The dynamic linker, ld.so, needs the execute bit to be set.
Detect tht the library being installed is in fact ld.so and
install it with 0755 instead of 0644.

Fix detecting src == dst.

Use a simpler command to copy src -> dst.

Also change echo to printf, get rid of 'echo -n', which is
highly non-portable.


 -------- diffstat follows --------
 /trunk/scripts/populate.in |   76    43    33     0 +++++++++++++++++++++++++++++-----------------------
 1 file changed, 43 insertions(+), 33 deletions(-)
(transplanted from d7ddcb75e0f703e2ba6d17169167356389224870)
14 years ago
Yann E. MORIN" e76e47b650 [configure] Use hg, instead of svn, to compute the version string
Now we moved from Subversion to Mercurial, use the hg command to
compute the version string.

Manually backported from 1409:7264ce426be4 plus 1430:933eee133cbf
as too much changes have been made to ./configure in the meantime.
14 years ago
Yann E. MORIN" 6841b1f9ec 1.4: backport 1538 from /trunk:
- fix gdb 6.8 frame handling

 -------- diffstat follows --------
 No data available: not in a working copy, and/or direct repo->repo move, cp...
14 years ago
Yann E. MORIN" afd70c9914 1.4: update version to 1.4.1+svn.
-------- diffstat follows --------
 /branches/1.4/.version |    2     1     1     0 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
14 years ago
Yann E. MORIN" 36f6713580 1.4: update version to 1.4.1.
-------- diffstat follows --------
 /branches/1.4/.version |    2     1     1     0 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
14 years ago
Yann E. MORIN" 170db5c2ed 1.4: backport #1519 from /trunk:
- sstrip: update the upstream URL, now buildroot has migrated to
  using git instead of svn.

 -------- diffstat follows --------
 /branches/1.4/scripts/build/tools/200-sstrip.sh |   11     8     3     0 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
14 years ago
Yann E. MORIN" c3dec35321 1.4: backport #1496 from /trunk:
- For glibc & eglibc, try to auto-select the ports addon for those
  architectures that require it (curently, ARM and MIPS are known to).

 -------- diffstat follows --------
 /branches/1.4/config/libc/glibc-eglibc.in-common |    9     8     1     0 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
14 years ago
Yann E. MORIN" 5d8855f2e4 1.4: backport #1495 from /trunk:
- Force getting glibc>=2.8 via checkout if any addon is selected.

 -------- diffstat follows --------
 /branches/1.4/config/libc/glibc.in               |    7     7     0     0 +++++++
 /branches/1.4/config/libc/glibc-eglibc.in-common |    6     6     0     0 ++++++
 2 files changed, 13 insertions(+)
14 years ago
Yann E. MORIN" 6e38f97f97 1.4: update version to 1.4.0+svn.
-------- diffstat follows --------
 /branches/1.4/.version |    2     1     1     0 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
14 years ago
Yann E. MORIN" 672d06d38d 1.4: update version to 1.4.0.
-------- diffstat follows --------
 /branches/1.4/.version |    2     1     1     0 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
14 years ago
Yann E. MORIN" a209425d19 1.4:
- mark the i686-nptl-linux-gnu sample as being broken.
- update known issues about seemingly native toolchains
  not building, using that sample as example.

 -------- diffstat follows --------
 /branches/1.4/docs/known-issues.txt |    5     4     1     0 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
14 years ago
Yann E. MORIN" 9f72946580 1.4: update all samples.
-------- diffstat follows --------
 /branches/1.4/samples/armeb-unknown-linux-uclibc/crosstool.config        |   25     2    23     0 +---------
 /branches/1.4/samples/sh4-unknown-linux-gnu/crosstool.config             |   25     2    23     0 +---------
 /branches/1.4/samples/x86_64-unknown-linux-gnu/crosstool.config          |   25     2    23     0 +---------
 /branches/1.4/samples/arm-unknown-linux-gnueabi/crosstool.config         |   25     2    23     0 +---------
 /branches/1.4/samples/ia64-unknown-linux-gnu/crosstool.config            |   25     2    23     0 +---------
 /branches/1.4/samples/x86_64-unknown-linux-uclibc/crosstool.config       |   25     2    23     0 +---------
 /branches/1.4/samples/armeb-unknown-linux-gnueabi/crosstool.config       |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc-e500v2-linux-gnuspe/crosstool.config       |   25     2    23     0 +---------
 /branches/1.4/samples/i686-nptl-linux-gnu/crosstool.config               |   25     2    23     0 +---------
 /branches/1.4/samples/arm-unknown-linux-gnu/crosstool.config             |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc-unknown-linux-gnu/crosstool.config         |   25     2    23     0 +---------
 /branches/1.4/samples/mips-unknown-linux-uclibc/crosstool.config         |   25     2    23     0 +---------
 /branches/1.4/samples/arm-unknown-linux-uclibcgnueabi/crosstool.config   |   25     2    23     0 +---------
 /branches/1.4/samples/arm-iphone-linux-gnueabi/crosstool.config          |   31     5    26     0 ++-----------
 /branches/1.4/samples/armeb-unknown-linux-gnu/crosstool.config           |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc-unknown_nofpu-linux-gnu/crosstool.config   |   25     2    23     0 +---------
 /branches/1.4/samples/i586-geode-linux-uclibc/crosstool.config           |   25     2    23     0 +---------
 /branches/1.4/samples/arm-unknown-linux-uclibc/crosstool.config          |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc-unknown-linux-uclibc/crosstool.config      |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc-405-linux-gnu/crosstool.config             |   25     2    23     0 +---------
 /branches/1.4/samples/armeb-unknown-linux-uclibcgnueabi/crosstool.config |   25     2    23     0 +---------
 /branches/1.4/samples/mipsel-unknown-linux-gnu/crosstool.config          |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc64-unknown-linux-gnu/crosstool.config       |   25     2    23     0 +---------
 /branches/1.4/samples/alphaev56-unknown-linux-gnu/crosstool.config       |   25     2    23     0 +---------
 /branches/1.4/samples/powerpc-860-linux-gnu/crosstool.config             |   25     2    23     0 +---------
 25 files changed, 53 insertions(+), 578 deletions(-)
14 years ago
Yann E. MORIN" 561488f051 1.4: small documentation fix.
-------- diffstat follows --------
 /branches/1.4/docs/overview.txt |    1     0     1     0 -
 1 file changed, 1 deletion(-)
14 years ago
Yann E. MORIN" 58764da6e1 Create the 1.4 maintenance branch.
-------- diffstat follows --------
 No data available: not in a working copy)
14 years ago

@ -1,27 +0,0 @@
name: Build kvx-elf and kvx-linux
on: [push]
jobs:
build:
strategy:
matrix:
os: [ubuntu-16.04,ubuntu-18.04]
target: [kvx-unknown-elf, kvx-unknown-linux-uclibc]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- name: Install packages
run: sudo apt-get install bison flex libncurses5-dev texinfo help2man g++ libtool-bin
- name: Configure CTNG
run: ./bootstrap && ./configure --enable-local
- name: Build CTNG
run: make
- name: Configure ${{ matrix.target }}
run: ./ct-ng ${{ matrix.target }}
- name: Patch config
run: sed -i -e 's/^.*\(CT_LOG_PROGRESS_BAR\).*$/# \1 is not set/' .config
- name: Build ${{ matrix.target }}
run: ./ct-ng build

45
.gitignore vendored

@ -1,45 +0,0 @@
# Generated files
configure
autom4te.cache
aclocal.m4
config.h*
config.log
config.status
Makefile
Makefile.in
ct-ng
!ct-ng.comp
!ct-ng.in
paths.sh
config/configure.in
config/gen/
config/versions/
.config
.config.*
verbatim-data.mk
maintainer/package-versions
# Compressed files
*.tar*
*.zip
*.xz
*.7zip
# Temporaries
.*.swp
build.log
.config.old
temp.*
stamp-h1
# Testing
testing/docker/*/build
testing/docker/*/install
testing/docker/*/xtools
# This is the place where toolchains are built
.build/
# .. and log for 'build-all'
.build-all/
# .. and release creation
release/

@ -0,0 +1,25 @@
syntax: glob
# Generated files
Makefile
ct-ng
docs/ct-ng.1
docs/ct-ng.1.gz
paths.mk
scripts/crosstool-NG.sh
scripts/saveSample.sh
scripts/showTuple.sh
# Temporaries
.*.swp
log.*
# Working files
kconfig/conf
kconfig/mconf
kconfig/**.o
kconfig/**.dep
config.gen/
.config
.config.old
targets/

@ -0,0 +1 @@
366b6c794c70f1a3387c0b2578d3300d5a36bee4 crosstool-ng-1.4.2

@ -0,0 +1 @@
1.4.2

@ -1,105 +0,0 @@
## Process this file with automake to produce Makefile.in
## vim: set noet :
include verbatim-data.mk
SUBDIRS = kconfig
bin_SCRIPTS = ct-ng
CLEANFILES = ct-ng bash-completion/ct-ng docs/ct-ng.1
EXTRA_DIST = bootstrap ct-ng.in bash-completion/ct-ng.in \
docs/ct-ng.1.in packages maintainer testing
if INSTALL_BASH_COMPLETION
compdir = @BASH_COMPLETION_DIR@
comp_SCRIPTS = bash-completion/ct-ng
endif
man1_MANS = docs/ct-ng.1
# paths.sh and configure.in are generated by configure
nobase_dist_pkgdata_DATA = $(verbatim_data)
nobase_nodist_pkgdata_DATA = paths.sh config/configure.in
# ct-ng, as renamed by the installation
ctng_progname = `echo ct-ng | sed '$(transform)'`
USER_MANUAL_FILES = \
docs/manual/1_Introduction.md \
docs/manual/2_Installation.md \
docs/manual/3_Configuration.md \
docs/manual/4_Building.md \
docs/manual/5_Toolchain_Usage.md \
docs/manual/6_Toolchain_Types.md \
docs/manual/7_Contributing.md \
docs/manual/8_Internals.md \
docs/manual/9_Toolchain_Construction.md \
docs/manual/A_Credits.md \
docs/manual/B_Known_issues.md \
docs/manual/C_Setup_OS.md \
docs/manual/D_Tutorials_features.md
if INSTALL_USER_MANUAL
doc_DATA = $(USER_MANUAL_FILES)
else
doc_DATA = docs/MANUAL_ONLINE
endif
do_subst = ( @SED@ \
-e 's,[@]docdir[@],$(docdir),g' \
-e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
-e 's,[@]pkglibexecdir[@],$(pkglibexecdir),g' \
-e 's,[@]progname[@],'$(ctng_progname)',g' \
| $(SHELL) config.status --file=- )
ct-ng: ct-ng.in Makefile
$(AM_V_GEN)$(do_subst) < $< >$@-t && chmod a-w,a+x $@-t && mv -f $@-t $@
docs/ct-ng.1: docs/ct-ng.1.in Makefile
$(AM_V_GEN)$(MKDIR_P) docs && $(do_subst) < $< >$@-t && mv -f $@-t $@
bash-completion/ct-ng: bash-completion/ct-ng.in Makefile
$(AM_V_GEN)$(MKDIR_P) bash-completion && $(do_subst) < $< >$@-t && mv -f $@-t $@
# automake doesn't offer an option to compress manpages, do it after installation
# Also, lintian is picky about execute-bit on the scripts
install-data-hook:
rm -f $(DESTDIR)$(man1dir)/$(ctng_progname).1.gz
gzip -9 $(DESTDIR)$(man1dir)/$(ctng_progname).1
chmod a+x $(DESTDIR)$(pkgdatadir)/scripts/config.guess
chmod a+x $(DESTDIR)$(pkgdatadir)/scripts/config.sub
rm -f $(DESTDIR)$(pkgdatadir)/LICENSE
ln -s COPYING $(DESTDIR)$(pkgdatadir)/LICENSE
if INSTALL_BASH_COMPLETION
chmod a-x $(DESTDIR)$(compdir)/$(ctng_progname)
endif
uninstall-hook:
rm -f $(DESTDIR)$(man1dir)/$(ctng_progname).1.gz
dist-hook: fetch-docs create-symlinks gen-tarball-version
.PHONY: fetch-docs
fetch-docs: maintainer/download-docs.sh
$< $(top_distdir) $(USER_MANUAL_FILES)
.PHONY: create-symlinks
create-symlinks:
ln -s COPYING $(top_distdir)/LICENSE
.PHONY: gen-tarball-version
gen-tarball-version:
echo $(VERSION) > $(distdir)/.tarball-version
DIGESTS ?= md5 sha1 sha512
USE_GPG ?= yes
dist-create-release: distcheck
for a in $(DIST_ARCHIVES); do \
for d in $(DIGESTS); do \
$${d}sum $${a} > $${a}.$${d}; \
done; \
if [ "$(USE_GPG)" = "yes" ]; then \
gpg --detach-sign $${a}; \
fi; \
done

@ -0,0 +1,257 @@
# Makefile.in for building crosstool-NG
# This file serves as source for the ./configure operation
# This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS
# to set additional flags in the current Makfile ( see:
# http://savannah.gnu.org/bugs/?20501 ), although the make manual says it
# should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion )
# so we have to work it around by calling ourselves back if needed
# So why do we need not to use the built rules and variables? Because we
# need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in
# and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite
# nor a command associated, and that built-in implicit rule takes precedence
# over our non-built-in implicit rule '%: %.in', below.
# CT_MAKEFLAGS will be used later, below...
# Do not print directories as we descend into them
ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
CT_MAKEFLAGS += --no-print-directory
endif
# Use neither builtin rules, nor builtin variables
# Note: dual test, because if -R and -r are given on the command line
# (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding
# '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' )
ifeq ($(filter Rr,$(MAKEFLAGS)),)
ifeq ($(filter -Rr,$(MAKEFLAGS)),)
CT_MAKEFLAGS += -Rr
endif # No -Rr
endif # No Rr
# Remove any suffix rules
.SUFFIXES:
all: Makefile build
###############################################################################
# Configuration variables
VERSION:= @@VERSION@@
BINDIR := @@BINDIR@@
LIBDIR := @@LIBDIR@@
DOCDIR := @@DOCDIR@@
MANDIR := @@MANDIR@@
DATE := @@DATE@@
LOCAL := @@LOCAL@@
# Paths found by ./configure
install:= @@install@@
bash := @@bash@@
grep := @@grep@@
make := @@make@@
sed := @@sed@@
###############################################################################
# Sanity checks
# Check if Makefile is up to date:
Makefile: Makefile.in
@echo "$< did changed: you must re-run './configure'"
@false
# If installing with DESTDIR, check it's an absolute path
ifneq ($(strip $(DESTDIR)),)
ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
$(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
endif
endif
###############################################################################
# Global make rules
# If any extra MAKEFLAGS were added, re-run ourselves
# See top of file for an explanation of why this is needed...
ifneq ($(strip $(CT_MAKEFLAGS)),)
MAKEFLAGS += $(CT_MAKEFLAGS)
build install clean distclean uninstall:
@$(MAKE) $@
else
# There were no additional MAKEFLAGS to add, do the job
TARGETS := bin lib doc man
build: $(patsubst %,build-%,$(TARGETS))
install: build real-install
clean: $(patsubst %,clean-%,$(TARGETS))
distclean: clean
@echo " RM 'Makefile'"
@rm -f Makefile
uninstall: real-uninstall
###############################################################################
# Specific make rules
#--------------------------------------
# Build rules
build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh
@chmod 755 $^
build-lib: paths.mk
build-doc:
build-man: docs/ct-ng.1.gz
docs/ct-ng.1.gz: docs/ct-ng.1
@echo " GZIP '$@'"
@gzip -c9 $< >$@
%: %.in Makefile
@echo " SED '$@'"
@$(sed) -r -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;' \
-e 's,@@CT_make@@,$(make),g;' \
-e 's,@@CT_bash@@,$(bash),g;' \
$@.in >$@
# We create a script fragment that is parseable from inside a Makefile,
# but also from inside a shell script, hence the reason why we don't
# use := to set varaibles, although that will incur a (very small)
# penalty from the Makefile that includes it (due to re-evaluation at
# each call).
paths.mk:
@echo " GEN '$@'"
@(echo "export install=$(install)"; \
echo "export bash=$(bash)"; \
echo "export grep=$(grep)"; \
echo "export make=$(make)"; \
echo "export sed=$(sed)"; \
) >paths.mk
#--------------------------------------
# Clean rules
clean-bin:
@echo " RM 'ct-ng'"
@rm -f ct-ng
@echo " RM 'script/crosstool-NG.sh'"
@rm -f scripts/crosstool-NG.sh
@echo " RM 'script/saveSample.sh'"
@rm -f scripts/saveSample.sh
clean-lib:
@echo " RM 'paths.mk'"
@rm -f paths.mk
clean-doc:
clean-man:
@echo " RM 'docs/ct-ng.1'"
@rm -f docs/ct-ng.1
@echo " RM 'docs/ct-ng.1.gz'"
@rm -f docs/ct-ng.1.gz
#--------------------------------------
# Check for --local setup
ifeq ($(strip $(LOCAL)),y)
real-install:
@true
real-uninstall:
@true
else
#--------------------------------------
# Install rules
real-install: $(patsubst %,install-%,$(TARGETS))
install-bin: $(DESTDIR)$(BINDIR)
@echo " INST 'ct-ng'"
@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
# If one is hacking crosstool-NG, the patch set might change between any two
# installations of the same VERSION, thus the patches must be removed prior
# to being installed. It is simpler to remove the whole lib/ directory, as it
# is the goal of the install-lib rule to install the lib/ directory...
install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
install-lib-main: $(DESTDIR)$(LIBDIR)
@for src_dir in config kconfig patches scripts; do \
echo " INST '$${src_dir}/'"; \
tar cf - --exclude=.svn --exclude='*.sh.in' $${src_dir} \
|(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
done
@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
@chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
@echo " INST 'steps.mk'"
@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
@echo " INST 'paths.mk'"
@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
# Samples need a little love:
# - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
@echo " INST 'samples/'"
@tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
@for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do \
$(sed) -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file}; \
$(sed) -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
done
install-doc: $(DESTDIR)$(DOCDIR)
@for doc_file in docs/CREDITS docs/overview.txt; do \
echo " INST '$${doc_file}'"; \
$(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
done
install-man: $(DESTDIR)$(MANDIR)
@echo " INST 'ct-ng.1.gz'"
@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
$(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
@echo " MKDIR '$@'"
@$(install) -m 755 -d "$@"
#--------------------------------------
# Uninstall rules
real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
uninstall-bin:
@echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'"
@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
uninstall-lib:
@echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
@rm -rf "$(DESTDIR)$(LIBDIR)"
uninstall-doc:
@echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
@rm -rf "$(DESTDIR)$(DOCDIR)"
uninstall-man:
@echo " RM '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
@rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
endif # Not --local
endif # No extra MAKEFLAGS were added

@ -0,0 +1,20 @@
This is the README for crosstool-NG
To get you started, just enter:
./configure --help
You can find a (terse and WIP) documentation in docs/overview.txt.
You can also point your browser to
http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool
If you need to send a bug report or a patch, please send a mail with subject
prefixed with "[CT_NG]" with the following destinations:
TO: yann.morin.1998 (at) anciens.enib.fr
CC: crossgcc (at) sourceware.org
The people that helped are listed in docs/CREDITS. Many thanks to them! :-)
The list of known issues is listed in docs/known-issues.txt.
Aloha!

@ -1,156 +0,0 @@
# Crosstool-NG
## Introduction
Crosstool-NG aims at building toolchains. Toolchains are an essential component in a software development project. It will compile, assemble and link the code that is being developed. Some pieces of the toolchain will eventually end up in the resulting binaries: static libraries are but an example.
**Before reporting a bug**, please read [bug reporting guidelines](http://crosstool-ng.github.io/support/). Bugs that do not provide the required information will be closed without explanation.
Refer to [documentation at crosstool-NG website](http://crosstool-ng.github.io/docs/) for more information on how to configure, install and use crosstool-NG.
**Note 1:** If you elect to build a uClibc-based toolchain, you will have to prepare a config file for uClibc with <= crosstool-NG-1.21.0. In >= crosstool-NG-1.22.0 you only need to prepare a config file for uClibc(or uClibc-ng) if you really need a custom config for uClibc.
**Note 2:** If you call `ct-ng --help` you will get help for `make(2)`. This is because ct-ng is in fact a `make(2)` script. There is no clean workaround for this.
## Repository layout
To clone the crosstool-NG repository:
```
git clone https://github.com/crosstool-ng/crosstool-ng
```
#### Old repositories
These are the old Mercurial repositories. They are now read-only: [http://crosstool-ng.org/hg/](http://crosstool-ng.org/hg/)
### Pull Requests and Issues
You can find open Pull Requests on GitHub [here](https://github.com/crosstool-ng/crosstool-ng/pulls) and you can find open issues [here](https://github.com/crosstool-ng/crosstool-ng/issues).
#### Contributing
To contribute to crosstool-NG it is helpful to provide as much information as you can about your change, including any updates to documentation (if appropriate), and test... test... test.
- [Fork crosstool-ng on github](https://github.com/crosstool-ng/crosstool-ng#fork-destination-box)
- Clone the fork you made to your computer
```
git clone https://github.com/crosstool-ng/crosstool-ng
```
- Create a topic branch for your work
```
git checkout -b fix_comment_typo
```
- Make changes
- hack
- test
- hack
- etc...
- Add your changes
```
git add [file(s) that changed, add -p if you want to be more specific]
```
- Verify you are happy with your changes to be commited
```
git diff --cached
```
- Commit changes
```
git commit -s
```
The `-s` automatically adds your `Signed-off-by: [name] <email>` to your commit message. Your commit will be rejected without this.
Also, please explain what your change does. `"Fix stuff"` will be rejected. For examples of good commit messages, read the [changelog](https://github.com/crosstool-ng/crosstool-ng/commits/master).
- Push your topic branch with your changes to your fork
```
git push origin fix_comment_typo
```
- Go to the crosstool-ng project and click the `Compare & pull request` button for the branch you want to open a pull request with.
- Review the pull request changes, and verify that you are opening a pull request for the appropriate branch. The title and message should reflect the nature/theme of the changes in the PR, say the title is `Fix comment typos` and the message details any specifics you can provide.
- You might change the crosstool-ng branch, if you are opening a pull request that is intended for a different branch. For example, when you created your topic branch you could have done:
```
git checkout -b fix_out_of_date_patch origin/1.22
```
Then when you get to this pull request screen change the base branch from `master` to `1.22`
- By creating a pull request, the PR is entered into the [backlog](https://waffle.io/crosstool-ng/crosstool-ng). A [travis-ci](https://travis-ci.org/crosstool-ng/crosstool-ng/builds) job will run to test your changes against a select set of samples. As they start to get worked, they should be placed in the `Ready` state. PRs that are being worked are `In Progress`. If a questions come up about the commit that might envolve changes to the commit then the PR is placed in `Waiting For Response`, you have two options:
1. Fix the issue with the commit by adding a new commit in the topic branch that fixes the code review. Then push your changes to your branch. This option keeps the comments in the PR, and allows for further code review. I personally dislike this, because people are lazy and fix reviews with `fix more review issues`. Please make good commit messages! All rules about commits from above apply! **THIS IS PREFERED**
Add your changes
```
git add [file(s) that changed, add -p if you want to be more specific]
```
Verify you are happy with your changes to be commited
```
git diff --cached
```
Commit changes
```
git commit -s
```
- Push your topic branch with your changes to your fork
```
git push origin fix_comment_typo
```
At this point the PR will be updated to have the latest commit to that branch, and can be subsequently reviewed.
2. Interactively rebase the offending commit(s) to fix the code review. This option is slightly annoying on Github, as the comments are stored with the commits, and are hidden when new commits replace the old commits. They used to disappear completely; now Github shows a grey 'View outdated' link next to the old commits.
This recipe also comes handy with other issues, like your topic branch not being up-to-date with master:
```
git fetch --all
git rebase --ignore-whitespace origin master
git rebase -i <offending-commit-id>^
```
**NOTE:** The `--ignore-whitespace` stops `git apply` (which is called by rebase) from changing any whitespace when it runs.
Replace `pick` with `edit` or remove the line to delete a commit.
Fix the issue in the code review.
```
git add [file(s)]
git rebase --continue
<update commit comment if needed>
git push --force origin fix_comment_typo
```
### Patchwork
We previously used patchwork for development, but it is no longer used. I'd like to see patches that are still applicable turned into Pull Requests on GitHub.
You can find the [list of pending patches](http://patchwork.ozlabs.org/project/crosstool-ng/) available on [patchwork](http://jk.ozlabs.org/projects/patchwork/).
## More Info
You can find *all* of this and more at [crosstool-ng.org](http://crosstool-ng.org/)
Report issues at [the project site on GitHub](https://github.com/crosstool-ng/crosstool-ng).
We have a [mailing list](mailto:crossgcc@sourceware.org). Archive and subscription info can be found here: [https://sourceware.org/ml/crossgcc/](https://sourceware.org/ml/crossgcc/)
Aloha! :-)

135
TODO

@ -1,135 +0,0 @@
A (slightly) ordered set of tasks for crosstool-NG. Written in a cryptic language; contact me if you want to help with any of these :)
-- Alexey Neyman (@stilor)
[ ] Migrate .config and build.log into per-target directory, make top-level file into symlinks - this will allow to compare/debug multiple configs side-by-side without overwriting each other
[ ] Need a variant of CT_DoExecLog that only captures stderr - for use where we need stdout for further processing but want to capture errors
[ ] Use in test-package.sh
[ ] mirror: remove crosstool-ng.org mirroring of archives? Use the option only for local mirrors? Archives currently hosted are outdated.
[ ] old mingw-w64 fails to build (with new gcc?) - the headers are installed into usr/x86_64-w64-mingw32/x86_64-w64-mingw32/include instead of usr/x86_64-w64-mingw32/include
[ ] fix or retire?
[ ] test-packages.sh
[ ] FTP URLs always succeed in verification (wget bug) - how to work around?
[ ] templates (bootstrap)
[ ] relevant pattern for Linaro releases - tie to the major version
[ ] new packages
[ ] config.guess
[ ] gnulib
[ ] use gnulib in m4, gettext, libiconv, libtool
[ ] autoconf-archive
[ ] use to retrieve ax_pthread.m4 (gettext?)
[ ] arm_neon.h - offer as a companion "library" for the target
[ ] gdbinit (installed if CT_GDB_INSTALL_GDBINIT is set) is not relocatable, contains absolute paths
[ ] Support alldefconfig/allnoconfig/other standard kconfig targets
[ ] Xtensa
[ ] Merge from xtensa maintainer whatever applicable?
[ ] Newlib does not seem to be working
[ ] Avoid printing "Using <overlay>" if the sources are already prepared
[ ] FreeBSD
[ ] Use 'cc' rather than 'gcc' on the host
[ ] Detect in configure what the default value is
[ ] Allow passing via CC=... to ct-ng
[ ] Same for ar/ld/ranlib/whatever we're using
[ ] Same for other utilities (patch, python, ...)
[ ] Allow using BSD patch
[ ] Set up 3 testing VMs: plain (using clang), using default 'gcc', using 'gcc6'
[ ] GDB7.1 build fails on macOS
[ ] need 'cpp' in the list of symlinked tools
[ ] still fails at link due to multiple definitions of BC/UP/PC
[ ] mingw.sh: create a hook for "pre-checks" for all libcs
[ ] move CT_DoMultilibList to this new hook?
[ ] go over all config options and evaluate their applicability to cross/canadian/cross-native (i.e. WANTS_STATIC_LINK does not have to test build's support for static link)
[ ] Update "Internals" chapter in the docs to match current state
[ ] Integrate openrisc support
[ ] Re-enable shared libraries - can it be done without wrapper scripts, e.g. via rpath?
[ ] 'ct-ng source'
[ ] disregard FORBID_DOWNLOADS and to avoid clobbering .build and build.log
[ ] should not check/prepare environment (#776)
[ ] move download/patching/prepare into separate steps
[ ] beware of TBD - want to use autotools for all packages after they're built, so need to defer preparation of the sources from a repo
[ ] 'ct-ng' source to disregard FORBID_DOWNLOADS and to avoid clobbering .build and build.log
[ ] Make ONLY_{DOWNLOAD,EXTRACT} options into steps
[ ] Create "prepare" state to make the environment checks, after "download"
[ ] Restore blackfin/fdpic support?
[ ] Install bash completion script - are there any default locations for it?
[ ] Do we need "HACK: we need to override SHLIB_LC from gcc/config/t-slibgcc-elf-ver" block in 100-gcc.sh? We do create a dummy libc.so
[ ] Follow up on -static -Wl,--dynamic-list=... weirdness
[ ] xldd.in
[ ] Deduce root from the location of the script itself by default + option for multiroot selection (e.g. for SH)
[ ] Handle CT_LD_LIBRARY_PATH in lieu of LD_LIBRARY_PATH
[ ] Handle AT_SECURE
[ ] Handle DT_RPATH/DT_RUNPATH separately (they have different priority vs LD_LIBRARY_PATH)
[ ] Handle default ld_library_path after ld.so.conf cache
[ ] Add optional removal of .build/src as part of build-all
[ ] Add removal of non-precious toolchains (i.e. those that are not needed for canadian)
[ ] Or remove all *when* they are no longer needed?
[ ] GMP select the right CC when not cross-compiling (https://github.com/crosstool-ng/crosstool-ng/pull/627)
[ ] Default to arch=i686 on x86
[ ] Run ct-ng oldconfig at the start, or detect if a different version of ct-ng has been used?
[ ] Move fetching config.guess/config.sub to scripts/functions to use common wget/curl wrappers
[ ] Allow auto-update as part of the build
[ ] Do they have versions? Is it possible to request a specific version?
[ ] Separate 'make check' for companion libs and companion tools?
[ ] gettext - test internationalization
[ ] seems the DB is hardcoded into .build/<TARGET>/... location - is it possible to make it relocatable?
[ ] add passthrough to configure, for host/target
[ ] Read/spellcheck configs & scripts
[ ] 'ct-ng olddefconfig'
[ ] Install a "trap" C++ compiler as ${CT_TARGET}-g++ during pass-1/pass-2 to trap attempts to compile target code with g++ (currently glibc detects host g++ and warns that it uses g++ w/o target triplet)
[ ] Somehow it needs to be functional during the configure step - export env var while running in CT_DoExecLog with CFG level, and forward it to host compiler?
[ ] elf2flt not compatible with multiple linkers enabled in binutils (ld.bfd + ld.gold) - fix upstream?
[ ] Companion libs
[ ] Group options into submenus
[ ] Allow building [companion] target libs (and tools, like gdbserver or native gdb or strace) for all multilibs
[ ] Install companion libs into a multi-os-directory for the default multilib
[ ] Perhaps remove the distinction between multi_os_dir/multi_os_dir_gcc and use gcc-reported dir always, and rely on "demultilib" to combine them if possible
[ ] Check for python-devel to enable cross-gdb python bindings
[ ] Common location for sources provided by ctng - duma.in, gdbinit.in, uclibc{,-ng}-config.in ...
[ ] CTNG_LD_IS=bfd has no effect on subsequent build steps, as each step runs in its own environment
[ ] Enable other languages in some sample(s):
[ ] Ada (?) - requires gnatbind/gnatmake on the host
[X] Seems to build
[ ] Try to run
[ ] Obj-C/C++
[X] Seems to build
[ ] Try to run - seems to crash, need to investigate
[ ] Go
[ ] Fix the build
[ ] Try to run
[ ] #516 Building with GO support fails
[ ] #521 gccgo - i586-unknown-linux-gnu - fails on missing version.go
[ ] Smoke-test test suite - whatever is supported by a particular toolchain
[ ] Compile baremetal, shared, static, static-libgcc, static-libstdc, C++, Fortran, Ada, Obj-C, Obj-C++, multilibs
[ ] Disallow libc selections that cannot handle the arch (e.g. aarch64-*-uclibc, aarch64-*-musl, ...)
[ ] Support removal of .build/<TARGET>/build after each step (to save space while compiling in a VM; and to test restartability - since this directory is lost after restart)
[ ] Configure enhancements
[ ] What is --host= in ct-ng's configure used for? should it set the default canadian cross?
[ ] CFLAGS/LDFLAGS from configure should probably be added into default build flags
[ ] Move tool checks from configure to runtime (i.e. if xz was installed after crosstool-ng, it should be usable)
[ ] Check for companion libs and allow using host's libraries for native/cross (need to check if the host has them) - but allow them to be selected for build
[ ] Merge aggregator scripts like cc.sh, debug.sh etc
[ ] #534 Merge gcc backends in 100-gcc.sh
[ ] Currently some options (e.g. plugins) are not supported in core backend, hence aren't available on baremetal configurations
[ ] Support clang
[ ] Add a script to poll for new releases
[ ] Install a single lib/ directory with all the stuff needed - scripts, makefile fragments, etc
[ ] Separate maintainer's scripts from the scripts used by crosstool-ng itself
[ ] Commit testing.py to the new maintainer's dir
[ ] Add an ability to do a single run of testing.py? or just use build-all, when the branch for separate canadian install is done
[ ] Extensibility to allow custom kernel headers and/or libc
[ ] Support elfkickers
[ ] Make cross-native toolchain non-experimental
[ ] Rework dependency order to suit xnative toolchain too
[ ] Make native/cross-native toolchain non-experimental
[ ] Pick up libc from host for native
[ ] Optimize steps to not require simple-cross for cross-native
[ ] Make supplemental commands like show-config leave .config and .build alone
[ ] Test populate script
[ ] 3rd party extensions to GCC
[ ] GHDL seems to be active and supports GCC6
[ ] COBOL? Cannot find which GCC version they need [http://cobolforgcc.sourceforge.net/]
[ ] At the very least they have an awesome guide to GCC internals: http://cobolforgcc.sourceforge.net/cobol_14.html; might just as well reference it in our docs
[ ] Modula-2 supports GCC 4.7 as the latest
[ ] Resurrect GCC4.7?
[ ] readelf: DWARF parser does not handle DW_CFA_remember_state/DW_CFA_restore_state
[ ] Support uClibc++?

@ -1,36 +0,0 @@
# To be sourced
_ct_ng () {
local cur prev samples show_samples actions steps start_steps stop_steps ct_ng_opts vars
COMPREPLY=()
cur=$(_get_cword)
prev=${COMP_WORDS[COMP_CWORD-1]}
samples=$( "${COMP_WORDS[0]}" list-samples-short 2>/dev/null )
show_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1show-/g;')
build_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1build-/g;')
check_samples=$(echo "${samples}" |sed -r -e 's/(^| )/\1check-/g;')
steps=$(${COMP_WORDS[0]} list-steps 2>/dev/null |awk '$1 == "-" { print $2; }')
start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;')
stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;')
actions='help menuconfig nconfig oldconfig saveconfig extractconfig
defconfig savedefconfig olddefconfig upgradeconfig
build build-all
wiki-samples list-samples list-samples-short check-samples
list-steps
show-tuple show-all show-config
clean distclean updatetools
version'
vars="RESTART= STOP= PREFIX= V= DEFCONFIG="
ct_ng_opts="${samples} ${show_samples} ${build_samples} ${check_samples}
${steps} ${start_steps} ${stop_steps}
${actions} ${vars}"
COMPREPLY=($(compgen -W "${ct_ng_opts}" -- "${cur}"))
return 0
}
complete -F _ct_ng @progname@

@ -1,823 +0,0 @@
#!/usr/bin/env bash
if [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
echo "Your BASH shell version (${BASH_VERSION}) is too old." >&2
echo "Run bootstrap on a machine with BASH 4.x" >&2
exit 1
fi
########################################
# Common meta-language implementation. Syntax:
#
# The template file is processed line by line, with @@VAR@@ placeholders
# being replaced with a value of the VAR variable.
# Special lines start with '#!' and a keyword:
#
# #!//
# Comment, the rest of the line is ignored
# #!if COND
# Conditional: the lines until the matching #!end-if are processed
# only if the conditional COND evaluates to true.
# #!foreach NAME
# Iterate over NAME entities (the iterator must be set up first
# using the set_iter function), processing the lines until the matching
# #!end-foreach line.
#
# Also, several forms of @@VAR@@ expansions are possible:
#
# @@VAR@@
# Just the value of the variable VAR
# @@VAR|@@
# The value of VAR made into Kconfig-name: all non-alphanumeric character
# replaced with underscores; upper-cased.
# @@VAR?val@@
# If VAR is non-empty, insert value "val". Otherwise, insert nothing.
# @@*ITER@@
# Expands to a space separated list of values for the iterator ITER.
# Postprocess operations, if any, are applied to each value.
declare -A info
debug()
{
if [ -n "${DEBUG}" ]; then
echo "DEBUG :: $@" >&2
fi
}
msg()
{
if [ -z "${QUIET}" ]; then
echo "INFO :: $@" >&2
fi
}
warn()
{
echo "WARN :: $@" >&2
}
error()
{
echo "ERROR :: $@" >&2
exit 1
}
find_end()
{
local token="${1}"
local count=1
# Skip first line, we know it has the proper '#!' command on it
endline=$[l + 1]
while [ "${endline}" -le "${end}" ]; do
case "${tlines[${endline}]}" in
"#!${token} "*)
count=$[count + 1]
;;
"#!end-${token}")
count=$[count - 1]
;;
esac
if [ "${count}" = 0 ]; then
return
fi
endline=$[endline + 1]
done
error "${template}:${l}: '${token}' token is unpaired"
}
set_iter()
{
local name="${1}"
local -a temp
if [ "${info[iter_${name}]+set}" = "set" ]; then
error "Iterator over '${name}' is already set up"
fi
shift
debug "Setting iterator over '${name}' to '$*'"
temp=("$@")
info[iter_${name}]="$*"
info[#${name}]=${#temp[@]}
}
run_if()
{
local cond="$*"
local endline
find_end "if"
if eval "${cond}"; then
debug "True conditional '${cond}' at lines ${l}..${endline}"
run_lines $[l + 1] $[endline - 1]
else
debug "False conditional '${cond}' at lines ${l}..${endline}"
fi
lnext=$[endline + 1]
debug "Continue at line ${lnext}"
}
do_foreach()
{
local var="${1}"
local -A saveinfo
local v k
shift
if [ "`type -t enter_${var}`" != "function" ]; then
error "No parameter setup routine for iterator over '${var}'"
fi
if [ "x${info[iter_${var}]+set}" != "xset" ]; then
error "Iterator over '${var}' not configured"
fi
for v in ${info[iter_${var}]}; do
# This works in bash 4.4, but not in bash 4.3:
# local saveinfo=`declare -p info`
# ...
# eval "${saveinfo}"
# Therefore, need to save key-by-key
saveinfo=()
for k in "${!info[@]}"; do
saveinfo["${k}"]=${info["${k}"]}
done
if eval "enter_${var} ${v}"; then
eval "$@"
fi
info=()
for k in "${!saveinfo[@]}"; do
info["${k}"]=${saveinfo["${k}"]}
done
done
}
run_foreach()
{
local endline
local var="${1}"
shift
if [ "${info[iter_${var}]+set}" != "set" ]; then
error "${template}:${l}: iterator over '${var}' is not defined"
fi
find_end "foreach"
debug "Loop over '${var}', lines ${l}..${endline}"
do_foreach ${var} run_lines_if $[l + 1] $[endline - 1] "$*"
lnext=$[endline + 1]
debug "Continue at line ${lnext}"
}
run_lines_if()
{
local start="${1}"
local end="${2}"
shift 2
local cond="$*"
local a prev
for a in ${cond}; do
if [ -n "${prev}" ]; then
case "${prev}" in
if-differs)
if [ "${info[${a}]}" = "${saveinfo[${a}]}" ]; then
return
fi
;;
*)
error "${template}:${l}: unknown condition '${prev}' for loop"
;;
esac
prev=
else
prev=${a}
fi
done
run_lines "${start}" "${end}"
}
run_lines()
{
local start="${1}"
local end="${2}"
local l lnext s s1 v vn vp pp p val val0 is_iter pp_saved
local -a vpl
debug "Running lines ${start}..${end}"
l=${start}
while [ "${l}" -le "${end}" ]; do
lnext=$[l+1]
s="${tlines[${l}]}"
# Expand @@foo@@ to ${info[foo]}. First escape variables/backslashes for evals below.
s="${s//\\/\\\\}"
s="${s//\$/\\\$}"
s1=
while [ -n "${s}" ]; do
case "${s}" in
*@@*@@*)
v="${s#*@@}"
v="${v%%@@*}"
# $v now has the complete reference. First check if it is cached already.
if [ "${info[${v}]+set}" != "set" ]; then
case "${v}" in
"*"*) is_iter=y; vn="${v#\*}";;
*) is_iter=n; vn="${v}";;
esac
# $vn is now the reference without the preceding iterator
vp="${vn%%[|?]*}"
pp="${vn#${vp}}"
# $vp is name of the variable proper, $pp is any postprocessing
if [ "${is_iter}" = "n" ]; then
if [ "${info[${vp}]+set}" != "set" ]; then
error "${template}:${l}: reference to undefined variable '${vp}'"
fi
vpl=( "${info[${vp}]}" )
else
if [ "${info[iter_${vp}]+set}" != "set" ]; then
error "${template}:${l}: iterator over '${vp} is not defined"
fi
vpl=( ${info[iter_${vp}]} )
fi
# ${vpl[@]} now is an array of values to be transformed.
val=
pp_saved="${pp}"
for val0 in "${vpl[@]}"; do
debug "val0 [${val0}]"
pp="${pp_saved}"
# Apply postprocessing(s)
while [ -n "${pp}" ]; do
case "${pp}" in
"|"*)
# Kconfigize
pp="${pp#|}"
val0=${val0//[^0-9A-Za-z_]/_}
val0=${val0^^}
;;
"?"*)
pp="${pp#?}"
p="${pp%%[|?]*}"
pp="${pp#${p}}"
val0="${val0:+${p}}"
;;
esac
done
val="${val:+${val} }${val0}"
done
# Cache for future references.
info[${v}]="${val}"
fi
s1="${s1}${s%%@@*}\${info[${v}]}"
s="${s#*@@*@@}"
;;
*@@*)
error "${template}:${l}: non-paired @@ markers"
;;
*)
s1="${s1}${s}"
break
;;
esac
done
s=${s1}
debug "Evaluate: ${s}"
case "${s}" in
"#!if "*)
run_if ${s#* }
;;
"#!foreach "*)
run_foreach ${s#* }
;;
"#!//"*)
# Comment, do nothing
;;
"#!"*)
error "${template}:${l}: unrecognized command"
;;
*)
# Not a special command
eval "echo \"${s//\"/\\\"}\""
;;
esac
l=${lnext}
done
}
run_template()
{
local -a tlines
local src="${1}"
if [ ! -r "${src}" ]; then
error "Template '${src}' not found"
fi
template="${src}"
debug "Running template ${src}"
mapfile -O 1 -t tlines < "${src}"
run_lines 1 ${#tlines[@]}
}
########################################
# Leave only relevant portion of the string
relevantize()
{
local p pb pa vx
local v="${1}"
shift
# Find the first match and contract to the matching portion.
for p in "$@"; do
pb=${p%|*}
pa=${p#*|}
eval "vx=\${v#${pb}${pa}}"
if [ "${v%${pa}${vx}}" != "${v}" ]; then
v=${v%${pa}${vx}}
break
fi
done
echo "${v}"
}
# Helper for cmp_versions: compare an upstream/debian portion of
# a version. Returns 0 if equal, otherwise echoes "-1" or "1" and
# returns 1.
equal_versions()
{
local v1="${1}"
local v2="${2}"
local p1 p2
# Compare alternating non-numerical/numerical portions, until
# non-equal portion is found or either string is exhausted.
while [ -n "${v1}" -a -n "${v2}" ]; do
# Find non-numerical portions and compare lexicographically
p1="${v1%%[0-9]*}"
p2="${v2%%[0-9]*}"
v1="${v1#${p1}}"
v2="${v2#${p2}}"
#debug "lex [${p1}] v [${p2}]"
if [ "${p1}" \< "${p2}" ]; then
echo "-1"
return 1
elif [ "${p1}" \> "${p2}" ]; then
echo "1"
return 1
fi
#debug "rem [${v1}] v [${v2}]"
# Find numerical portions and compare numerically
p1="${v1%%[^0-9]*}"
p2="${v2%%[^0-9]*}"
v1="${v1#${p1}}"
v2="${v2#${p2}}"
#debug "num [${p1}] v [${p2}]"
if [ "${p1:-0}" -lt "${p2:-0}" ]; then
echo "-1"
return 1
elif [ "${p1:-0}" -gt "${p2:-0}" ]; then
echo "1"
return 1
fi
#debug "rem [${v1}] v [${v2}]"
done
if [ -n "${v1}" ]; then
echo "1"
return 1
elif [ -n "${v2}" ]; then
echo "-1"
return 1
fi
return 0
}
# Compare two version strings, similar to sort -V. But we don't
# want to depend on GNU sort availability on the host.
# See http://www.debian.org/doc/debian-policy/ch-controlfields.html
# for description of what the version is expected to be.
# Returns "-1", "0" or "1" if first version is earlier, same or
# later than the second.
cmp_versions()
{
local v1="${1}"
local v2="${2}"
local e1=0 e2=0 u1 u2 d1=0 d2=0
# Case-insensitive comparison
v1="${v1^^}"
v2="${v2^^}"
# Find if the versions contain epoch part
case "${v1}" in
*:*)
e1="${v1%%:*}"
v1="${v1#*:}"
;;
esac
case "${v2}" in
*:*)
e2="${v2%%:*}"
v2="${v2#*:}"
;;
esac
# Compare epochs numerically
if [ "${e1}" -lt "${e2}" ]; then
echo "-1"
return
elif [ "${e1}" -gt "${e2}" ]; then
echo "1"
return
fi
# Find if the version contains a "debian" part.
# v1/v2 will now contain "upstream" part.
case "${v1}" in
*-*)
d1=${v1##*-}
v1=${v1%-*}
;;
esac
case "${v2}" in
*-*)
d2=${v2##*-}
v2=${v2%-*}
;;
esac
# Compare upstream
if equal_versions "${v1}" "${v2}" && equal_versions "${d1}" "${d2}"; then
echo "0"
fi
}
# Sort versions, descending
sort_versions()
{
local sorted
local remains="$*"
local next_remains
local v vx found
while [ -n "${remains}" ]; do
#debug "Sorting [${remains}]"
for v in ${remains}; do
found=yes
next_remains=
#debug "Candidate ${v}"
for vx in ${remains}; do
#debug "${v} vs ${vx} :: `cmp_versions ${v} ${vx}`"
case `cmp_versions ${v} ${vx}` in
1)
next_remains+=" ${vx}"
;;
0)
;;
-1)
found=no
#debug "Bad: earlier than ${vx}"
break
;;
esac
done
if [ "${found}" = "yes" ]; then
# $v is less than all other members in next_remains
sorted+=" ${v}"
remains="${next_remains}"
#debug "Good candidate ${v} sorted [${sorted}] remains [${remains}]"
break
fi
done
done
echo "${sorted}"
}
read_file()
{
local l p
while read l; do
l="${p}${l}"
p=
case "${l}" in
"")
continue
;;
*\\)
p="${l%\\}"
continue
;;
"#"*)
continue
;;
*=*)
echo "info[${l%%=*}]=${l#*=}"
;;
*)
error "syntax error in '${1}': '${l}'"
;;
esac
done < "${1}"
}
read_package_desc()
{
read_file "packages/${1}/package.desc"
}
read_version_desc()
{
read_file "packages/${1}/${2}/version.desc"
}
find_forks()
{
local -A info
info[preferred]=${1}
eval `read_package_desc ${1}`
if [ -n "${info[master]}" ]; then
pkg_nforks[${info[master]}]=$[pkg_nforks[${info[master]}]+1]
pkg_forks[${info[master]}]+=" ${1} "
else
pkg_preferred[${1}]=${info[preferred]}
pkg_nforks[${1}]=$[pkg_nforks[${1}]+1]
pkg_forks[${1}]+=" ${1} "
pkg_milestones[${1}]=`sort_versions ${info[milestones]}`
pkg_relevantpattern[${1}]=${info[relevantpattern]}
pkg_masters+=( "${1}" )
fi
# Keep sorting so that preferred fork is first
if [ -n "${pkg_preferred[${1}]}" ]; then
pkg_forks[${1}]="${pkg_preferred[${1}]} ${pkg_forks[${1}]##* ${pkg_preferred[${1}]} } ${pkg_forks[${1}]%% ${pkg_preferred[${1}]} *}"
fi
}
enter_fork()
{
local fork="${1}"
local versions
local only_obsolete only_experimental
local -A seen_selectors
# Set defaults
info[obsolete]=
info[experimental]=
info[repository]=
info[repository_branch]=
info[repository_cset]=
info[repository_subdir]=
info[bootstrap]=
info[fork]=${fork}
info[pkg_name]=${fork}
info[pkg_label]=${fork}
info[mirrors]=
info[archive_filename]='@{pkg_name}-@{version}'
info[archive_dirname]='@{pkg_name}-@{version}'
info[versionlocked]=
info[origin]=
info[signature_format]=
eval `read_package_desc ${fork}`
if [ -r "packages/${info[origin]}.help" ]; then
info[originhelp]=`sed 's/^/ /' "packages/${info[origin]}.help"`
else
info[originhelp]=" ${info[master]} from ${info[origin]}."
fi
if [ -n "${info[repository]}" ]; then
info[vcs]=${info[repository]%% *}
info[repository_url]=${info[repository]#* }
fi
versions=`cd packages/${fork} && \
for f in */version.desc; do [ -r "${f}" ] && echo "${f%/version.desc}"; done`
versions=`sort_versions ${versions}`
set_iter version ${versions}
info[all_versions]=${versions}
check_relevant_pattern()
{
if [ "x${seen_selectors[${info[ver_sel]}]+set}" = "xset" ]; then
error "${info[pkg_name]}: version ${info[ver]} conflicts with version ${seen_selectors[${info[ver_sel]}]} (${info[ver_sel]} selector)"
else
seen_selectors[${info[ver_sel]}]=${info[ver]}
fi
}
do_foreach version check_relevant_pattern
# If a fork does not define any versions at all ("rolling release"), do not
# consider it obsolete/experimental unless it is so marked in the fork's
# description.
if [ -n "${versions}" ]; then
only_obsolete=yes
only_experimental=yes
check_obsolete_experimental()
{
[ -z "${info[obsolete]}" ] && only_obsolete=
[ -z "${info[experimental]}" ] && only_experimental=
}
do_foreach version check_obsolete_experimental
info[only_obsolete]=${only_obsolete}
info[only_experimental]=${only_experimental}
else
info[only_obsolete]=${info[obsolete]}
info[only_experimental]=${info[experimental]}
fi
}
enter_version()
{
local version="${1}"
eval `read_version_desc ${info[fork]} ${version}`
info[ver]=${version}
info[ver_sel]=`relevantize ${version} ${info[relevantpattern]}`
}
enter_milestone()
{
local ms="${1}"
local cmp
info[ms]=${ms}
if [ -n "${info[ver]}" ]; then
info[version_cmp_milestone]=`cmp_versions ${info[ver]} ${info[ms]}`
fi
}
gen_packages()
{
local -A pkg_forks pkg_milestones pkg_nforks pkg_relevantpattern
local -a pkg_masters pkg_all pkg_preferred
pkg_all=( `cd packages && \
ls */package.desc 2>/dev/null | \
while read f; do [ -r "${f}" ] && echo "${f%/package.desc}"; done | \
xargs echo` )
debug "Packages: ${pkg_all[@]}"
# We need to group forks of the same package into the same
# config file. Discover such relationships and only iterate
# over "master" packages at the top.
for p in "${pkg_all[@]}"; do
find_forks "${p}"
done
msg "Master packages: ${pkg_masters[@]}"
# Now for each master, create its kconfig file with version
# definitions. As a byproduct, generate a list of all package
# versions for maintenance purposes.
exec 3>"maintainer/package-versions"
for p in "${pkg_masters[@]}"; do
msg "Generating '${config_versions_dir}/${p}.in'"
exec >"${config_versions_dir}/${p}.in"
# Base definitions for the whole config file
info=( \
[master]=${p} \
[nforks]=${pkg_nforks[${p}]} \
[relevantpattern]=${pkg_relevantpattern[${p}]} \
)
set_iter fork ${pkg_forks[${p}]}
set_iter milestone ${pkg_milestones[${p}]}
run_template "maintainer/kconfig-versions.template"
run_template "maintainer/package-versions.template" >&3
done
}
msg "*** Generating package version descriptions"
config_versions_dir=config/versions
rm -rf "${config_versions_dir}"
mkdir -p "${config_versions_dir}"
gen_packages
get_components()
{
local dir="${1}"
local f b
for f in ${dir}/*.in; do
b=${f#${dir}/}
echo ${b%.in}
done
}
enter_choice()
{
local choice="${1}"
local input="config/${info[dir]}/${choice}.in"
local l ln
info[choice]="${choice}"
info[pkg]="${choice}"
# Not local, we need these arrays be set in enter_dependency/enter_help
deplines=( )
helplines=( )
ln=0
while read l; do
ln=$[ln+1]
case "${l}" in
"## help "*)
helplines+=( "${l#\#\# help }" )
;;
"## depends "*|"## select "*|"## default "*)
deplines+=( "${l#\#\# }" )
;;
"## no-package")
info[pkg]=