1*d0e51869Samw#!/bin/ksh -p 2*d0e51869Samw# 3*d0e51869Samw# CDDL HEADER START 4*d0e51869Samw# 5*d0e51869Samw# The contents of this file are subject to the terms of the 6*d0e51869Samw# Common Development and Distribution License (the "License"). 7*d0e51869Samw# You may not use this file except in compliance with the License. 8*d0e51869Samw# 9*d0e51869Samw# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*d0e51869Samw# or http://www.opensolaris.org/os/licensing. 11*d0e51869Samw# See the License for the specific language governing permissions 12*d0e51869Samw# and limitations under the License. 13*d0e51869Samw# 14*d0e51869Samw# When distributing Covered Code, include this CDDL HEADER in each 15*d0e51869Samw# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*d0e51869Samw# If applicable, add the following below this CDDL HEADER, with the 17*d0e51869Samw# fields enclosed by brackets "[]" replaced with your own identifying 18*d0e51869Samw# information: Portions Copyright [yyyy] [name of copyright owner] 19*d0e51869Samw# 20*d0e51869Samw# CDDL HEADER END 21*d0e51869Samw# 22*d0e51869Samw# 23*d0e51869Samw# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*d0e51869Samw# Use is subject to license terms. 25*d0e51869Samw# 26*d0e51869Samw# ident "%Z%%M% %I% %E% SMI" 27*d0e51869Samw# 28*d0e51869Samw 29*d0e51869Samw# This is a wrapper script around the ndrgen compiler (ndrgen1). 30*d0e51869Samw# CC must be defined in the environment or on the command line. 31*d0e51869Samw 32*d0e51869SamwNDRPROG="${0%/*}/ndrgen1" 33*d0e51869SamwINCDIR=${ROOT}/usr/include/smbsrv 34*d0e51869Samw 35*d0e51869SamwPROGNAME=`basename $0` 36*d0e51869Samw 37*d0e51869Samwndrgen_usage() 38*d0e51869Samw{ 39*d0e51869Samw if [[ $1 != "" ]] ; then 40*d0e51869Samw print "$PROGNAME: ERROR: $1" 41*d0e51869Samw fi 42*d0e51869Samw 43*d0e51869Samw echo "usage: $PROGNAME [-Y cpp-path] file [file]..." 44*d0e51869Samw exit 1 45*d0e51869Samw} 46*d0e51869Samw 47*d0e51869Samwif [[ $# -lt 1 ]] ; then 48*d0e51869Samw ndrgen_usage 49*d0e51869Samwfi 50*d0e51869Samw 51*d0e51869Samwwhile getopts "Y" FLAG $*; do 52*d0e51869Samw case $FLAG in 53*d0e51869Samw Y) 54*d0e51869Samw CC_FLAG="y" 55*d0e51869Samw ;; 56*d0e51869Samw *) 57*d0e51869Samw ndrgen_usage 58*d0e51869Samw ;; 59*d0e51869Samw esac 60*d0e51869Samwdone 61*d0e51869Samw 62*d0e51869Samwif [[ $CC_FLAG = "y" ]] ; then 63*d0e51869Samw shift $(($OPTIND - 1)) 64*d0e51869Samw 65*d0e51869Samw if [[ $# -lt 1 ]] ; then 66*d0e51869Samw ndrgen_usage "C pre-processor path is missing" 67*d0e51869Samw else 68*d0e51869Samw CC=$1 69*d0e51869Samw shift $(($OPTIND - 1)) 70*d0e51869Samw 71*d0e51869Samw # Check for cw being invoked with -_cc 72*d0e51869Samw if [[ $1 = "-_cc" ]] ; then 73*d0e51869Samw CC_ARG=$1 74*d0e51869Samw shift $(($OPTIND - 1)) 75*d0e51869Samw fi 76*d0e51869Samw fi 77*d0e51869Samwfi 78*d0e51869Samw 79*d0e51869Samwif [[ $CC = "" ]] ; then 80*d0e51869Samw ndrgen_usage "C pre-processor is not defined" 81*d0e51869Samwfi 82*d0e51869Samw 83*d0e51869Samwif [ ! -f $CC ] || [ ! -x $CC ] ; then 84*d0e51869Samw ndrgen_usage "cannot run $CC" 85*d0e51869Samwfi 86*d0e51869Samw 87*d0e51869Samwfor i 88*d0e51869Samwdo 89*d0e51869Samw if [[ ! -r $i ]] ; then 90*d0e51869Samw print "$PROGNAME: ERROR: cannot read $i" 91*d0e51869Samw exit 1 92*d0e51869Samw fi 93*d0e51869Samw 94*d0e51869Samw BASENAME=`basename $i .ndl` 95*d0e51869Samw TMP_NAME=$BASENAME.ndl.c 96*d0e51869Samw 97*d0e51869Samw cp $i $TMP_NAME 98*d0e51869Samw 99*d0e51869Samw if $CC $CC_ARG -E -D__a64 -D__EXTENSIONS__ -D_FILE_OFFSET_BITS=64 \ 100*d0e51869Samw -I. -I${INCDIR} -I${INCDIR}/ndl -DNDRGEN $TMP_NAME | \ 101*d0e51869Samw $NDRPROG > $BASENAME.raw 102*d0e51869Samw then 103*d0e51869Samw cat - << EOF > ${BASENAME}_ndr.c 104*d0e51869Samw/* 105*d0e51869Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 106*d0e51869Samw * Use is subject to license terms. 107*d0e51869Samw */ 108*d0e51869Samw 109*d0e51869Samw#pragma ident "@(#)${BASENAME}_ndr.c 1.2 07/01/07 SMI" 110*d0e51869Samw 111*d0e51869Samw/* 112*d0e51869Samw * THIS FILE IS GENERATED. DO NOT EDIT IT 113*d0e51869Samw */ 114*d0e51869Samw#include <strings.h> 115*d0e51869Samw#include <smbsrv/ndr.h> 116*d0e51869Samw#include <smbsrv/ndl/$BASENAME.ndl> 117*d0e51869SamwEOF 118*d0e51869Samw 119*d0e51869Samw cat $BASENAME.raw >> ${BASENAME}_ndr.c 120*d0e51869Samw 121*d0e51869Samw rm -f $BASENAME.raw 122*d0e51869Samw rm -f $TMP_NAME 123*d0e51869Samw else 124*d0e51869Samw rm -f $BASENAME.raw 125*d0e51869Samw rm -f $TMP_NAME 126*d0e51869Samw exit 1 127*d0e51869Samw fi 128*d0e51869Samwdone 129