1#!/bin/sh - 2# 3# Copyright (c) 1991, 1993 4# The Regents of the University of California. All rights reserved. 5# 6# This code is derived from software contributed to Berkeley by 7# Kenneth Almquist. 8# 9# %sccs.include.redist.sh% 10# 11# @(#)mkbuiltins 8.2 (Berkeley) 05/04/95 12 13temp=/tmp/ka$$ 14havejobs=0 15if grep '^#define JOBS[ ]*1' shell.h > /dev/null 16then havejobs=1 17fi 18havehist=1 19if [ "X$1" = "X-h" ]; then 20 havehist=0 21 shift 22fi 23objdir=$1 24exec > ${objdir}/builtins.c 25cat <<\! 26/* 27 * This file was generated by the mkbuiltins program. 28 */ 29 30#include "shell.h" 31#include "builtins.h" 32 33! 34awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ 35 print $0}' builtins.def | sed 's/-j//' > $temp 36awk '{ printf "int %s();\n", $1}' $temp 37echo ' 38int (*const builtinfunc[])() = {' 39awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp 40echo '}; 41 42const struct builtincmd builtincmd[] = {' 43awk '{ for (i = 2 ; i <= NF ; i++) { 44 printf "\t{ \"%s\", %d },\n", $i, NR-1 45 }}' $temp 46echo ' { NULL, 0 } 47};' 48 49exec > ${objdir}/builtins.h 50cat <<\! 51/* 52 * This file was generated by the mkbuiltins program. 53 */ 54 55#include <sys/cdefs.h> 56! 57tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | 58 awk '{ printf "#define %s %d\n", $1, NR-1}' 59echo ' 60struct builtincmd { 61 char *name; 62 int code; 63}; 64 65extern int (*const builtinfunc[])(); 66extern const struct builtincmd builtincmd[];' 67rm -f $temp 68