diff --git a/lib/libc/regex/grot/Makefile b/lib/libc/regex/grot/Makefile
index b5919bba27..593f7120c2 100644
--- a/lib/libc/regex/grot/Makefile
+++ b/lib/libc/regex/grot/Makefile
@@ -1,14 +1,14 @@
 # $FreeBSD: src/lib/libc/regex/grot/Makefile,v 1.5 2012/11/17 01:49:36 svnexp Exp $
-# You probably want to take -DREDEBUG out of CFLAGS, and put something like
-# -O in, *after* testing (-DREDEBUG strengthens testing by enabling a lot of
+# You probably want to take -DTRE_DEBUG out of CFLAGS, and put something like
+# -O in, *after* testing (-DTRE_DEBUG strengthens testing by enabling a lot of
 # internal assertion checking).  Take -Dconst= out for an ANSI compiler.
 # Do not take -DPOSIX_MISTAKE out.  REGCFLAGS isn't important to you (it's
 # for my use in some special contexts).
 
-PATHS= ${.CURDIR}/.. ${.CURDIR}/../../locale ${.CURDIR}/../../../../include
+PATHS= ${.CURDIR}/../../../../contrib/tre/lib ${.CURDIR}/../../tre-regex ${.CURDIR}/../../locale ${.CURDIR}/../../../../include
 .PATH: ${PATHS}
 
-CFLAGS+= -DPOSIX_MISTAKE -DREDEBUG $(REGCFLAGS)
+CFLAGS+= -DPOSIX_MISTAKE -DTRE_DEBUG -D__LIBC -include regex.h -DTRE_MULTIBYTE -DTRE_WCHAR -include config.h -DHAVE_MBRTOWC -DHAVE_WCTYPE -include wctype.h -include tre-internal.h -DHAVE_ISWCTYPE -include unistd.h $(REGCFLAGS)
 .for incpath in ${PATHS}
 CFLAGS+= -I${incpath}
 .endfor
@@ -24,17 +24,17 @@ LDFLAGS =
 HMISSING =
 SRCMISSING = split.c
 OBJMISSING = split.o
-H = cname.h regex2.h utils.h $(HMISSING)
-REGSRC = regcomp.c regerror.c regexec.c regfree.c engine.c
-SRC = $(REGSRC) debug.c main.c $(SRCMISSING)
+H = cname.h $(HMISSING)
+REGSRC = regcomp.c regerror.c regexec.c
+SRC = $(REGSRC) main.c $(SRCMISSING)
 
 # Internal stuff, should not need changing.
-OBJPRODN = regcomp.o regexec.o regerror.o regfree.o
-OBJS = $(OBJPRODN) debug.o main.o $(OBJMISSING)
+OBJPRODN = regcomp.o regexec.o regerror.o
+OBJS = $(OBJPRODN) main.o $(OBJMISSING)
 
 # Stuff that matters only if you're trying to lint the package.
-LINTFLAGS = -I. -Dstatic= -Dconst= -DREDEBUG
-LINTC = regcomp.c regexec.c regerror.c regfree.c debug.c main.c $(SRCMISSING)
+LINTFLAGS = -I. -Dstatic= -Dconst= -DTRE_DEBUG
+LINTC = regcomp.c regexec.c regerror.c main.c $(SRCMISSING)
 JUNKLINT =possible pointer alignment|null effect
 
 .SUFFIXES:	.ih .h
@@ -48,20 +48,9 @@ re:	$(OBJS)
 
 o:	$(OBJPRODN)
 
-REGEXHSRC = ../regex2.h ../reg*.c
-h:	$(REGEXHSRC)
-	sh mkh $(MKHFLAGS) -i _REGEX_H_ $(REGEXHSRC) >regex.tmp
-	cmp -s regex.tmp regex.h 2>/dev/null || cp regex.tmp regex.h
-	rm -f regex.tmp
-
-regex.h: h
-
-regcomp.o regexec.o regfree.o debug.o:	utils.h regex.h regex2.h
+regcomp.o regexec.o:	regex.h
 regcomp.o:	cname.h regcomp.ih
-regexec.o:	engine.c engine.ih
 regerror.o:	regerror.ih
-regerror.o:	utils.h
-debug.o:	debug.ih
 main.o:	main.ih
 
 r:	re tests
diff --git a/lib/libc/regex/grot/debug.c b/lib/libc/regex/grot/debug.c
index 8e713567b6..cbf9e10466 100644
--- a/lib/libc/regex/grot/debug.c
+++ b/lib/libc/regex/grot/debug.c
@@ -12,8 +12,6 @@
 #include <wchar.h>
 #include <wctype.h>
 
-#include "utils.h"
-#include "regex2.h"
 #include "debug.ih"
 
 /*
diff --git a/lib/libc/regex/grot/main.c b/lib/libc/regex/grot/main.c
index 6f00b88fdf..a73b20c406 100644
--- a/lib/libc/regex/grot/main.c
+++ b/lib/libc/regex/grot/main.c
@@ -180,6 +180,7 @@ FILE *in;
 						erbuf, SHORT-1, badpat);
 		status = 1;
 	}
+#if 0
 	ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
 	if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
 		fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
@@ -197,6 +198,7 @@ FILE *in;
 						erbuf, (long)REG_BADPAT);
 		status = 1;
 	}
+#endif
 }
 
 /*
@@ -354,12 +356,14 @@ char *s;
 			case '#':
 				o |= REG_STARTEND;
 				break;
+#if 0
 			case 't':	/* trace */
 				o |= REG_TRACE;
 				break;
 			case 'l':	/* force long representation */
 				o |= REG_LARGE;
 				break;
+#endif
 			case 'r':	/* force backref use */
 				o |= REG_BACKR;
 				break;
@@ -489,7 +493,7 @@ int err;
 	static char epbuf[100];
 	size_t len;
 
-	len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
+	len = regerror(err, (regex_t *)NULL, epbuf, sizeof(epbuf));
 	assert(len <= sizeof(epbuf));
 	return(epbuf);
 }
@@ -502,13 +506,13 @@ static int
 efind(name)
 char *name;
 {
-	static char efbuf[100];
+	static char efbuf[100] = "666";
 	size_t n;
 	regex_t re;
 
 	sprintf(efbuf, "REG_%s", name);
 	assert(strlen(efbuf) < sizeof(efbuf));
 	re.re_endp = efbuf;
-	(void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
+//	(void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
 	return(atoi(efbuf));
 }
