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