Factorize code from findprovisionusnranges in order to solve bug #8504
[Samba/gbeck.git] / librpc / build_idl.sh
blobafab91044bebd535fe29b90bdfc34d9f3ac4044c
1 #!/bin/sh
3 if [ "$1" = "--full" ]; then
4 FULL=1
5 shift 1
6 else
7 FULL=0
8 fi
10 ARGS="--outputdir $PIDL_OUTPUTDIR --header --ndr-parser --samba3-ndr-server --server --client --python --dcom-proxy --com-header $PIDL_ARGS --"
11 IDL_FILES="$*"
13 oldpwd=`pwd`
14 cd ${srcdir}
16 [ -d $PIDL_OUTPUTDIR ] || mkdir -p $PIDL_OUTPUTDIR || exit 1
18 PIDL="$PIDL $ARGS"
20 if [ $FULL = 1 ]; then
21 echo "Rebuilding all idl files"
22 $PIDL $IDL_FILES || exit 1
23 exit 0
27 ## Find newer files rather than rebuild all of them
30 list=""
31 for f in ${IDL_FILES}; do
32 b=`basename $f .idl`
33 outfiles="$b.h ndr_${b}_c.c ndr_$b.h ndr_${b}_s.c srv_$b.c"
34 outfiles="$outfiles ndr_$b.c ndr_${b}_c.h py_$b.c srv_$b.h"
36 for o in $outfiles; do
37 [ -f $PIDL_OUTPUTDIR/$o ] || {
38 list="$list $f"
39 break
41 test "`find $f -newer $PIDL_OUTPUTDIR/$o`" != "" && {
42 list="$list $f"
43 break
45 done
46 done
49 ## generate the ndr stubs
52 if [ "x$list" != x ]; then
53 # echo "${PIDL} ${list}"
54 $PIDL $list || exit 1
57 cd ${oldpwd}
59 exit 0