Use a modified copy of the Makefile from the root of the legOS build tree. It has been modified to understand the rules to convert C and C++ source into firmware download files. (Here is the SREC specification) Just use a make target of your file with a .srec extension:
$ ls
Makefile    avoid.c
$ make avoid.srec
/usr/local/mindstorms/bin/h8300-hitachi-hms-ld -T \
       /usr/local/mindstorms/legOS/h8300.rcx -relax   avoid.o \
       -L /usr/local/mindstorms/legOS/lib \
       /usr/local/mindstorms/legOS/kmain.o -llegOS -lc -lmint -lc++  \
       -o avoid.coff --oformat coff-h8300
chmod a-x avoid.coff
/usr/local/mindstorms/bin/h8300-hitachi-hms-objcopy -I coff-h8300 \
       -O srec  avoid.coff avoid.srec
chmod a-x avoid.srec
rm avoid.coff
The srec file is what is downloaded to the RCX brick. To build programs out of multiple objects, the makefile would need to have a target added for the final program (exactly as it would for normal programs).
Previous - Building the Cross Compiler Main Next - Downloading the SREC Files to the Brick
Monty Stein Dec 18, 1999
CLUG Home