summaryrefslogtreecommitdiff
path: root/source3/script/mksyms.sh
blob: 673c77a3cfab58dcd59f1f6cd61c75010f7c48d6 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh

#
# mksyms.sh
#
# Extract symbols to export from C-header files.
# output in version-script format for linking shared libraries.
#
# This is the shell warpper for the mksyms.awk core script.
#
# Copyright (C) 2008 Micheal Adam <obnox@samba.org>
#

LANG=C; export LANG
LC_ALL=C; export LC_ALL
LC_COLLATE=C; export LC_COLLATE

if [ $# -lt 3 ]
then
  echo "Usage: $0 awk versionfile output_file header_files"
  exit 1
fi

awk="$1"
shift

versionfile="$1"
shift

symsfile="$1"
shift
symsfile_tmp="$symsfile.$$.tmp~"

libname=`basename $symsfile | cut -d '.' -f1`
verline=`grep $libname $versionfile`
majver=`echo -n "$verline" | cut -d ':' -f2`
minver=`echo -n "$verline" | cut -d ':' -f3`
upname=`echo -n "$libname" | sed -e 's/^lib//' | tr '[a-z]' '[A-Z]'`
symver="${upname}_${majver}.${minver}"

symsext=`basename $symsfile | cut -d '.' -f2-`

if test x"$symsext" = x"version.syms"; then
	echo "creating $symsfile for $symver"
else
	echo "creating $symsfile"
	symver="# no symbol versioning"
fi

proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `"

mkdir -p `dirname $symsfile`

cat > $symsfile_tmp <<_ACEOF
#
# This file is automatically generated with "$0". DO NOT EDIT
#
$symver
_ACEOF

${awk} -f `dirname $0`/mksyms.awk $proto_src >> $symsfile_tmp

if cmp -s $symsfile $symsfile_tmp 2>/dev/null
then
  echo "$symsfile unchanged"
  rm $symsfile_tmp
else
  mv $symsfile_tmp $symsfile
fi