#!/bin/sh - # # Copyright (c) 1991, 1993 # The Regents of the University of California. All rights reserved. # # This code is derived from software contributed to Berkeley by # Kenneth Almquist. # # %sccs.include.redist.sh% # # @(#)mkbuiltins 8.1 (Berkeley) 05/31/93 temp=/tmp/ka$$ havejobs=0 if grep '^#define JOBS[ ]*1' shell.h > /dev/null then havejobs=1 fi exec > obj/builtins.c cat <<\! /* * This file was generated by the mkbuiltins program. */ #include "shell.h" #include "builtins.h" ! awk '/^[^#]/ {if('$havejobs' || $2 != "-j") print $0}' builtins | sed 's/-j//' > $temp awk '{ printf "int %s();\n", $1}' $temp echo ' int (*const builtinfunc[])() = {' awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp echo '}; const struct builtincmd builtincmd[] = {' awk '{ for (i = 2 ; i <= NF ; i++) { printf "\t\"%s\", %d,\n", $i, NR-1 }}' $temp echo ' NULL, 0 };' exec > obj/builtins.h cat <<\! /* * This file was generated by the mkbuiltins program. */ #include ! tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp | awk '{ printf "#define %s %d\n", $1, NR-1}' echo ' struct builtincmd { char *name; int code; }; extern int (*const builtinfunc[])(); extern const struct builtincmd builtincmd[];' rm -f $temp