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