doc: Fixes for the talloc stealing tutorial.
[Samba/vl.git] / lib / talloc / script / mksyms.sh
blob089344f8f03a79736779181f4add12c70b42a556
1 #! /bin/sh
4 # mksyms.sh
6 # Extract symbols to export from C-header files.
7 # output in version-script format for linking shared libraries.
9 # This is the shell wrapper for the mksyms.awk core script.
11 # Copyright (C) 2008 Micheal Adam <obnox@samba.org>
14 LANG=C; export LANG
15 LC_ALL=C; export LC_ALL
16 LC_COLLATE=C; export LC_COLLATE
18 if [ $# -lt 2 ]
19 then
20 echo "Usage: $0 awk output_file header_files"
21 exit 1
24 awk="$1"
25 shift
27 symsfile="$1"
28 shift
29 symsfile_tmp="$symsfile.$$.tmp~"
31 proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `"
33 echo creating $symsfile
35 mkdir -p `dirname $symsfile`
37 #Write header
38 cat > $symsfile_tmp << EOF
39 # This file is autogenerated, please DO NOT EDIT
41 global:
42 EOF
44 #loop on each header
45 for i in $proto_src; do
46 ${awk} -f `dirname $0`/mksyms.awk $i | sort >> $symsfile_tmp
47 done;
49 #Write tail
50 cat >> $symsfile_tmp << EOF
52 local: *;
54 EOF
56 if cmp -s $symsfile $symsfile_tmp 2>/dev/null
57 then
58 echo "$symsfile unchanged"
59 rm $symsfile_tmp
60 else
61 mv $symsfile_tmp $symsfile