6e4e049cb7f5d9714c70d14d88fa5544fbc410d5
[nivanova/samba-autobuild/.git] / source4 / script / build_idl.sh
1 #!/bin/sh
2
3 FULLBUILD=$1
4
5 [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
6
7 PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server"
8 EPARSERPIDL="$PERL ./build/pidl/pidl.pl --output $EPARSERPREFIX/ndr_ --parse --header --eparser"
9 TABLES="$PERL ./build/pidl/tables.pl --output librpc/gen_ndr/tables"
10
11 if [ x$FULLBUILD = xFULL ]; then
12       echo Rebuilding all idl files in librpc/idl
13       $PIDL librpc/idl/*.idl || exit 1
14
15       echo Rebuilding IDL tables
16       $TABLES librpc/gen_ndr/ndr_*.h || exit 1
17       exit 0
18 fi
19
20 if [ x$FULLBUILD = xEPARSER ]; then
21       echo Rebuilding all idl files in librpc/idl
22       $EPARSERPIDL librpc/idl/*.idl || exit 1
23       exit 0
24 fi
25
26 list=""
27
28 for f in librpc/idl/*.idl; do
29     basename=`basename $f .idl`
30     ndr="librpc/gen_ndr/ndr_$basename.c"
31     # blergh - most shells don't have the -nt function
32     if [ -f $ndr ]; then
33         if [ x`find $f -newer $ndr -print` = x$f ]; then
34             list="$list $f"
35         fi
36     else 
37         list="$list $f"
38     fi
39 done
40
41 if [ "x$list" != x ]; then
42     $PIDL $list || exit 1
43     $TABLES librpc/gen_ndr/ndr_*.h || exit 1
44 fi
45
46 exit 0