Print this page
cw: give cw(1onbld) a new interface allowing for multiple arbitrary shadows
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/ndrgen/ndrgen.sh
+++ new/usr/src/tools/ndrgen/ndrgen.sh
1 1 #!/bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 #
23 23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 26
27 27 # This is a wrapper script around the ndrgen compiler (ndrgen1).
28 28 # CC must be defined in the environment or on the command line.
29 29
30 30 NDRPROG="${0%/*}/ndrgen1"
31 31 INCDIR=${ROOT}/usr/include/smbsrv
32 32
33 33 PROGNAME=`basename $0`
34 34
35 35 ndrgen_usage()
36 36 {
37 37 if [[ $1 != "" ]] ; then
38 38 print "$PROGNAME: ERROR: $1"
39 39 fi
40 40
41 41 echo "usage: $PROGNAME [-Y cpp-path] file [file]..."
42 42 exit 1
43 43 }
44 44
45 45 # Copy header text from the input ndl file to the generated ndr C file.
46 46 ndrgen_copy_header()
47 47 {
48 48 ndl_file=$1
49 49 ndr_file=$2
50 50
51 51 nawk 'BEGIN { copy=0; }
52 52 /^\/\* NDRGEN_HEADER_BEGIN \*\// { copy=1; next; }
53 53 /^\/\* NDRGEN_HEADER_END \*\// { copy=0; next; }
54 54 /./ { if (copy==1) print; }' < $ndl_file > $ndr_file
55 55 }
56 56
57 57 if [[ $# -lt 1 ]] ; then
58 58 ndrgen_usage
59 59 fi
60 60
61 61 while getopts "Y" FLAG $*; do
62 62 case $FLAG in
63 63 Y)
64 64 CC_FLAG="y"
65 65 ;;
66 66 *)
67 67 ndrgen_usage
68 68 ;;
69 69 esac
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
70 70 done
71 71
72 72 if [[ $CC_FLAG = "y" ]] ; then
73 73 shift $(($OPTIND - 1))
74 74
75 75 if [[ $# -lt 1 ]] ; then
76 76 ndrgen_usage "C pre-processor path is missing"
77 77 else
78 78 CC=$1
79 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 80 fi
87 81 fi
88 82
89 83 if [[ $CC = "" ]] ; then
90 84 ndrgen_usage "C pre-processor is not defined"
91 85 fi
92 86
93 -if [ ! -f $CC ] || [ ! -x $CC ] ; then
87 +# Remove the non-cw options
88 +CC=${CC%% -- *}
89 +
90 +if [ ! -f ${CC%% *} ] || [ ! -x ${CC%% *} ] ; then
94 91 ndrgen_usage "cannot run $CC"
95 92 fi
96 93
97 94 for i
98 95 do
99 96 if [[ ! -r $i ]] ; then
100 97 print "$PROGNAME: ERROR: cannot read $i"
101 98 exit 1
102 99 fi
103 100
104 101 BASENAME=`basename $i .ndl`
105 102 TMP_NAME=$BASENAME.ndl.c
106 103
107 104 cp $i $TMP_NAME
108 105
109 - if $CC $CC_ARG -E -D__a64 -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 \
106 + if $CC -E -D__a64 -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 \
110 107 -I. -I${INCDIR} -I${INCDIR}/ndl -DNDRGEN $TMP_NAME | \
111 108 $NDRPROG > $BASENAME.raw
112 109 then
113 110 touch ${BASENAME}_ndr.c
114 111 ndrgen_copy_header $i ${BASENAME}_ndr.c
115 112
116 113 cat - << EOF >> ${BASENAME}_ndr.c
117 114 /*
118 115 * Please do not edit this file.
119 116 * It was generated using ndrgen.
120 117 */
121 118
122 119 #include <strings.h>
123 120 #include <smbsrv/ndr.h>
124 121 #include <smbsrv/ndl/$BASENAME.ndl>
125 122 EOF
126 123
127 124 cat $BASENAME.raw >> ${BASENAME}_ndr.c
128 125
129 126 rm -f $BASENAME.raw
130 127 rm -f $TMP_NAME
131 128 else
132 129 rm -f $BASENAME.raw
133 130 rm -f $TMP_NAME
134 131 exit 1
135 132 fi
136 133 done
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX