commit: 6e3e79ebdcf003f32bdad32bb2cbe2db69aa9438
parent e2522b737e6be889c7c3aa4eeb2523f326218b63
Author: Michael Forney <mforney@mforney.org>
Date: Tue, 10 Apr 2018 16:36:09 -0700
openbsd: Build m4
Diffstat:
7 files changed, 439 insertions(+), 11 deletions(-)
diff --git a/pkg/openbsd/fetch.sh b/pkg/openbsd/fetch.sh
@@ -15,16 +15,18 @@ if ! sha256sum -c sha256 2>/dev/null ; then
fi
zcat src.tar.gz | pax -r -s '/^/src\//' \
- 'bin/pax/*' \
- 'include/*' \
- 'lib/libc/*' \
- 'lib/libcrypto/arc4random/*' \
- 'usr.bin/diff/*' \
- 'usr.bin/doas/*' \
- 'usr.bin/fmt/*' \
- 'usr.bin/nc/*' \
- 'usr.bin/patch/*' \
- 'usr.bin/yacc/*'
+ 'bin/pax/*' \
+ 'include/*' \
+ 'lib/libc/*' \
+ 'lib/libcrypto/arc4random/*' \
+ 'lib/libutil/*' \
+ 'usr.bin/diff/*' \
+ 'usr.bin/doas/*' \
+ 'usr.bin/fmt/*' \
+ 'usr.bin/m4/*' \
+ 'usr.bin/nc/*' \
+ 'usr.bin/patch/*' \
+ 'usr.bin/yacc/*'
zcat sys.tar.gz | pax -r -s '/^/src\//' 'sys/sys/*'
git apply -v --whitespace=nowarn --directory "$dir/src" patch/*
diff --git a/pkg/openbsd/gen.lua b/pkg/openbsd/gen.lua
@@ -4,6 +4,7 @@ cflags{
'-I $builddir/pkg/libressl/include',
'-idirafter $srcdir/include',
'-idirafter $srcdir/sys',
+ '-idirafter $srcdir/lib/libutil',
}
local libs
@@ -36,6 +37,7 @@ lib('libbsd.a', {paths[[
string/(explicit_bzero.c strmode.c timingsafe_memcmp.c)
)
lib/libcrypto/arc4random/getentropy_linux.c
+ lib/libutil/ohash.c
]], libs}, {'pkg/libressl/headers'})
-- diff
@@ -55,6 +57,17 @@ man{'usr.bin/doas/doas.1', 'usr.bin/doas/doas.conf.5'}
file('bin/fmt', '755', exe('fmt', {'usr.bin/fmt/fmt.c'}))
man{'usr.bin/fmt/fmt.1'}
+-- m4
+yacc('usr.bin/m4/parser', 'usr.bin/m4/parser.y')
+cc('usr.bin/m4/tokenizer.c', nil, {cflags='$cflags -I $outdir/usr.bin/m4'})
+exe('m4', [[
+ usr.bin/m4/(eval.c expr.c look.c main.c misc.c gnum4.c trace.c tokenizer.c.o)
+ $outdir/usr.bin/m4/parser.tab.c
+ libbsd.a
+]])
+file('bin/m4', '755', '$outdir/m4')
+man{'usr.bin/m4/m4.1'}
+
-- nc
exe('nc', [[
usr.bin/nc/(netcat.c atomicio.c socks.c)
diff --git a/pkg/openbsd/patch/0022-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch b/pkg/openbsd/patch/0022-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch
@@ -0,0 +1,327 @@
+From edf250c633bef40e7e37dafc9fc393dd2ad9074f Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 10 Apr 2018 13:37:14 -0700
+Subject: [PATCH] m4: Use hand-written lexer to avoid cycle in bootstrap
+
+---
+ usr.bin/m4/tokenizer.c | 191 +++++++++++++++++++++++++++++++++++++++++
+ usr.bin/m4/tokenizer.l | 109 -----------------------
+ 2 files changed, 191 insertions(+), 109 deletions(-)
+ create mode 100644 usr.bin/m4/tokenizer.c
+ delete mode 100644 usr.bin/m4/tokenizer.l
+
+diff --git a/usr.bin/m4/tokenizer.c b/usr.bin/m4/tokenizer.c
+new file mode 100644
+index 00000000000..fa19fc65035
+--- /dev/null
++++ b/usr.bin/m4/tokenizer.c
+@@ -0,0 +1,191 @@
++/* $OpenBSD: tokenizer.l,v 1.10 2017/06/17 01:55:16 bcallah Exp $ */
++/*
++ * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++#include "parser.tab.h"
++#include <assert.h>
++#include <ctype.h>
++#include <errno.h>
++#include <limits.h>
++#include <stdbool.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <stdint.h>
++
++extern void m4_warnx(const char *, ...);
++extern int mimic_gnu;
++extern int32_t yylval;
++static const char *yypos;
++
++void
++yy_scan_string(const char *s)
++{
++ yypos = s;
++}
++
++static int32_t
++number(const char *yytext, size_t yylen)
++{
++ long l;
++
++ errno = 0;
++ l = strtol(yytext, NULL, 0);
++ if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) ||
++ l > INT32_MAX || l < INT32_MIN)
++ m4_warnx("numeric overflow in expr: %.*s", (int)yylen, yytext);
++ return l;
++}
++
++static int32_t
++parse_radix(const char *yytext, size_t yylen)
++{
++ long base;
++ char *next;
++ long l;
++ int d;
++
++ l = 0;
++ base = strtol(yytext+2, &next, 0);
++ if (base > 36 || next == NULL) {
++ m4_warnx("error in number %.*s", (int)yylen, yytext);
++ } else {
++ next++;
++ while (*next != 0) {
++ if (*next >= '0' && *next <= '9')
++ d = *next - '0';
++ else if (*next >= 'a' && *next <= 'z')
++ d = *next - 'a' + 10;
++ else {
++ assert(*next >= 'A' && *next <= 'Z');
++ d = *next - 'A' + 10;
++ }
++ if (d >= base) {
++ m4_warnx("error in number %.*s", (int)yylen, yytext);
++ return 0;
++ }
++ l = base * l + d;
++ next++;
++ }
++ }
++ return l;
++}
++
++static int
++isodigit(int c)
++{
++ return c >= '0' && c <= '7';
++}
++
++int yylex(void)
++{
++ const char *start;
++
++next:
++ start = yypos;
++ switch (*yypos) {
++ case ' ':
++ case '\t':
++ case '\n':
++ ++yypos;
++ goto next;
++ case '<':
++ switch (yypos[1]) {
++ case '=':
++ yypos += 2;
++ return LE;
++ case '<':
++ yypos += 2;
++ return LSHIFT;
++ }
++ break;
++ case '>':
++ switch (yypos[1]) {
++ case '=':
++ yypos += 2;
++ return GE;
++ case '>':
++ yypos += 2;
++ return RSHIFT;
++ }
++ break;
++ case '=':
++ if (yypos[1] != '=')
++ break;
++ yypos += 2;
++ return EQ;
++ case '!':
++ if (yypos[1] != '=')
++ break;
++ yypos += 2;
++ return NE;
++ case '&':
++ if (yypos[1] != '&')
++ break;
++ yypos += 2;
++ return LAND;
++ case '|':
++ if (yypos[1] != '|')
++ break;
++ yypos += 2;
++ return LOR;
++ case '*':
++ if (!mimic_gnu || yypos[1] != '*')
++ break;
++ yypos += 2;
++ return EXPONENT;
++ case '0':
++ switch (*++yypos) {
++ case 'x':
++ case 'X':
++ if (!isxdigit(*++yypos))
++ return ERROR;
++ do ++yypos;
++ while (isxdigit(*yypos));
++ break;
++ case 'r':
++ case 'R':
++ if (!mimic_gnu)
++ break;
++ if (!isdigit(*++yypos))
++ return ERROR;
++ do ++yypos;
++ while (isdigit(*yypos));
++ if (*yypos != ':')
++ return ERROR;
++ if (!isalnum(*++yypos))
++ return ERROR;
++ do ++yypos;
++ while (isalnum(*yypos));
++ yylval = parse_radix(start, yypos - start);
++ return NUMBER;
++ default:
++ do ++yypos;
++ while (isodigit(*yypos));
++ break;
++ }
++ yylval = number(start, yypos - start);
++ return NUMBER;
++ case '\0':
++ return '\0';
++ }
++ if (isdigit(*yypos)) {
++ do ++yypos;
++ while (isdigit(*yypos));
++ yylval = number(start, yypos - start);
++ return NUMBER;
++ }
++
++ return *yypos++;
++}
+diff --git a/usr.bin/m4/tokenizer.l b/usr.bin/m4/tokenizer.l
+deleted file mode 100644
+index 94f02fb6085..00000000000
+--- a/usr.bin/m4/tokenizer.l
++++ /dev/null
+@@ -1,109 +0,0 @@
+-%{
+-/* $OpenBSD: tokenizer.l,v 1.10 2017/06/17 01:55:16 bcallah Exp $ */
+-/*
+- * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
+- *
+- * Permission to use, copy, modify, and distribute this software for any
+- * purpose with or without fee is hereby granted, provided that the above
+- * copyright notice and this permission notice appear in all copies.
+- *
+- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+- */
+-#include "parser.h"
+-#include <assert.h>
+-#include <stdlib.h>
+-#include <errno.h>
+-#include <stdint.h>
+-#include <limits.h>
+-
+-extern void m4_warnx(const char *, ...);
+-extern int mimic_gnu;
+-extern int32_t yylval;
+-
+-int32_t number(void);
+-int32_t parse_radix(void);
+-%}
+-
+-delim [ \t\n]
+-ws {delim}+
+-hex 0[xX][0-9a-fA-F]+
+-oct 0[0-7]*
+-dec [1-9][0-9]*
+-radix 0[rR][0-9]+:[0-9a-zA-Z]+
+-
+-%option noyywrap
+-
+-%%
+-{ws} {/* just skip it */}
+-{hex}|{oct}|{dec} { yylval = number(); return(NUMBER); }
+-{radix} { if (mimic_gnu) {
+- yylval = parse_radix(); return(NUMBER);
+- } else {
+- return(ERROR);
+- }
+- }
+-"<=" { return(LE); }
+-">=" { return(GE); }
+-"<<" { return(LSHIFT); }
+-">>" { return(RSHIFT); }
+-"==" { return(EQ); }
+-"!=" { return(NE); }
+-"&&" { return(LAND); }
+-"||" { return(LOR); }
+-"**" { if (mimic_gnu) { return (EXPONENT); } }
+-. { return yytext[0]; }
+-%%
+-
+-int32_t
+-number()
+-{
+- long l;
+-
+- errno = 0;
+- l = strtol(yytext, NULL, 0);
+- if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) ||
+- l > INT32_MAX || l < INT32_MIN)
+- m4_warnx("numeric overflow in expr: %s", yytext);
+- return l;
+-}
+-
+-int32_t
+-parse_radix()
+-{
+- long base;
+- char *next;
+- long l;
+- int d;
+-
+- l = 0;
+- base = strtol(yytext+2, &next, 0);
+- if (base > 36 || next == NULL) {
+- m4_warnx("error in number %s", yytext);
+- } else {
+- next++;
+- while (*next != 0) {
+- if (*next >= '0' && *next <= '9')
+- d = *next - '0';
+- else if (*next >= 'a' && *next <= 'z')
+- d = *next - 'a' + 10;
+- else {
+- assert(*next >= 'A' && *next <= 'Z');
+- d = *next - 'A' + 10;
+- }
+- if (d >= base) {
+- m4_warnx("error in number %s", yytext);
+- return 0;
+- }
+- l = base * l + d;
+- next++;
+- }
+- }
+- return l;
+-}
+-
+--
+2.17.0
+
diff --git a/pkg/openbsd/patch/0023-m4-Use-_Noreturn-instead-of-__dead.patch b/pkg/openbsd/patch/0023-m4-Use-_Noreturn-instead-of-__dead.patch
@@ -0,0 +1,25 @@
+From 0f0eb43f3d6fb749fac229e3d6c8f74b2c40ece2 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 10 Apr 2018 16:03:44 -0700
+Subject: [PATCH] m4: Use _Noreturn instead of __dead
+
+---
+ usr.bin/m4/extern.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h
+index ea8406b8540..0c07599777d 100644
+--- a/usr.bin/m4/extern.h
++++ b/usr.bin/m4/extern.h
+@@ -113,7 +113,7 @@ extern void usage(void);
+ extern void resizedivs(int);
+ extern size_t buffer_mark(void);
+ extern void dump_buffer(FILE *, size_t);
+-extern void __dead m4errx(int, const char *, ...);
++extern void _Noreturn m4errx(int, const char *, ...);
+
+ extern int obtain_char(struct input_file *);
+ extern void set_input(struct input_file *, FILE *, const char *);
+--
+2.17.0
+
diff --git a/pkg/openbsd/patch/0024-m4-Add-missing-includes.patch b/pkg/openbsd/patch/0024-m4-Add-missing-includes.patch
@@ -0,0 +1,37 @@
+From 2213572d0ef5646c205f5d30e67ba7ad1ac0129e Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 10 Apr 2018 16:24:12 -0700
+Subject: [PATCH] m4: Add missing includes
+
+---
+ usr.bin/m4/look.c | 1 +
+ usr.bin/m4/main.c | 1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c
+index ac504570a9f..5feb0413cd6 100644
+--- a/usr.bin/m4/look.c
++++ b/usr.bin/m4/look.c
+@@ -38,6 +38,7 @@
+ * by: oz
+ */
+
++#include <sys/cdefs.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <stdint.h>
+diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
+index f1b8fa5a55b..4e664c0a50b 100644
+--- a/usr.bin/m4/main.c
++++ b/usr.bin/m4/main.c
+@@ -39,6 +39,7 @@
+ * by: oz
+ */
+
++#include <sys/cdefs.h>
+ #include <assert.h>
+ #include <signal.h>
+ #include <err.h>
+--
+2.17.0
+
diff --git a/pkg/openbsd/patch/0025-libutil-Add-missing-includes.patch b/pkg/openbsd/patch/0025-libutil-Add-missing-includes.patch
@@ -0,0 +1,24 @@
+From 72cfeec702c7b76cce88be4c411ce40a8abb628c Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 10 Apr 2018 16:23:22 -0700
+Subject: [PATCH] libutil: Add missing includes
+
+---
+ lib/libutil/ohash.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/lib/libutil/ohash.c b/lib/libutil/ohash.c
+index 74ca4fafd9c..9537c60eac4 100644
+--- a/lib/libutil/ohash.c
++++ b/lib/libutil/ohash.c
+@@ -15,6 +15,7 @@
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
++#include <sys/cdefs.h>
+ #include <stddef.h>
+ #include <stdint.h>
+ #include <stdlib.h>
+--
+2.17.0
+
diff --git a/pkg/openbsd/rev b/pkg/openbsd/rev
@@ -1 +1 @@
-18
+19