summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/gdb/mkinit.sh
blob: baa001f3735632109fbfa289dc65a298d56854e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# $NetBSD: mkinit.sh,v 1.2 1999/09/25 05:29:27 enami Exp $
#
# 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}

# $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}

# Does the compiler prepend an underscore?
if ($nm version.o |grep -q ' _version')
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
  $nm -p $f
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