2016-08-23 05:59:02 +02:00
#! /bin/sh
if [ $# -eq 0 ] ; then
# With no args, read stdin to scrape compiler output.
set -- $( while read LINE; do
case " $LINE " in
*undefined\ reference\ to*)
LINE = ${ LINE #*undefined reference to \` }
echo ${ LINE % \' * }
; ;
*)
continue
; ;
esac ; done | sort -u)
fi
for SYMBOL; do
2017-10-29 11:59:04 +01:00
WHERE = $( grep -nH " ^[a-zA-Z0-9_ (),]* [*]* $SYMBOL ( " */*.h )
2016-08-23 05:59:02 +02:00
if [ x" $WHERE " != x ] ; then
STUB = '\n{ fprintf(stderr, "' $SYMBOL ' called!\\n"); abort(); }'
else
2017-10-29 11:59:04 +01:00
echo " /* Could not find declaration for $SYMBOL */ "
continue
2016-08-23 05:59:02 +02:00
fi
2017-12-10 13:41:10 +01:00
2016-08-23 05:59:02 +02:00
echo " /* Generated stub for $SYMBOL */ "
FILE = ${ WHERE %% : * }
FILE_AND_LINE = ${ WHERE % : * }
LINE = ${ FILE_AND_LINE #* : }
END = $( tail -n +$LINE < $FILE | grep -n ';$' ) ;
NUM = ${ END %% : * }
2017-10-29 11:59:04 +01:00
tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NORETURN//g' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed " s/;\$/ $STUB / " | sed 's/\s*$//'
2016-08-23 05:59:02 +02:00
done