Cannot build a gcc cross-compiler

Michael Abbott michael@araneidae.co.uk
Wed Jul 22 10:01:00 GMT 2009


On Wed, 22 Jul 2009, booleandomain wrote:
> Martin Guy wrote:
> > >  It seems a chicken and egg problem: glibc needs gcc, gcc needs glibc.
> > It is. You need a robot chicken to make your first egg. Specifically,
> > you build a stripped-down gcc that is enough to build glibc, then use
> > that two to build the final gcc.
> 
> I'm trying to build the stripped-down gcc, but it still fails after having
> added --disable-decimal-float --without-headers --with-newlib
> --disable-threads --disable-shared --disable-libmudflap --disable-libssp.
> 
> I have also looked at crosstools-ng, but it also fails (at configure 
> stage) because of automake.

The automake issue is easy enough to sort: I have a makefile which wraps 
crosstool-ng, and the main thing it does of interest is install local 
copies of automake, autoconf, m4 and libtool (versions 1.10.2, 2.63, 
1.4.12, 2.2.4 repectively).  Each is just a matter of 
	./configure --prefix=${TOOLKIT_ROOT} && make install
and then I run crosstool-ng with ${TOOLKIT_ROOT}/bin on the path.

Perhaps crosstool-ng could do this bit, maybe my makefile could be 
modified to be helpful?  Anyhow, I've attached the makefile I use to wrap 
my crosstool-ng build (but I've not attached all the extra dependencies, 
and I've not updated it recently...)

> Also, I'd like to avoid automatic scripts that do the job for me, 
> because even if they work, I would not understand and learn anything 
> about building a toolchains and cross-compilers. Instead what I probably 
> really need is good documentation, but after having extensively searched 
> the web I only found laconic or obsolete pages.

Yeah, the documentation here is pretty horrible.

Well, what crosstool-ng does is pretty informative: it's pretty nicely 
structured, I think.
-------------- next part --------------
# The following three symbols are used by the crosstool configuration file.
# Note that WORK_DIR and TARGET_DIR are designed to be overridden by the
# publish script, and can also be overridden by the CONFIG.local script.
export WORK_DIR = /scratch/tmp/crosstool-ng
export TARGET_DIR = $(WORK_DIR)/target
export PATCHES_DIR = $(CURDIR)/patches

TAR_DIRS = /dls_sw/prod/targetOS/tar-files
SOURCE_DIR = $(WORK_DIR)/src

# Crosstool can only look in one tar directory.
export TARS_DIR = $(word 1, $(TAR_DIRS))

# Note that the line below is scanned by scripts/publish, so needs to keep
# exactly the format shown!
CT_VERSION = 1.3.2

ifneq ($(PUBLISH),YES)
-include CONFIG.local
endif


# Crosstool-NG files downloaded from 
#   http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool
MD5_SUM_1.2.2 = e7c99281fafa7422fd17061f7cbb8cc3
MD5_SUM_1.2.4 = fab13cba6fd9305c01d5ea3e4537eeba
MD5_SUM_1.3.0 = 99c2624cd9954e70eb4927ca61ba414f
MD5_SUM_1.3.1 = b7bd4eab82c4026614b9258cc5aadcc4
MD5_SUM_1.3.2 = 4111f899792afea6d47085b5a897e4b0



CROSSTOOL = crosstool-ng-$(CT_VERSION)
CROSSTOOL_DIR = $(SOURCE_DIR)/$(CROSSTOOL)
TOOLKIT_ROOT = $(WORK_DIR)/local


default: 
	@echo This is not designed to be made without configuration
	@echo Read the documentation first!
	make -C docs


$(CROSSTOOL_DIR): $(TOOLKIT_ROOT)
	mkdir -p $(SOURCE_DIR)
	./scripts/extract-tar $(SOURCE_DIR) $(CROSSTOOL).tar.bz2 \
            '$(MD5_SUM_$(CT_VERSION))' $(TAR_DIRS)
	for file in $(wildcard patches/crosstool-ng/$(CT_VERSION)/*); do \
            patch -d $(CROSSTOOL_DIR) -p1 < $$file  ||  exit 1; \
        done
	cd $(CROSSTOOL_DIR)  &&  ./configure --local  &&  make install

untar: $(CROSSTOOL_DIR)

$(CROSSTOOL_DIR)/.config: $(CROSSTOOL_DIR) config

src: $(CROSSTOOL_DIR)/.config
	cd $(CROSSTOOL_DIR)  && ./ct-ng build CT_ONLY_EXTRACT=y


.PHONY: config
config: $(CROSSTOOL_DIR) configs/$(TARGET).config
	./scripts/patch-config \
            <configs/$(TARGET).config >$(CROSSTOOL_DIR)/.config
	cd $(CROSSTOOL_DIR)  &&  ./ct-ng oldconfig

build: $(CROSSTOOL_DIR)/.config
	cd $(CROSSTOOL_DIR)  && ./ct-ng build


clean-config:
	rm $(CROSSTOOL_DIR)/.config

clean-all: 
	chmod -R +w $(WORK_DIR)
	rm -rf $(WORK_DIR)


menuconfig:
	cd $(CROSSTOOL_DIR)  && ./ct-ng menuconfig


configs/.config:
	$(error Need to specify a TARGET. See configs/ for supported targets)


# The following ensure that the required up to date environment is present.
TOOLKIT_COMPONENTS = m4 autoconf automake libtool

export PATH := $(TOOLKIT_ROOT)/bin:$(PATH)


# Automake (builds Makefile.in files)
# Homepage:
#   http://www.gnu.org/software/automake/
# Download from:
#   http://ftp.gnu.org/gnu/automake/automake-1.10.2.tar.bz2
#   ftp://ftp.gnu.org/gnu/automake/automake-1.10.2.tar.bz2
automake_VERSION ?= 1.10.2
MD5_SUM_automake_1.10.2 = 1498208ab1c8393dcbd9afb7d06df6d5

# Autoconf (M4 macros for generating configuration scripts)
# Homepage:
#   http://www.gnu.org/software/autoconf/
# Download from:
#   http://ftp.gnu.org/gnu/autoconf/autoconf-2.63.tar.bz2
#   ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.63.tar.bz2
autoconf_VERSION ?= 2.63
MD5_SUM_autoconf_2.63 = 7565809ed801bb5726da0631ceab3699

# M4 (macro processor)
# Homepage: 
#   http://www.gnu.org/software/m4/
# Download from:
#   http://ftp.gnu.org/gnu/m4/m4-1.4.12.tar.bz2 
#   ftp://ftp.gnu.org/gnu/m4/m4-1.4.12.tar.bz2
m4_VERSION ?= 1.4.12
MD5_SUM_m4_1.4.12 = b3587c993523dd320c318ec456876839

# Libtool (shared library support)
# Homepage:
#   http://www.gnu.org/software/libtool/
# Download from:
#   http://ftp.gnu.org/gnu/libtool/libtool-2.2.4.tar.bz2
#   ftp://ftp.gnu.org/gnu/libtool/libtool-2.2.4.tar.bz2
libtool_VERSION ?= 2.2.4
MD5_SUM_libtool_2.2.4 = bbb81648164c48361e3fd0e1a058dc93


# All the components have a completely uniform build: basically untar,
# configure with local prefix, build and install.
$(TOOLKIT_COMPONENTS):
	./scripts/extract-tar $(SOURCE_DIR) \
            $@-$($@_VERSION).tar.bz2 \
            '$(MD5_SUM_$@_$($@_VERSION))' $(TAR_DIRS)
	cd $(SOURCE_DIR)/$@-$($@_VERSION)  &&  \
        ./configure --prefix=$(TOOLKIT_ROOT)
	make -C $(SOURCE_DIR)/$@-$($@_VERSION) install

$(TOOLKIT_ROOT):
	mkdir -p $(SOURCE_DIR) $(TOOLKIT_ROOT)
	make m4
	make autoconf
	make automake
	make libtool

toolkit: $(TOOLKIT_ROOT)
-------------- next part --------------
--
For unsubscribe information see http://sourceware.org/lists.html#faq


More information about the crossgcc mailing list