brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame^] | 1 | #!/bin/bash -e |
| 2 | |
| 3 | # This is a helper script that compiles .out files for the cRIO. It is designed |
| 4 | # to be called as a replacement for g++ being used as a linker. |
| 5 | |
| 6 | # All the flags except -shared. |
| 7 | INPUTS_FLAGS=`echo "$@" | sed 's/-shared//g'` |
| 8 | # The arguments after any -o flags. |
| 9 | OUTPUT=`echo ${INPUTS_FLAGS} | awk \ |
| 10 | 'BEGIN { RS=" " }; output { print ; output = 0 }; /-o/ { output = 1 }'` |
| 11 | # All arguments that don't start with a - and aren't ${OUTPUT}. |
| 12 | #INPUTS=`echo ${INPUTS_FLAGS} | sed "s:-[^ ]*::g; s:${OUTPUT}::g;"` |
| 13 | INPUTS=`echo ${INPUTS_FLAGS} | awk \ |
| 14 | 'BEGIN { RS=" " }; /-Wl,--no-whole-archive/ { output = 0 }; \ |
| 15 | output { print }; \ |
| 16 | /-Wl,--whole-archive/ { output = 1 }'` |
| 17 | TEMPDIR=`dirname ${OUTPUT}` |
| 18 | AOS=`dirname $0`/.. |
| 19 | powerpc-wrs-vxworks-nm ${INPUTS} | \ |
| 20 | tclsh ${WIND_BASE}/host/resource/hutils/tcl/munch.tcl -c ppc > ${TEMPDIR}/ctdt.c |
| 21 | powerpc-wrs-vxworks-gcc -I${AOS}/.. -c ${TEMPDIR}/ctdt.c -o ${TEMPDIR}/ctdt.o |
| 22 | powerpc-wrs-vxworks-nm ${INPUTS} | \ |
| 23 | ${AOS}/build/create_aos_ctdt.sh > ${TEMPDIR}/aos_ctdt.c |
| 24 | powerpc-wrs-vxworks-gcc -I${AOS}/.. -c ${TEMPDIR}/aos_ctdt.c -o ${TEMPDIR}/aos_ctdt.o |
| 25 | powerpc-wrs-vxworks-g++ ${INPUTS_FLAGS} ${TEMPDIR}/ctdt.o ${TEMPDIR}/aos_ctdt.o |
| 26 | ln -f ${OUTPUT} `echo ${OUTPUT} | sed 's/lib\([A-Za-z0-9_]*\)\.so$/\1.out/'` |