blob: eef549bce10d327a67bdfe42bfaa92d07656d103 [file] [log] [blame]
#!/bin/bash -e
# This is a helper script that compiles .out files for the cRIO. It is designed
# to be called as a replacement for g++ being used as a linker.
# All the flags except -shared.
INPUTS_FLAGS=`echo "$@" | sed 's/-shared//g'`
# The arguments after any -o flags.
OUTPUT=`echo ${INPUTS_FLAGS} | awk \
'BEGIN { RS=" " }; output { print ; output = 0 }; /-o/ { output = 1 }'`
# All arguments that don't start with a - and aren't ${OUTPUT}.
#INPUTS=`echo ${INPUTS_FLAGS} | sed "s:-[^ ]*::g; s:${OUTPUT}::g;"`
INPUTS=`echo ${INPUTS_FLAGS} | awk \
'BEGIN { RS=" " }; /-Wl,--no-whole-archive/ { output = 0 }; \
output { print }; \
/-Wl,--whole-archive/ { output = 1 }'`
TEMPDIR=`dirname ${OUTPUT}`
AOS=`dirname $0`/..
powerpc-wrs-vxworks-nm ${INPUTS} | \
tclsh ${WIND_BASE}/host/resource/hutils/tcl/munch.tcl -c ppc > ${TEMPDIR}/ctdt.c
powerpc-wrs-vxworks-gcc -I${AOS}/.. -c ${TEMPDIR}/ctdt.c -o ${TEMPDIR}/ctdt.o
powerpc-wrs-vxworks-nm ${INPUTS} | \
${AOS}/build/create_aos_ctdt.sh > ${TEMPDIR}/aos_ctdt.c
powerpc-wrs-vxworks-gcc -I${AOS}/.. -c ${TEMPDIR}/aos_ctdt.c -o ${TEMPDIR}/aos_ctdt.o
powerpc-wrs-vxworks-g++ ${INPUTS_FLAGS} ${TEMPDIR}/ctdt.o ${TEMPDIR}/aos_ctdt.o
ln -f ${OUTPUT} `echo ${OUTPUT} | sed 's/lib\([A-Za-z0-9_]*\)\.so$/\1.out/'`