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