1997-09-26 08:37:02 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
1999-09-25 09:29:27 +04:00
|
|
|
# $NetBSD: mkinit.sh,v 1.2 1999/09/25 05:29:27 enami Exp $
|
1997-09-26 08:37:02 +04:00
|
|
|
#
|
|
|
|
# Generate the init.c file on stdout.
|
|
|
|
# Arguments are names of *.o files.
|
|
|
|
|
|
|
|
# Run awk on the (edited) output of nm, i.e:
|
|
|
|
# 00000000 T _initialize_xxxx
|
|
|
|
# and turn it into a list of function calls.
|
|
|
|
|
|
|
|
# Which awk do we use? (awk,gawk,nawk?)
|
|
|
|
awk=${AWK:-awk}
|
|
|
|
|
1999-09-25 09:29:27 +04:00
|
|
|
# $NM may be a name of nm command for cross compilation. The default
|
|
|
|
# value here is a default when you invoke this script manually.
|
|
|
|
nm=${NM:-nm}
|
|
|
|
|
1997-09-26 08:37:02 +04:00
|
|
|
# Does the compiler prepend an underscore?
|
1999-09-25 09:29:27 +04:00
|
|
|
if ($nm version.o |grep -q ' _version')
|
1997-09-26 08:37:02 +04:00
|
|
|
then
|
|
|
|
sedarg='s/ _/ /'
|
|
|
|
else
|
|
|
|
sedarg=
|
|
|
|
fi
|
|
|
|
# echo "mkinit.sh: sedarg=$sedarg" >&2
|
|
|
|
|
|
|
|
echo '/* Do not modify this file. */'
|
|
|
|
echo '/* It is created automatically by the Makefile. */'
|
|
|
|
echo 'void initialize_all_files () {'
|
|
|
|
|
|
|
|
for f
|
|
|
|
do
|
1999-09-25 09:29:27 +04:00
|
|
|
$nm -p $f
|
1997-09-26 08:37:02 +04:00
|
|
|
done |
|
|
|
|
sed -e "$sedarg" |
|
|
|
|
$awk '
|
|
|
|
function doit(str) {
|
|
|
|
printf(" {extern void %s (); %s ();}\n", str, str);
|
|
|
|
}
|
|
|
|
/ T _initialize_/ {
|
|
|
|
doit($3);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
{ next; }
|
|
|
|
'
|
|
|
|
|
|
|
|
echo '}'
|
|
|
|
|
|
|
|
exit 0
|