blob: eef549bce10d327a67bdfe42bfaa92d07656d103 [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#!/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.
7INPUTS_FLAGS=`echo "$@" | sed 's/-shared//g'`
8# The arguments after any -o flags.
9OUTPUT=`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;"`
13INPUTS=`echo ${INPUTS_FLAGS} | awk \
14 'BEGIN { RS=" " }; /-Wl,--no-whole-archive/ { output = 0 }; \
15 output { print }; \
16 /-Wl,--whole-archive/ { output = 1 }'`
17TEMPDIR=`dirname ${OUTPUT}`
18AOS=`dirname $0`/..
19powerpc-wrs-vxworks-nm ${INPUTS} | \
20 tclsh ${WIND_BASE}/host/resource/hutils/tcl/munch.tcl -c ppc > ${TEMPDIR}/ctdt.c
21powerpc-wrs-vxworks-gcc -I${AOS}/.. -c ${TEMPDIR}/ctdt.c -o ${TEMPDIR}/ctdt.o
22powerpc-wrs-vxworks-nm ${INPUTS} | \
23 ${AOS}/build/create_aos_ctdt.sh > ${TEMPDIR}/aos_ctdt.c
24powerpc-wrs-vxworks-gcc -I${AOS}/.. -c ${TEMPDIR}/aos_ctdt.c -o ${TEMPDIR}/aos_ctdt.o
25powerpc-wrs-vxworks-g++ ${INPUTS_FLAGS} ${TEMPDIR}/ctdt.o ${TEMPDIR}/aos_ctdt.o
26ln -f ${OUTPUT} `echo ${OUTPUT} | sed 's/lib\([A-Za-z0-9_]*\)\.so$/\1.out/'`