r18230: Build Samba3 RPC client<->libndr glue code.
[samba.git] / source / script / build_idl.sh
1 #!/bin/sh
2
3 PIDL_ARGS="--outputdir librpc/gen_ndr --header --ndr-parser --samba3-ndr-client --"
4 PIDL_EXTRA_ARGS="$*"
5
6 oldpwd=`pwd`
7 cd ${srcdir}
8
9 [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
10
11 PIDL="$PERL pidl/pidl ${PIDL_ARGS} ${PIDL_EXTRA_ARGS}"
12
13 ##
14 ## Find newer files rather than rebuild all of them
15 ##
16
17 list=""
18 for f in ${IDL_FILES}; do
19         basename=`basename $f .idl`
20         ndr="librpc/gen_ndr/ndr_$basename.c"
21
22         if [ -f $ndr && 0 ]; then
23                 if [ "x`find librpc/idl/$f -newer $ndr -print`" = "xlibrpc/idl/$f" ]; then
24                         list="$list librpc/idl/$f"
25                 fi
26         else 
27                 list="$list librpc/idl/$f"
28         fi
29 done
30
31 ##
32 ## generate the ndr stubs
33 ##
34
35 if [ "x$list" != x ]; then
36         echo "${PIDL} ${list}"
37         $PIDL $list || exit 1
38 fi
39
40 ##
41 ## Do miscellaneous cleanup
42 ##
43
44 for f in librpc/gen_ndr/ndr_*.c; do
45         cat $f | sed -e 's/^static //g' \
46                 -e 's/^_PUBLIC_ //g' \
47                 -e 's/#include <stdint.h>//g' \
48                 -e 's/#include <stdbool.h>//g' > $f.new
49         /bin/mv -f $f.new $f
50 done
51
52 touch librpc/gen_ndr/ndr_dcerpc.h
53
54 cd ${oldpwd}
55
56 exit 0
57