Print this page
1575 untangle libmlrpc ... (libmlrpc)


   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #

  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #


  26 
  27 # This is a wrapper script around the ndrgen compiler (ndrgen1).
  28 # CC must be defined in the environment or on the command line.
  29 
  30 NDRPROG="${0%/*}/ndrgen1"
  31 INCDIR=${ROOT}/usr/include/smbsrv
  32 







  33 PROGNAME=`basename $0`
  34 
  35 ndrgen_usage()
  36 {
  37         if [[ $1 != "" ]] ; then
  38                 print "$PROGNAME: ERROR: $1"
  39         fi
  40 
  41         echo "usage: $PROGNAME [-Y cpp-path] file [file]..."

  42         exit 1
  43 }
  44 
  45 # Copy header text from the input ndl file to the generated ndr C file.
  46 ndrgen_copy_header()
  47 {
  48         ndl_file=$1
  49         ndr_file=$2
  50 

















  51         nawk 'BEGIN { copy=0; }
  52         /^\/\* NDRGEN_HEADER_BEGIN \*\// { copy=1; next; }
  53         /^\/\* NDRGEN_HEADER_END \*\// { copy=0; next; }
  54         /./ { if (copy==1) print; }' < $ndl_file > $ndr_file





  55 }
  56 
  57 if [[ $# -lt 1 ]] ; then
  58         ndrgen_usage
  59 fi
  60 
  61 while getopts "Y" FLAG $*; do

  62         case $FLAG in
  63         Y)
  64                 CC_FLAG="y"
  65                 ;;
  66         *)
  67                 ndrgen_usage
  68                 ;;
  69         esac
  70 done

  71 
  72 if [[ $CC_FLAG = "y" ]] ; then
  73         shift $(($OPTIND - 1))
  74 
  75         if [[ $# -lt 1 ]] ; then
  76                 ndrgen_usage "C pre-processor path is missing"
  77         else
  78                 CC=$1
  79                 shift $(($OPTIND - 1))
  80 
  81                 # Check for cw being invoked with -_cc or -_gcc
  82                 if [[ $1 = "-_cc" || $1 = "-_gcc" ]] ; then
  83                         CC_ARG=$1
  84                         shift $(($OPTIND - 1))
  85                 fi
  86         fi
  87 fi
  88 
  89 if [[ $CC = "" ]] ; then
  90         ndrgen_usage "C pre-processor is not defined"
  91 fi
  92 
  93 if [ ! -f $CC ] || [ ! -x $CC ] ; then
  94         ndrgen_usage "cannot run $CC"
  95 fi
  96 
  97 for i
  98 do
  99         if [[ ! -r $i ]] ; then
 100                 print "$PROGNAME: ERROR: cannot read $i"
 101                 exit 1
 102         fi
 103 
 104         BASENAME=`basename $i .ndl`
 105         TMP_NAME=$BASENAME.ndl.c
 106 
 107         cp $i $TMP_NAME
 108 
 109         if $CC $CC_ARG -E  -D__a64 -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 \
 110                 -I. -I${INCDIR} -I${INCDIR}/ndl -DNDRGEN $TMP_NAME | \
 111                 $NDRPROG > $BASENAME.raw
 112         then
 113                 touch ${BASENAME}_ndr.c
 114                 ndrgen_copy_header $i ${BASENAME}_ndr.c
 115 
 116                 cat - << EOF >> ${BASENAME}_ndr.c
 117 /*
 118  * Please do not edit this file.
 119  * It was generated using ndrgen.
 120  */
 121 
 122 #include <strings.h>
 123 #include <smbsrv/ndr.h>
 124 #include <smbsrv/ndl/$BASENAME.ndl>
 125 EOF
 126 
 127                 cat $BASENAME.raw >> ${BASENAME}_ndr.c
 128 
 129                 rm -f $BASENAME.raw
 130                 rm -f $TMP_NAME
 131         else
 132                 rm -f $BASENAME.raw
 133                 rm -f $TMP_NAME
 134                 exit 1
 135         fi
 136 done


   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  28 #
  29 
  30 # This is a wrapper script around the ndrgen compiler (ndrgen1).

  31 
  32 NDRPROG="${0}1"

  33 
  34 # Note: most *.ndl files require an ANSI-compatible cpp,
  35 # so we can NOT use /usr/lib/cpp or /usr/ccs/lib/cpp
  36 # Wish there was an easier way to get an ANSI cpp.
  37 CPP="${CC} -E"
  38 CPPFLAGS="-DNDRGEN"
  39 V_FLAG=
  40 
  41 PROGNAME=`basename $0`
  42 
  43 ndrgen_usage()
  44 {
  45         if [[ $1 != "" ]] ; then
  46                 print "$PROGNAME: ERROR: $1"
  47         fi
  48 
  49         echo "usage: $PROGNAME [options] file.ndl [file.ndl]..."
  50         echo "  options: -Y cc-path -Ddefine -Iinclude"
  51         exit 1
  52 }
  53 
  54 # Process the input ndl file ($1) generating C code on stdout.
  55 process()
  56 {


  57 
  58         # Put the standard top matter
  59         #
  60         # Want the include directive to have just
  61         # include "file.ndl" (no path) so...
  62         inc_ndl=`basename $1`
  63         cat - << EOF
  64 /*
  65  * Please do not edit this file.
  66  * It was generated using ndrgen.
  67  */
  68 
  69 #include <strings.h>
  70 #include <libmlrpc/ndr.h>
  71 #include "$inc_ndl"
  72 EOF
  73 
  74         # Put optional custom top matter
  75         nawk 'BEGIN { copy=0; }
  76         /^\/\* NDRGEN_HEADER_BEGIN \*\// { copy=1; next; }
  77         /^\/\* NDRGEN_HEADER_END \*\// { copy=0; next; }
  78         /./ { if (copy==1) print; }' $1
  79 
  80         # now the real ndrgen output
  81         [ -n "$V_FLAG" ] &&
  82           echo "$CPP $CPPFLAGS $1 | $NDRPROG" >&2
  83         $CPP $CPPFLAGS $1 | $NDRPROG
  84 }
  85 



  86 
  87 while getopts "D:I:Y:V" FLAG
  88 do
  89         case $FLAG in
  90         D|I)    CPPFLAGS="$CPPFLAGS -${FLAG}${OPTARG}";;
  91         Y)      CPP="$OPTARG";;
  92         V)      V_FLAG="V";;
  93         *)      ndrgen_usage;;


  94         esac
  95 done
  96 shift $(($OPTIND - 1))
  97 
  98 if [[ $# -lt 1 ]] ; then
  99         ndrgen_usage













 100 fi
 101 
 102 if [ ! -x $CPP ] ; then
 103         ndrgen_usage "cannot run $CPP"
 104 fi
 105 




 106 for i
 107 do
 108         if [[ ! -r $i ]] ; then
 109                 print "$PROGNAME: ERROR: cannot read $i"
 110                 exit 1
 111         fi
 112 
 113         base=`basename $i .ndl`
 114         process $i > ${base}_ndr.c || {
 115           echo "ndrgen error";
 116           rm ${base}_ndr.c;
 117         }



























 118 done