build: rebuild idl if the pidl compiler is changed
[ddiss/samba.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 --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_CMD="$PIDL $ARGS"
19
20 if [ $FULL = 1 ]; then
21         echo "Rebuilding all idl files"
22         $PIDL_CMD $IDL_FILES || exit 1
23         exit 0
24 fi
25
26 ##
27 ## Find newer files rather than rebuild all of them. Also handle the case
28 ## where the pidl compiler itself is newer.
29 ##
30
31 list=""
32 for f in ${IDL_FILES}; do
33         b=`basename $f .idl`
34         outfiles="$b.h ndr_${b}_c.c ndr_$b.h ndr_${b}_s.c srv_$b.c"
35         outfiles="$outfiles ndr_$b.c ndr_${b}_c.h py_$b.c srv_$b.h"
36
37         for o in $outfiles; do
38             [ -f $PIDL_OUTPUTDIR/$o ] || {
39                 list="$list $f"
40                 break
41             }
42             test "`find $f -newer $PIDL_OUTPUTDIR/$o`" != "" && {
43                 list="$list $f"
44                 break
45             }
46             test "`find $PIDL -newer $PIDL_OUTPUTDIR/$o`" != "" && {
47                 list="$list $f"
48                 break
49             }
50         done
51 done
52
53 ##
54 ## generate the ndr stubs
55 ##
56
57 if [ "x$list" != x ]; then
58         # echo "${PIDL_CMD} ${list}"
59         $PIDL_CMD $list || exit 1
60 fi
61
62 cd ${oldpwd}
63
64 exit 0