summaryrefslogtreecommitdiff
path: root/source3/script/mkproto.sh.in
blob: 8d7d300ff5df20c54c4f3ebafebf9a8d50dc80ff (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
#! /bin/sh -x

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

# Need reference point for "mkproto.awk", including when "srcdir != builddir".
# Use of "abs_..." is unpleasant.  Is there another way?
abs_srcdir=@abs_srcdir@

if [ $# -lt 3 ]
then
  echo "Usage: $0 awk [-h headerdefine] outputheader proto_obj"
  exit 1
fi

awk="$1"
shift

if [ x"$1" = x-h ]
then
  headeropt="-v headername=$2"
  shift; shift;
else
  headeropt=""
fi

header="$1"
shift
headertmp="$header.$$.tmp~"

proto_src="`echo $@ | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort | uniq | egrep -v 'ubiqx/|wrapped'`"

echo creating $header

mkdir -p `dirname $header`

${awk} $headeropt \
  -f $abs_srcdir/mkproto.awk $proto_src > $headertmp

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