author | amw |
Mon, 29 Oct 2007 16:16:37 -0700 | |
changeset 5366 | 5a99671e8d50 |
parent 5311 | 05e4ca164d13 |
child 7183 | e96caf694e64 |
permissions | -rwxr-xr-x |
5311 | 1 |
#!/bin/ksh -p |
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 2007 Sun Microsystems, Inc. All rights reserved. |
|
24 |
# Use is subject to license terms. |
|
25 |
# |
|
26 |
# ident "%Z%%M% %I% %E% SMI" |
|
27 |
# |
|
28 |
||
29 |
# This is a wrapper script around the ndrgen compiler (ndrgen1). |
|
30 |
# CC must be defined in the environment or on the command line. |
|
31 |
||
32 |
NDRPROG="${0%/*}/ndrgen1" |
|
33 |
INCDIR=${ROOT}/usr/include/smbsrv |
|
34 |
||
35 |
PROGNAME=`basename $0` |
|
36 |
||
37 |
ndrgen_usage() |
|
38 |
{ |
|
39 |
if [[ $1 != "" ]] ; then |
|
40 |
print "$PROGNAME: ERROR: $1" |
|
41 |
fi |
|
42 |
||
43 |
echo "usage: $PROGNAME [-Y cpp-path] file [file]..." |
|
44 |
exit 1 |
|
45 |
} |
|
46 |
||
47 |
if [[ $# -lt 1 ]] ; then |
|
48 |
ndrgen_usage |
|
49 |
fi |
|
50 |
||
51 |
while getopts "Y" FLAG $*; do |
|
52 |
case $FLAG in |
|
53 |
Y) |
|
54 |
CC_FLAG="y" |
|
55 |
;; |
|
56 |
*) |
|
57 |
ndrgen_usage |
|
58 |
;; |
|
59 |
esac |
|
60 |
done |
|
61 |
||
62 |
if [[ $CC_FLAG = "y" ]] ; then |
|
63 |
shift $(($OPTIND - 1)) |
|
64 |
||
65 |
if [[ $# -lt 1 ]] ; then |
|
66 |
ndrgen_usage "C pre-processor path is missing" |
|
67 |
else |
|
68 |
CC=$1 |
|
69 |
shift $(($OPTIND - 1)) |
|
70 |
||
5366
5a99671e8d50
6617183 CIFS Service - PSARC 2006/715 (fix merge, unref, versioning)
amw
parents:
5311
diff
changeset
|
71 |
# Check for cw being invoked with -_cc or -_gcc |
5a99671e8d50
6617183 CIFS Service - PSARC 2006/715 (fix merge, unref, versioning)
amw
parents:
5311
diff
changeset
|
72 |
if [[ $1 = "-_cc" || $1 = "-_gcc" ]] ; then |
5311 | 73 |
CC_ARG=$1 |
74 |
shift $(($OPTIND - 1)) |
|
75 |
fi |
|
76 |
fi |
|
77 |
fi |
|
78 |
||
79 |
if [[ $CC = "" ]] ; then |
|
80 |
ndrgen_usage "C pre-processor is not defined" |
|
81 |
fi |
|
82 |
||
83 |
if [ ! -f $CC ] || [ ! -x $CC ] ; then |
|
84 |
ndrgen_usage "cannot run $CC" |
|
85 |
fi |
|
86 |
||
87 |
for i |
|
88 |
do |
|
89 |
if [[ ! -r $i ]] ; then |
|
90 |
print "$PROGNAME: ERROR: cannot read $i" |
|
91 |
exit 1 |
|
92 |
fi |
|
93 |
||
94 |
BASENAME=`basename $i .ndl` |
|
95 |
TMP_NAME=$BASENAME.ndl.c |
|
96 |
||
97 |
cp $i $TMP_NAME |
|
98 |
||
99 |
if $CC $CC_ARG -E -D__a64 -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 \ |
|
100 |
-I. -I${INCDIR} -I${INCDIR}/ndl -DNDRGEN $TMP_NAME | \ |
|
101 |
$NDRPROG > $BASENAME.raw |
|
102 |
then |
|
103 |
cat - << EOF > ${BASENAME}_ndr.c |
|
104 |
/* |
|
105 |
* Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
|
106 |
* Use is subject to license terms. |
|
107 |
*/ |
|
108 |
||
109 |
#pragma ident "@(#)${BASENAME}_ndr.c 1.2 07/01/07 SMI" |
|
110 |
||
111 |
/* |
|
112 |
* THIS FILE IS GENERATED. DO NOT EDIT IT |
|
113 |
*/ |
|
114 |
#include <strings.h> |
|
115 |
#include <smbsrv/ndr.h> |
|
116 |
#include <smbsrv/ndl/$BASENAME.ndl> |
|
117 |
EOF |
|
118 |
||
119 |
cat $BASENAME.raw >> ${BASENAME}_ndr.c |
|
120 |
||
121 |
rm -f $BASENAME.raw |
|
122 |
rm -f $TMP_NAME |
|
123 |
else |
|
124 |
rm -f $BASENAME.raw |
|
125 |
rm -f $TMP_NAME |
|
126 |
exit 1 |
|
127 |
fi |
|
128 |
done |