#!/bin/dash | |
set -e | |
OBJCOPY=$1 | |
shift | |
# The arguments after any -o flags. | |
OUTPUT=`echo "$@" | awk \ | |
'BEGIN { RS=" " }; output { print ; output = 0 }; /-o/ { output = 1 }'` | |
DEBUG_DIR=$(dirname $(dirname ${OUTPUT}))/unstripped_files | |
mkdir -p ${DEBUG_DIR} | |
DEBUG_FILE=${DEBUG_DIR}/$(basename ${OUTPUT}).full | |
"$@" | |
cp ${OUTPUT} ${DEBUG_FILE} | |
${OBJCOPY} --strip-debug --add-gnu-debuglink=${DEBUG_FILE} ${OUTPUT} |