mkbuiltins revision 149015
175185Stmm#!/bin/sh - 275185Stmm 3107052Sru#- 475185Stmm# Copyright (c) 1991, 1993 575185Stmm# The Regents of the University of California. All rights reserved. 675185Stmm# 775185Stmm# This code is derived from software contributed to Berkeley by 875185Stmm# Kenneth Almquist. 975185Stmm# 1075185Stmm# Redistribution and use in source and binary forms, with or without 1175185Stmm# modification, are permitted provided that the following conditions 1275185Stmm# are met: 1375185Stmm# 1. Redistributions of source code must retain the above copyright 1475185Stmm# notice, this list of conditions and the following disclaimer. 1575185Stmm# 2. Redistributions in binary form must reproduce the above copyright 1675185Stmm# notice, this list of conditions and the following disclaimer in the 1775185Stmm# documentation and/or other materials provided with the distribution. 1875185Stmm# 4. Neither the name of the University nor the names of its contributors 19101242Srwatson# may be used to endorse or promote products derived from this software 20105698Srwatson# without specific prior written permission. 21106482Srwatson# 22101242Srwatson# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23105698Srwatson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2475185Stmm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25156613Sdeischen# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26156613Sdeischen# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2775223Sru# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2875185Stmm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2975185Stmm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3075185Stmm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3175185Stmm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3275209Sjedgar# SUCH DAMAGE. 3375185Stmm# 3475185Stmm# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95 3575185Stmm# $FreeBSD: head/bin/sh/mkbuiltins 149015 2005-08-13 08:09:22Z stefanf $ 3675185Stmm 3775185Stmmtemp=`/usr/bin/mktemp -t ka` 3875185Stmmhavejobs=0 3975185Stmmif grep '^#define[ ]*JOBS[ ]*1' shell.h > /dev/null 4075928Sjedgarthen havejobs=1 4175185Stmmfi 4275492Sjedgarhavehist=1 4375185Stmmif [ "X$1" = "X-h" ]; then 4475185Stmm havehist=0 4575185Stmm shift 4675185Stmmfi 4775185Stmmobjdir=$1 4875185Stmmexec > ${objdir}/builtins.c 4975185Stmmcat <<\! 5075185Stmm/* 5175185Stmm * This file was generated by the mkbuiltins program. 5286452Srwatson */ 53101242Srwatson 54113737Srwatson#include <stdlib.h> 55101242Srwatson#include "shell.h" 56160154Srwatson#include "builtins.h" 57101242Srwatson 58109263Schris! 59101242Srwatsonawk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ 60101242Srwatson print $0}' builtins.def | sed 's/-[hj]//' > $temp 6175185Stmmawk '{ printf "int %s(int, char **);\n", $1}' $temp 6275185Stmmecho ' 6375185Stmmint (*const builtinfunc[])(int, char **) = {' 6475185Stmmawk '/^[^#]/ { printf "\t%s,\n", $1}' $temp 6575185Stmmecho '}; 6675185Stmm 6775185Stmmconst struct builtincmd builtincmd[] = {' 6875185Stmmawk '{ for (i = 2 ; i <= NF ; i++) { 6975185Stmm printf "\t{ \"%s\", %d },\n", $i, NR-1 7075185Stmm }}' $temp 7175185Stmmecho ' { NULL, 0 } 7275185Stmm};' 7382707Srwatson 7486452Srwatsonexec > ${objdir}/builtins.h 75101242Srwatsoncat <<\! 76101242Srwatson/* 77101242Srwatson * This file was generated by the mkbuiltins program. 78130636Srwatson */ 79109263Schris 80101242Srwatson#include <sys/cdefs.h> 81109263Schris! 82109263Schristr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | 83109263Schris awk '{ printf "#define %s %d\n", $1, NR-1}' 84109263Schrisecho ' 85101242Srwatsonstruct builtincmd { 86101242Srwatson char *name; 87101242Srwatson int code; 88101242Srwatson}; 89101242Srwatson 90extern int (*const builtinfunc[])(int, char **); 91extern const struct builtincmd builtincmd[];' 92rm -f $temp 93