cd $HOME

Autotools and private toolchain

How do you compile code using autotools against a private toolchain?

This is the issue I faced today. I needed to build bash (why does Ubuntu link bash against ncurses?!) against an external toolchain (tree containing specific version of gcc, libc, ld, nm, as, ...).

Sure you can specify CC='your-version-of-gcc' but what about PERL? or even LD? You don’t want to use the gcc from the toolchain and link against your local libc (what about `ldconfig’?).

Here is the solution I came with. Tell me if you have a better one.

In my main makefile, I first define my utils:
YACC            := $(TOOLCHAIN)/bison-2.3/bin/yacc
(do the same for nm, gcc, perl, cp, ...) I then declare explicitly a PATH:
YACC_PATH       := $(shell dirname $(YACC))
TOOLCHAIN_PATH  := $(TOOLCHAIN_PATH):$(YACC_PATH)
And then run the configure script, explicitly redefining PATH in a subshell:
bash-configure:
  PATH=$(TOOLCHAIN_PATH); pushd bash-3.2; \
  $(SHELL) configure $(MYCONFIGUREFLAGS) CC=$(CC) LDFLAGS=$(MYLDFLAGS); \
  popd

Passing the PATH will break the build if a utility is called which has not been explicitly declared (sed, awk, ...) which is good. I don’t want the build to use any of my local tools.

I also pass explicitly when I `make all’ AR, NM, OBJCOPY, STRIP, ... basically all the binutils. It is probably unnecessary, but it is ‘in case of’. Note that you need to double check `ld’ and `as’. If they are configured when you compiled `gcc’ (—with-ld=...), you don’t want to specify them again (that could lead to some strange behaviors).

Also, be sure to check `gcc -print-search-dirs’ for header and library files paths.

Back

Comments



The content of this field is kept private and will not be shown publicly.