On Sat, 04 Mar 2000 23:16:09 +0200 (SAST), Carl van Schaik wrote:
> Also, there any way to get automake to compile a .c file to .o and not
> make a library or program out of it?
> I'm doing some cross-compiling stuff that only seems to work if I compile
> files to .o and use the linker to create a binary... this is a pain in
> automake ...
>
> ie. what I do at the moment
>
> ----- Makefile.am -----
> all: led_blink.c
> $(CC) -Wall -DAT91M40400 -I$(top_srcdir)/src/include \
> -c $(srcdir)/led_blink.c -o led_blink.o; \
> $(LD) -Ttext 0x2018000 -e 0x2018000 -o led_blink.bin \
> ../../library/init/lib32/in_main.o led_blink.o \
> ../../library/init/lib32/in_eb01.o \
> ../../library/init/lib32/in_reset.o \
> ../../angel-lib/libangel.arm \
> ../../library/lib32/lib32.arm \
> $(prefix)/arm-AT91-elf/lib/libc.a \
> $(prefix)/lib/gcc-lib/arm-AT91-elf/2.95.2/libgcc.a
This is quite a complicated way of getting things compiled. It can be done
much easier by just passing the correct flags to gcc. I wrote a bootloader
for our StrongARM SA1100 board (see .signature for more info) using
autoconf+automake. Here is my Makefile.am (slightly edited):
---- Makefile.am ----
bin_PROGRAMS = blob-elf32 blob
blob_elf32_SOURCES = start.S command.c main.c flash.c serial.c time.c \
util.c uucodec.c
blob_SOURCES =
EXTRA_DIST = ld-script
blob_elf32_LDFLAGS += -Wl,-T,ld-script
BLOB_elf32_LDADD = -lgcc
blob: blob-elf32
$(OBJCOPY) $(OCFLAGS) $< $@
---- Makefile.am ----
In short, this Makefile.am first builds an elf32 "binary", and then uses
objcopy to create a "real" (i.e., without ELF info) binary image. The key
trick is to hide the linker details in a linker script which you just pass
to gcc (and the configure script also sets some compiler flags). Have a
look at BLOB[1] the bootloader at:
http://www-ict.its.tudelft.nl/~erik/open-source/blob/
If you have a gcc cross compiler to armv4l-unknown-linux, you should be
able to compile BLOB straight out of the box.
Erik
[1] Boot Loader OBject
--
LART. 250 MIPS under one Watt.
http://www-ict.its.tudelft.nl/~erik/open-source/LART/