diff options
author | harti <harti@FreeBSD.org> | 2005-04-28 07:55:55 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-04-28 07:55:55 +0000 |
commit | 6b86becddd4b3a6be5835f1d82b8f6970a09372a (patch) | |
tree | 55eac1df47743b4f456328f864ca636a89abb33b /usr.bin/make/Makefile | |
parent | 5b8bbca994dae4b36b2135df5e705e8684090b1c (diff) | |
download | FreeBSD-src-6b86becddd4b3a6be5835f1d82b8f6970a09372a.zip FreeBSD-src-6b86becddd4b3a6be5835f1d82b8f6970a09372a.tar.gz |
Move the hash function for directives into its own file and add
a Makefile target to re-created this file. Note, that there is no
explicite dependency to automatically re-create the file, because this
is needed only when the directive table changes and it requires the
(yet to come) devel/mph port.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (first version)
Diffstat (limited to 'usr.bin/make/Makefile')
-rw-r--r-- | usr.bin/make/Makefile | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index acd90e57..ee4d7b3 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -4,8 +4,9 @@ PROG= make CFLAGS+=-I${.CURDIR} -SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c lst.c main.c \ - make.c parse.c str.c suff.c targ.c util.c var.c var_modify.c +SRCS= arch.c buf.c compat.c cond.c dir.c directive_hash.c for.c \ + hash.c job.c lst.c main.c make.c parse.c str.c suff.c targ.c \ + util.c var.c var_modify.c NO_WERROR= WARNS?= 3 @@ -21,6 +22,58 @@ CFLAGS+=-D__FBSDID=__RCSID main.o: ${MAKEFILE} +# Directive table. We use a hash table. This hash table has been +# generated with mph which can be found on the usual GNU mirrors. +# If you change the directives (adding, deleting, reordering) you +# need to create a new table and hash function (directive_hash). +# +# The following changes have been made to the generated code: +# +# o prefix the names of the g, T0 and T1 arrays with 'directive_'. +# +# o make the type of the tables 'const [un]signed char' (if you change +# anything make sure that the numbers fit into a char). +# +# o make the hash function use the length for termination, +# not the trailing '\0', via the -l flag in emitc and some editing. + +LOCALBASE ?= /usr/local +MPH ?= ${LOCALBASE}/bin/mph +EMITC ?= ${LOCALBASE}/bin/emitc + +.PRECIOUS: hash +hash: + ( echo '/*' ; \ + echo ' * DO NOT EDIT' ; \ + echo ' * $$FreeBSD$$' ; \ + echo -n ' * auto-generated from ' ; \ + sed -nEe '/\$$FreeBSD/s/^.*\$$(.*)\$$.*$$/\1/p' \ + ${.CURDIR}/parse.c ; \ + echo ' * DO NOT EDIT' ; \ + echo ' */' ; \ + echo '#include <sys/types.h>' ; \ + echo ; \ + echo '#include "directive_hash.h"' ; \ + echo ; \ + cat ${.CURDIR}/parse.c | sed \ + -e '1,/DIRECTIVES-START-TAG/d' \ + -e '/DIRECTIVES-END-TAG/,$$d' \ + -e 's/^[^"]*"\([^"]*\)".*$$/\1/' | \ + ${MPH} -d2 -m1 | ${EMITC} -l -s | \ + sed \ + -e 's/^static int g\[\]/static const signed char directive_g[]/' \ + -e 's/^static int T0\[\]/static const u_char directive_T0[]/' \ + -e 's/^static int T1\[\]/static const u_char directive_T1[]/' \ + -e '/^#define uchar unsigned char/d' \ + -e 's/uchar/u_char/g' \ + -e 's/^hash(/directive_hash(/' \ + -e 's/; \*kp;/; kp < key + len;/' \ + -e 's/int len)/size_t len)/' \ + -e 's/= T0\[/= directive_T0\[/' \ + -e 's/= T1\[/= directive_T1\[/' \ + -e 's/g\[f/directive_g[f/g' \ + ) > ${.CURDIR}/directive_hash.c + # Set the shell which make(1) uses. Bourne is the default, but a decent # Korn shell works fine, and much faster. Using the C shell for this # will almost certainly break everything, but it's Unix tradition to |