WHATSNEW: Update changes.
[nivanova/samba-autobuild/.git] / librpc / build_idl.sh
1 #!/bin/sh
2
3 if [ "$1" = "--full" ]; then
4         FULL=1
5         shift 1
6 else
7         FULL=0
8 fi
9
10 ARGS="--outputdir $PIDL_OUTPUTDIR --header --ndr-parser --samba3-ndr-server --samba3-ndr-client --server --client --python --dcom-proxy --com-header $PIDL_ARGS --"
11 IDL_FILES="$*"
12
13 oldpwd=`pwd`
14 cd ${srcdir}
15
16 [ -d $PIDL_OUTPUTDIR ] || mkdir -p $PIDL_OUTPUTDIR || exit 1
17
18 PIDL="$PIDL $ARGS"
19
20 if [ $FULL = 1 ]; then
21         echo "Rebuilding all idl files"
22         $PIDL $IDL_FILES || exit 1
23         exit 0
24 fi
25
26 ##
27 ## Find newer files rather than rebuild all of them
28 ##
29
30 list=""
31 for f in ${IDL_FILES}; do
32         b=`basename $f .idl`
33         outfiles="cli_$b.c $b.h ndr_${b}_c.c ndr_$b.h ndr_${b}_s.c srv_$b.c"
34         outfiles="$outfiles cli_$b.h ndr_$b.c ndr_${b}_c.h py_$b.c srv_$b.h"
35
36         for o in $outfiles; do
37             [ -f $PIDL_OUTPUTDIR/$o ] || {
38                 list="$list $f"
39                 break
40             }
41             test "`find $f -newer $PIDL_OUTPUTDIR/$o`" != "" && {
42                 list="$list $f"
43                 break
44             }
45         done
46 done
47
48 ##
49 ## generate the ndr stubs
50 ##
51
52 if [ "x$list" != x ]; then
53         # echo "${PIDL} ${list}"
54         $PIDL $list || exit 1
55 fi
56
57 cd ${oldpwd}
58
59 exit 0