[OT] making software easily cross-compilable
Dave Korn
dave.korn@artimi.com
Fri Apr 28 18:48:00 GMT 2006
On 28 April 2006 12:53, Robert P. J. Day wrote:
> On Fri, 28 Apr 2006, Dave Korn wrote:
>
>> On 28 April 2006 12:08, Robert P. J. Day wrote:
>
>>> even more generally, the build process might need access to
>>> *both* the cross-compile tools and the native tools (like the
>>> linux kernel does), so you might see:
>>>
>>> CC := ${CROSS_COMPILE}cc
>>> LD := ${CROSS_COMPILE}ld
>>>
>>> and another set for the native tools:
>>>
>>> HOSTCC = gcc
>>> HOSTLD = ld
>>>
>>> etc.
>>
>> In GNU terms, these would be CC/LD and
>> CC_FOR_TARGET/LD_FOR_TARGET.
>
> really? i already knew that was another approach but it seems far
> more cumbersome. it seems so much more straightforward to use the
> *generic* variables (CC, LD, ...) for *whatever* target you're
> building for, and have to *override* with HOSTCC, HOSTLD just in case
> you need to some native building.
Actually I was thinking of CFLAGS_FOR_TARGET when I wrote that, I'm not
actually sure how the cross-tool names are defined.... let me just dig out an
old build log and take a look at the submake invocations. Ah, here's a cygwin
build:
make "AR_FLAGS=rc" "CC_FOR_BUILD=gcc" "CFLAGS=-O2 -g -O2 "
"CFLAGS_FOR_BUILD=-g -O2" "CFLAGS_FOR_TARGET=-O2 -g -O2 "
"INSTALL=/usr/bin/install -c" "LDFLAGS=" "LIBCFLAGS=-O2 -g -O2 "
"LIBCFLAGS_FOR_TARGET=-O2 -g -O2 " "MAKE=make" "MAKEINFO=makeinfo
--split-size=5000000 --split-size=5000000 " "PICFLAG="
"PICFLAG_FOR_TARGET=" "SHELL=/bin/sh" "EXPECT=expect"
"RUNTEST=runtest" "RUNTESTFLAGS="
"exec_prefix=/usr/build/install" "infodir=/usr/build/install/info"
"libdir=/usr/build/install/lib" "prefix=/usr/build/install"
"tooldir=/usr/build/install/i686-pc-cygwin"
"top_toollibdir=/usr/build/install/i686-pc-cygwin/lib" "AR=ar"
"AS=as" "CC=gcc -L/usr/build/obj-winsup/i686-pc-cygwin/winsup
-L/usr/build/obj-winsup/i686-pc-cygwin/winsup/cygwin
-L/usr/build/obj-winsup/i686-pc-cygwin/winsup/w32api/lib -isystem
/usr/build/src-winsup/winsup/include -isystem
/usr/build/src-winsup/winsup/cygwin/include -isystem
/usr/build/src-winsup/winsup/w32api/include
-B/usr/build/obj-winsup/i686-pc-cygwin/newlib/ -isystem
/usr/build/obj-winsup/i686-pc-cygwin/newlib/targ-include -isystem
/usr/build/src-winsup/newlib/libc/include
-I/usr/build/src-winsup/winsup/cygwin/include"
"LD=/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld.exe"
"LIBCFLAGS=-O2 -g -O2 " "NM=nm" "PICFLAG="
"RANLIB=ranlib" "DESTDIR=" DO=all multi-do # make
and here's one from a gcc build:
make GCC_FOR_TARGET="/repository/gcc-build/linux/gcc/gcc/xgcc
-B/repository/gcc-build/linux/gcc/gcc/ -B/artimi/tools/cygwin/arm-linux/bin/
-B/artimi/tools/cygwin/arm-linux/lib/ -isystem
/artimi/tools/cygwin/arm-linux/include" \
BUILD_PREFIX="" BUILD_PREFIX_1="loser-" \
AR_FOR_TARGET="arm-linux-ar" \
AR_CREATE_FOR_TARGET="arm-linux-ar rc" \
AR_FLAGS_FOR_TARGET="" \
CFLAGS="-g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long " \
RANLIB_FOR_TARGET="arm-linux-ranlib" \
RANLIB_TEST_FOR_TARGET="[ -f arm-linux-ranlib ] || ( [ "i686-pc-cygwin" =
"arm-unknown-linux-gnu" ] && [ -f /usr/bin/ranlib -o -f /bin/ranlib ] )" \
NM_FOR_TARGET="/artimi/tools/cygwin/arm-linux/bin/nm.exe" AWK="gawk" \
LIBGCC2_CFLAGS="-O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings
-Wstrict-prototypes -Wmissing-prototypes -isystem ./include
-fomit-frame-pointer -fPIC -g0 -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2
-D__GCC_FLOAT_NOT_NEEDED " \
INCLUDES="-I. -I. -I/tools/external_source/gnu/gcc-3.3.3/gcc
-I/tools/external_source/gnu/gcc-3.3.3/gcc/.
-I/tools/external_source/gnu/gcc-3.3.3/gcc/config
-I/tools/external_source/gnu/gcc-3.3.3/gcc/../include" \
CONFIG_H="tconfig.h " MACHMODE_H="machmode.h machmode.def
/tools/external_source/gnu/gcc-3.3.3/gcc/config/arm/arm-modes.def" \
LIB1ASMSRC='arm/lib1funcs.asm' \
MAKEOVERRIDES= \
-f libgcc.mk all
> doing it that way would certainly allow existing makefiles to be
> quickly cross-compilable. i certainly wouldn't want to have to write
> new makefiles loaded with "_FOR_TARGET" suffixes everywhere. barf.
Well, autotools do all that for you. Which is where we came in!
cheers,
DaveK
--
Can't think of a witty .sigline today....
--
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc
mailing list