Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2017-02-18 08:25:22 +0300
committerBryan Drewery <bryan@shatow.net>2017-02-18 09:22:48 +0300
commite43ee759ab70fd1cfb29105858df039c3823fbc2 (patch)
tree7971be39a9f177d6138b9cf4e62b6fd5955cbec0 /external
parent2cd05a9fe00a73dbaf796c32683b36076b6edd57 (diff)
sh: Generate builtins.[ch] at build time
Diffstat (limited to 'external')
-rw-r--r--external/sh/builtins.c102
-rw-r--r--external/sh/builtins.def93
-rw-r--r--external/sh/builtins.h95
-rwxr-xr-xexternal/sh/mkbuiltins93
-rw-r--r--external/update_sh.sh27
5 files changed, 204 insertions, 206 deletions
diff --git a/external/sh/builtins.c b/external/sh/builtins.c
deleted file mode 100644
index 00afc2e2..00000000
--- a/external/sh/builtins.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * This file was generated by the mkbuiltins program.
- */
-
-#include <stdlib.h>
-#include "shell.h"
-#include "builtins.h"
-
-int (*const builtinfunc[])(int, char **) = {
- bltincmd,
- aliascmd,
- bgcmd,
- bindcmd,
- breakcmd,
- cdcmd,
- commandcmd,
- dotcmd,
- echocmd,
- evalcmd,
- execcmd,
- exitcmd,
- letcmd,
- exportcmd,
- falsecmd,
- fgcmd,
- freebsd_wordexpcmd,
- getoptscmd,
- hashcmd,
- histcmd,
- jobidcmd,
- jobscmd,
- killcmd,
- localcmd,
- printfcmd,
- pwdcmd,
- readcmd,
- returncmd,
- setcmd,
- setvarcmd,
- shiftcmd,
- testcmd,
- timescmd,
- trapcmd,
- truecmd,
- typecmd,
- ulimitcmd,
- umaskcmd,
- unaliascmd,
- unsetcmd,
- waitcmd,
- wordexpcmd,
-};
-
-const unsigned char builtincmd[] = {
- "\007\000builtin"
- "\005\001alias"
- "\002\002bg"
- "\004\003bind"
- "\005\204break"
- "\010\204continue"
- "\002\005cd"
- "\005\005chdir"
- "\007\006command"
- "\001\207."
- "\004\010echo"
- "\004\211eval"
- "\004\212exec"
- "\004\213exit"
- "\003\014let"
- "\006\215export"
- "\010\215readonly"
- "\005\016false"
- "\002\017fg"
- "\017\020freebsd_wordexp"
- "\007\021getopts"
- "\004\022hash"
- "\002\023fc"
- "\005\024jobid"
- "\004\025jobs"
- "\004\026kill"
- "\005\027local"
- "\006\030printf"
- "\003\031pwd"
- "\004\032read"
- "\006\233return"
- "\003\234set"
- "\006\035setvar"
- "\005\236shift"
- "\004\037test"
- "\001\037["
- "\005\240times"
- "\004\241trap"
- "\001\242:"
- "\004\042true"
- "\004\043type"
- "\006\044ulimit"
- "\005\045umask"
- "\007\046unalias"
- "\005\247unset"
- "\004\050wait"
- "\007\051wordexp"
-};
diff --git a/external/sh/builtins.def b/external/sh/builtins.def
new file mode 100644
index 00000000..dd113b60
--- /dev/null
+++ b/external/sh/builtins.def
@@ -0,0 +1,93 @@
+#!/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.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)builtins.def 8.4 (Berkeley) 5/4/95
+# $FreeBSD: head/bin/sh/builtins.def 288430 2015-09-30 21:32:29Z jilles $
+
+#
+# This file lists all the builtin commands. The first column is the name
+# of a C routine.
+# The -j flag specifies that this command is to be excluded from systems
+# without job control.
+# The -h flag specifies that this command is to be excluded from systems
+# based on the NO_HISTORY compile-time symbol.
+# The -s flag specifies that this is a POSIX 'special built-in' command.
+# The rest of the line specifies the command name or names used to run the
+# command. The entry for bltincmd, which is run when the user does not specify
+# a command, must come first.
+#
+# NOTE: bltincmd must come first!
+
+bltincmd builtin
+aliascmd alias
+bgcmd -j bg
+bindcmd bind
+breakcmd -s break -s continue
+cdcmd cd chdir
+commandcmd command
+dotcmd -s .
+echocmd echo
+evalcmd -s eval
+execcmd -s exec
+exitcmd -s exit
+letcmd let
+exportcmd -s export -s readonly
+#exprcmd expr
+falsecmd false
+fgcmd -j fg
+freebsd_wordexpcmd freebsd_wordexp
+getoptscmd getopts
+hashcmd hash
+histcmd -h fc
+jobidcmd jobid
+jobscmd jobs
+killcmd kill
+localcmd local
+printfcmd printf
+pwdcmd pwd
+readcmd read
+returncmd -s return
+setcmd -s set
+setvarcmd setvar
+shiftcmd -s shift
+testcmd test [
+timescmd -s times
+trapcmd -s trap
+truecmd -s : true
+typecmd type
+ulimitcmd ulimit
+umaskcmd umask
+unaliascmd unalias
+unsetcmd -s unset
+waitcmd wait
+wordexpcmd wordexp
diff --git a/external/sh/builtins.h b/external/sh/builtins.h
deleted file mode 100644
index baa29d52..00000000
--- a/external/sh/builtins.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * This file was generated by the mkbuiltins program.
- */
-
-#include <sys/cdefs.h>
-#define BLTINCMD 0
-#define ALIASCMD 1
-#define BGCMD 2
-#define BINDCMD 3
-#define BREAKCMD 4
-#define CDCMD 5
-#define COMMANDCMD 6
-#define DOTCMD 7
-#define ECHOCMD 8
-#define EVALCMD 9
-#define EXECCMD 10
-#define EXITCMD 11
-#define LETCMD 12
-#define EXPORTCMD 13
-#define FALSECMD 14
-#define FGCMD 15
-#define FREEBSD_WORDEXPCMD 16
-#define GETOPTSCMD 17
-#define HASHCMD 18
-#define HISTCMD 19
-#define JOBIDCMD 20
-#define JOBSCMD 21
-#define KILLCMD 22
-#define LOCALCMD 23
-#define PRINTFCMD 24
-#define PWDCMD 25
-#define READCMD 26
-#define RETURNCMD 27
-#define SETCMD 28
-#define SETVARCMD 29
-#define SHIFTCMD 30
-#define TESTCMD 31
-#define TIMESCMD 32
-#define TRAPCMD 33
-#define TRUECMD 34
-#define TYPECMD 35
-#define ULIMITCMD 36
-#define UMASKCMD 37
-#define UNALIASCMD 38
-#define UNSETCMD 39
-#define WAITCMD 40
-#define WORDEXPCMD 41
-
-#define BUILTIN_SPECIAL 0x80
-
-extern int (*const builtinfunc[])(int, char **);
-extern const unsigned char builtincmd[];
-
-int bltincmd(int, char **);
-int aliascmd(int, char **);
-int bgcmd(int, char **);
-int bindcmd(int, char **);
-int breakcmd(int, char **);
-int cdcmd(int, char **);
-int commandcmd(int, char **);
-int dotcmd(int, char **);
-int echocmd(int, char **);
-int evalcmd(int, char **);
-int execcmd(int, char **);
-int exitcmd(int, char **);
-int letcmd(int, char **);
-int exportcmd(int, char **);
-int falsecmd(int, char **);
-int fgcmd(int, char **);
-int freebsd_wordexpcmd(int, char **);
-int getoptscmd(int, char **);
-int hashcmd(int, char **);
-int histcmd(int, char **);
-int jobidcmd(int, char **);
-int jobscmd(int, char **);
-int killcmd(int, char **);
-int localcmd(int, char **);
-int printfcmd(int, char **);
-int pwdcmd(int, char **);
-int readcmd(int, char **);
-int returncmd(int, char **);
-int setcmd(int, char **);
-int setvarcmd(int, char **);
-int shiftcmd(int, char **);
-int testcmd(int, char **);
-int timescmd(int, char **);
-int trapcmd(int, char **);
-int truecmd(int, char **);
-int typecmd(int, char **);
-int ulimitcmd(int, char **);
-int umaskcmd(int, char **);
-int unaliascmd(int, char **);
-int unsetcmd(int, char **);
-int waitcmd(int, char **);
-int wordexpcmd(int, char **);
diff --git a/external/sh/mkbuiltins b/external/sh/mkbuiltins
new file mode 100755
index 00000000..dd0adc8d
--- /dev/null
+++ b/external/sh/mkbuiltins
@@ -0,0 +1,93 @@
+#!/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.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 4. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)mkbuiltins 8.2 (Berkeley) 5/4/95
+# $FreeBSD: head/bin/sh/mkbuiltins 293118 2016-01-03 21:30:22Z jilles $
+
+temp=`/usr/bin/mktemp -t ka`
+havehist=1
+if [ "X$1" = "X-h" ]; then
+ havehist=0
+ shift
+fi
+srcdir=$1
+havejobs=0
+if grep '^#define[ ]*JOBS[ ]*1' $srcdir/shell.h > /dev/null
+then havejobs=1
+fi
+exec > builtins.c
+cat <<\!
+/*
+ * This file was generated by the mkbuiltins program.
+ */
+
+#include <stdlib.h>
+#include "shell.h"
+#include "builtins.h"
+
+!
+awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \
+ print $0}' $srcdir/builtins.def | sed 's/-[hj]//' > $temp
+echo 'int (*const builtinfunc[])(int, char **) = {'
+awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp
+echo '};
+
+const unsigned char builtincmd[] = {'
+awk '{ for (i = 2 ; i <= NF ; i++) {
+ if ($i == "-s") {
+ spc = 1;
+ } else {
+ printf "\t\"\\%03o\\%03o%s\"\n", length($i), (spc ? 128 : 0) + NR-1, $i
+ spc = 0;
+ }
+ }}' $temp
+echo '};'
+
+exec > builtins.h
+cat <<\!
+/*
+ * This file was generated by the mkbuiltins program.
+ */
+
+#include <sys/cdefs.h>
+!
+tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp |
+ awk '{ printf "#define %s %d\n", $1, NR-1}'
+echo '
+#define BUILTIN_SPECIAL 0x80
+
+extern int (*const builtinfunc[])(int, char **);
+extern const unsigned char builtincmd[];
+'
+awk '{ printf "int %s(int, char **);\n", $1}' $temp
+rm -f $temp
diff --git a/external/update_sh.sh b/external/update_sh.sh
index c7439812..0664acbd 100644
--- a/external/update_sh.sh
+++ b/external/update_sh.sh
@@ -18,15 +18,24 @@ make cleanobj
make clean cleandepend
make depend
paths=$(make -V '${.PATH:N.*bltin*}'|xargs realpath)
-for src in *.h $(make -V SRCS); do
- if [ -f "${src}" ]; then
- echo "${PWD}/${src}"
- else
- for p in ${paths}; do
- [ -f "${p}/${src}" ] && echo "${p}/${src}" && break
- done
- fi
-done | sort -u | tar -c -T - --exclude bltin -s ",.*/,,g" -f - | tar -C "${DESTDIR_REAL}" -xf -
+{
+ echo builtins.def
+ echo mkbuiltins
+ for src in *.h $(make -V SRCS); do
+ if [ -f "${src}" ]; then
+ echo "${PWD}/${src}"
+ else
+ for p in ${paths}; do
+ [ -f "${p}/${src}" ] && echo "${p}/${src}" && break
+ done
+ fi
+ done
+} | sort -u | \
+ tar -c -T - \
+ --exclude bltin \
+ --exclude builtins.c \
+ --exclude builtins.h \
+ -s ",.*/,,g" -f - | tar -C "${DESTDIR_REAL}" -xf -
cp -R "${SH_DIR}/bltin" "${DESTDIR_REAL}/bltin"
make clean cleandepend
cd "${ORIG_PWD}"