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.1 (Berkeley) 05/31/93 12 13temp=/tmp/ka$$ 14havejobs=0 15if grep '^#define JOBS[ ]*1' shell.h > /dev/null 16then havejobs=1 17fi 18exec > obj/builtins.c 19cat <<\! 20/* 21 * This file was generated by the mkbuiltins program. 22 */ 23 24#include "shell.h" 25#include "builtins.h" 26 27! 28awk '/^[^#]/ {if('$havejobs' || $2 != "-j") print $0}' builtins | 29 sed 's/-j//' > $temp 30awk '{ printf "int %s();\n", $1}' $temp 31echo ' 32int (*const builtinfunc[])() = {' 33awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp 34echo '}; 35 36const struct builtincmd builtincmd[] = {' 37awk '{ for (i = 2 ; i <= NF ; i++) { 38 printf "\t\"%s\", %d,\n", $i, NR-1 39 }}' $temp 40echo ' NULL, 0 41};' 42 43exec > obj/builtins.h 44cat <<\! 45/* 46 * This file was generated by the mkbuiltins program. 47 */ 48 49#include <sys/cdefs.h> 50! 51tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | 52 awk '{ printf "#define %s %d\n", $1, NR-1}' 53echo ' 54struct builtincmd { 55 char *name; 56 int code; 57}; 58 59extern int (*const builtinfunc[])(); 60extern const struct builtincmd builtincmd[];' 61rm -f $temp 62