mkbuiltins revision 1556
1193323Sed#!/bin/sh - 2193323Sed# 3193323Sed# Copyright (c) 1991, 1993 4193323Sed# The Regents of the University of California. All rights reserved. 5193323Sed# 6193323Sed# This code is derived from software contributed to Berkeley by 7193323Sed# Kenneth Almquist. 8193323Sed# 9193323Sed# Redistribution and use in source and binary forms, with or without 10193323Sed# modification, are permitted provided that the following conditions 11193323Sed# are met: 12193323Sed# 1. Redistributions of source code must retain the above copyright 13193323Sed# notice, this list of conditions and the following disclaimer. 14193323Sed# 2. Redistributions in binary form must reproduce the above copyright 15193323Sed# notice, this list of conditions and the following disclaimer in the 16193323Sed# documentation and/or other materials provided with the distribution. 17193323Sed# 3. All advertising materials mentioning features or use of this software 18243830Sdim# must display the following acknowledgement: 19243830Sdim# This product includes software developed by the University of 20243830Sdim# California, Berkeley and its contributors. 21193323Sed# 4. Neither the name of the University nor the names of its contributors 22218893Sdim# may be used to endorse or promote products derived from this software 23193323Sed# without specific prior written permission. 24198090Srdivacky# 25193323Sed# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26193323Sed# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27193323Sed# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28193323Sed# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29193323Sed# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30193323Sed# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31193323Sed# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32193323Sed# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33193323Sed# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34193323Sed# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35193323Sed# SUCH DAMAGE. 36193323Sed# 37193323Sed# @(#)mkbuiltins 8.1 (Berkeley) 5/31/93 38193323Sed 39193323Sedtemp=/tmp/ka$$ 40193323Sedhavejobs=0 41193323Sedif grep '^#define JOBS[ ]*1' shell.h > /dev/null 42193323Sedthen havejobs=1 43193323Sedfi 44193323Sedexec > obj/builtins.c 45193323Sedcat <<\! 46193323Sed/* 47193323Sed * This file was generated by the mkbuiltins program. 48193323Sed */ 49193323Sed 50193323Sed#include "shell.h" 51210299Sed#include "builtins.h" 52210299Sed 53210299Sed! 54210299Sedawk '/^[^#]/ {if('$havejobs' || $2 != "-j") print $0}' builtins | 55193323Sed sed 's/-j//' > $temp 56193323Sedawk '{ printf "int %s();\n", $1}' $temp 57193323Sedecho ' 58193323Sedint (*const builtinfunc[])() = {' 59218893Sdimawk '/^[^#]/ { printf "\t%s,\n", $1}' $temp 60193323Sedecho '}; 61193323Sed 62193323Sedconst struct builtincmd builtincmd[] = {' 63193323Sedawk '{ for (i = 2 ; i <= NF ; i++) { 64210299Sed printf "\t\"%s\", %d,\n", $i, NR-1 65210299Sed }}' $temp 66210299Sedecho ' NULL, 0 67193323Sed};' 68193323Sed 69193323Sedexec > obj/builtins.h 70193323Sedcat <<\! 71193323Sed/* 72193323Sed * This file was generated by the mkbuiltins program. 73193323Sed */ 74263508Sdim 75193323Sed#include <sys/cdefs.h> 76193323Sed! 77193323Sedtr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | 78193323Sed awk '{ printf "#define %s %d\n", $1, NR-1}' 79193323Sedecho ' 80193323Sedstruct builtincmd { 81193323Sed char *name; 82193323Sed int code; 83193323Sed}; 84193323Sed 85193323Sedextern int (*const builtinfunc[])(); 86193323Sedextern const struct builtincmd builtincmd[];' 87193323Sedrm -f $temp 88193323Sed