1*d90bee97SLionel Sambuc#!/bin/sh - 2*d90bee97SLionel Sambuc# $NetBSD: mkbuiltins,v 1.22 2009/10/06 19:56:58 apb Exp $ 3*d90bee97SLionel Sambuc# 4*d90bee97SLionel Sambuc# Copyright (c) 1991, 1993 5*d90bee97SLionel Sambuc# The Regents of the University of California. All rights reserved. 6*d90bee97SLionel Sambuc# 7*d90bee97SLionel Sambuc# This code is derived from software contributed to Berkeley by 8*d90bee97SLionel Sambuc# Kenneth Almquist. 9*d90bee97SLionel Sambuc# 10*d90bee97SLionel Sambuc# Redistribution and use in source and binary forms, with or without 11*d90bee97SLionel Sambuc# modification, are permitted provided that the following conditions 12*d90bee97SLionel Sambuc# are met: 13*d90bee97SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 14*d90bee97SLionel Sambuc# notice, this list of conditions and the following disclaimer. 15*d90bee97SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 16*d90bee97SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 17*d90bee97SLionel Sambuc# documentation and/or other materials provided with the distribution. 18*d90bee97SLionel Sambuc# 3. Neither the name of the University nor the names of its contributors 19*d90bee97SLionel Sambuc# may be used to endorse or promote products derived from this software 20*d90bee97SLionel Sambuc# without specific prior written permission. 21*d90bee97SLionel Sambuc# 22*d90bee97SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23*d90bee97SLionel Sambuc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*d90bee97SLionel Sambuc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*d90bee97SLionel Sambuc# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26*d90bee97SLionel Sambuc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*d90bee97SLionel Sambuc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*d90bee97SLionel Sambuc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*d90bee97SLionel Sambuc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*d90bee97SLionel Sambuc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*d90bee97SLionel Sambuc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*d90bee97SLionel Sambuc# SUCH DAMAGE. 33*d90bee97SLionel Sambuc# 34*d90bee97SLionel Sambuc# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95 35*d90bee97SLionel Sambuc 36*d90bee97SLionel Sambuchavehist=1 37*d90bee97SLionel Sambucif [ x"$1" = x"-h" ]; then 38*d90bee97SLionel Sambuc havehist=0 39*d90bee97SLionel Sambuc shift 40*d90bee97SLionel Sambucfi 41*d90bee97SLionel Sambuc 42*d90bee97SLionel Sambucshell=$1 43*d90bee97SLionel Sambucbuiltins=$2 44*d90bee97SLionel Sambucobjdir=$3 45*d90bee97SLionel Sambuc 46*d90bee97SLionel Sambuchavejobs=0 47*d90bee97SLionel Sambucif grep '^#define JOBS[ ]*1' ${shell} > /dev/null 48*d90bee97SLionel Sambucthen 49*d90bee97SLionel Sambuc havejobs=1 50*d90bee97SLionel Sambucfi 51*d90bee97SLionel Sambuc 52*d90bee97SLionel Sambucexec <$builtins 3> ${objdir}/builtins.c 4> ${objdir}/builtins.h 53*d90bee97SLionel Sambuc 54*d90bee97SLionel Sambucecho '/* 55*d90bee97SLionel Sambuc * This file was generated by the mkbuiltins program. 56*d90bee97SLionel Sambuc */ 57*d90bee97SLionel Sambuc 58*d90bee97SLionel Sambuc#include "shell.h" 59*d90bee97SLionel Sambuc#include "builtins.h" 60*d90bee97SLionel Sambuc 61*d90bee97SLionel Sambucconst struct builtincmd builtincmd[] = { 62*d90bee97SLionel Sambuc' >&3 63*d90bee97SLionel Sambuc 64*d90bee97SLionel Sambucecho '/* 65*d90bee97SLionel Sambuc * This file was generated by the mkbuiltins program. 66*d90bee97SLionel Sambuc */ 67*d90bee97SLionel Sambuc 68*d90bee97SLionel Sambuc#include <sys/cdefs.h> 69*d90bee97SLionel Sambuc 70*d90bee97SLionel Sambucstruct builtincmd { 71*d90bee97SLionel Sambuc const char *name; 72*d90bee97SLionel Sambuc int (*builtin)(int, char **); 73*d90bee97SLionel Sambuc}; 74*d90bee97SLionel Sambuc 75*d90bee97SLionel Sambucextern const struct builtincmd builtincmd[]; 76*d90bee97SLionel Sambucextern const struct builtincmd splbltincmd[]; 77*d90bee97SLionel Sambuc 78*d90bee97SLionel Sambuc' >&4 79*d90bee97SLionel Sambuc 80*d90bee97SLionel Sambucspecials= 81*d90bee97SLionel Sambuc 82*d90bee97SLionel Sambucwhile read line 83*d90bee97SLionel Sambucdo 84*d90bee97SLionel Sambuc set -- $line 85*d90bee97SLionel Sambuc [ -z "$1" ] && continue 86*d90bee97SLionel Sambuc case "$1" in 87*d90bee97SLionel Sambuc \#if*|\#def*|\#end*) 88*d90bee97SLionel Sambuc echo $line >&3 89*d90bee97SLionel Sambuc echo $line >&4 90*d90bee97SLionel Sambuc continue 91*d90bee97SLionel Sambuc ;; 92*d90bee97SLionel Sambuc \#*) 93*d90bee97SLionel Sambuc continue 94*d90bee97SLionel Sambuc ;; 95*d90bee97SLionel Sambuc esac 96*d90bee97SLionel Sambuc 97*d90bee97SLionel Sambuc func=$1 98*d90bee97SLionel Sambuc shift 99*d90bee97SLionel Sambuc [ x"$1" = x'-j' ] && { 100*d90bee97SLionel Sambuc [ $havejobs = 0 ] && continue 101*d90bee97SLionel Sambuc shift 102*d90bee97SLionel Sambuc } 103*d90bee97SLionel Sambuc [ x"$1" = x'-h' ] && { 104*d90bee97SLionel Sambuc [ $havehist = 0 ] && continue 105*d90bee97SLionel Sambuc shift 106*d90bee97SLionel Sambuc } 107*d90bee97SLionel Sambuc echo 'int '"$func"'(int, char **);' >&4 108*d90bee97SLionel Sambuc while 109*d90bee97SLionel Sambuc [ $# != 0 ] && [ x"$1" != x'#' ] 110*d90bee97SLionel Sambuc do 111*d90bee97SLionel Sambuc [ x"$1" = x'-s' ] && { 112*d90bee97SLionel Sambuc specials="$specials $2 $func" 113*d90bee97SLionel Sambuc shift 2 114*d90bee97SLionel Sambuc continue; 115*d90bee97SLionel Sambuc } 116*d90bee97SLionel Sambuc [ x"$1" = x'-u' ] && shift 117*d90bee97SLionel Sambuc echo ' { "'$1'", '"$func"' },' >&3 118*d90bee97SLionel Sambuc shift 119*d90bee97SLionel Sambuc done 120*d90bee97SLionel Sambucdone 121*d90bee97SLionel Sambuc 122*d90bee97SLionel Sambucecho ' { 0, 0 },' >&3 123*d90bee97SLionel Sambucecho '};' >&3 124*d90bee97SLionel Sambucecho >&3 125*d90bee97SLionel Sambucecho 'const struct builtincmd splbltincmd[] = {' >&3 126*d90bee97SLionel Sambuc 127*d90bee97SLionel Sambucset -- $specials 128*d90bee97SLionel Sambucwhile 129*d90bee97SLionel Sambuc [ $# != 0 ] 130*d90bee97SLionel Sambucdo 131*d90bee97SLionel Sambuc echo ' { "'$1'", '"$2"' },' >&3 132*d90bee97SLionel Sambuc shift 2 133*d90bee97SLionel Sambucdone 134*d90bee97SLionel Sambuc 135*d90bee97SLionel Sambucecho ' { 0, 0 },' >&3 136*d90bee97SLionel Sambucecho "};" >&3 137