147104Sbostic#!/bin/sh - 247104Sbostic# 360707Sbostic# Copyright (c) 1991, 1993 460707Sbostic# The Regents of the University of California. All rights reserved. 547104Sbostic# 647104Sbostic# This code is derived from software contributed to Berkeley by 747104Sbostic# Kenneth Almquist. 847104Sbostic# 947104Sbostic# %sccs.include.redist.sh% 1047104Sbostic# 11*69273Schristos# @(#)mkbuiltins 8.2 (Berkeley) 05/04/95 1247104Sbostic 1347104Sbostictemp=/tmp/ka$$ 1447104Sbostichavejobs=0 1547104Sbosticif grep '^#define JOBS[ ]*1' shell.h > /dev/null 1647104Sbosticthen havejobs=1 1747104Sbosticfi 18*69273Schristoshavehist=1 19*69273Schristosif [ "X$1" = "X-h" ]; then 20*69273Schristos havehist=0 21*69273Schristos shift 22*69273Schristosfi 23*69273Schristosobjdir=$1 24*69273Schristosexec > ${objdir}/builtins.c 2547104Sbosticcat <<\! 2647104Sbostic/* 2747104Sbostic * This file was generated by the mkbuiltins program. 2847104Sbostic */ 2947104Sbostic 3047104Sbostic#include "shell.h" 3147104Sbostic#include "builtins.h" 3247104Sbostic 3347104Sbostic! 34*69273Schristosawk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ 35*69273Schristos print $0}' builtins.def | sed 's/-j//' > $temp 3647104Sbosticawk '{ printf "int %s();\n", $1}' $temp 3747104Sbosticecho ' 3847104Sbosticint (*const builtinfunc[])() = {' 3947104Sbosticawk '/^[^#]/ { printf "\t%s,\n", $1}' $temp 4047104Sbosticecho '}; 4147104Sbostic 4247104Sbosticconst struct builtincmd builtincmd[] = {' 4347104Sbosticawk '{ for (i = 2 ; i <= NF ; i++) { 44*69273Schristos printf "\t{ \"%s\", %d },\n", $i, NR-1 4547104Sbostic }}' $temp 46*69273Schristosecho ' { NULL, 0 } 4747104Sbostic};' 4847104Sbostic 49*69273Schristosexec > ${objdir}/builtins.h 5047104Sbosticcat <<\! 5147104Sbostic/* 5247104Sbostic * This file was generated by the mkbuiltins program. 5347104Sbostic */ 5447104Sbostic 5547166Sbostic#include <sys/cdefs.h> 5647104Sbostic! 5747104Sbostictr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | 5847104Sbostic awk '{ printf "#define %s %d\n", $1, NR-1}' 5947104Sbosticecho ' 6047104Sbosticstruct builtincmd { 6147104Sbostic char *name; 6247104Sbostic int code; 6347104Sbostic}; 6447104Sbostic 6547104Sbosticextern int (*const builtinfunc[])(); 6647104Sbosticextern const struct builtincmd builtincmd[];' 6747104Sbosticrm -f $temp 68