6d92d482e57fb2128ffd09495297ce18c496996d
[dragonfly.git] / usr.bin / make / Makefile
1 .INTERRUPT:
2         echo Hey that hurt!
3 #       @(#)Makefile    5.2 (Berkeley) 12/28/90
4 # $FreeBSD: src/usr.bin/make/Makefile,v 1.13.2.1 2001/05/25 08:33:40 sobomax Exp $
5
6 PROG=   make
7 CFLAGS+=-I${.CURDIR}
8 SRCS=   arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c      \
9         lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c  \
10         util.c var.c
11
12 NOSHARED?=      YES
13
14 CFLAGS+=-DMAKE_VERSION=\"5200408120\"
15
16 # Make object files which depend on preprocessor symbols defined
17 # in the Makefile which are not compilation options but rather
18 # configuration options dependend on the Makefile. main.c needs
19 # MAKE_VERSION, and DEFSHELLNAME.  This will cause recompilation
20 # in the case the definition is changed in the makefile. It will
21 # of course not cause recompilation if one does 'make MAKE_SHELL=csh'.
22 main.o: ${MAKEFILE}
23
24 # Directive and keyword tables. We use hash tables. These hash tables have been
25 # generated with mph which can be found in pkgsrc/devel/mph.
26 # If you change the directives or keywords (adding, deleting, reordering) you
27 # need to create new tables and hash functions (directive_hash, keyword_hash).
28 #
29 # The following changes have been made to the generated code:
30 #
31 #       o prefix the names of the g, T0 and T1 arrays with 'directive_'
32 #         resp. 'keyword_'.
33 #
34 #       o make the type of the tables 'const [un]signed char' (if you change
35 #         anything make sure that the numbers fit into a char).
36 #
37 #       o make the hash function use the length for termination,
38 #         not the trailing '\0', via the -l flag in emitc and some editing
39 #         (only for directive_hash).
40
41 LOCALBASE ?= /usr/pkg
42 MPH     ?= ${LOCALBASE}/bin/mph
43 EMITC   ?= ${LOCALBASE}/bin/emitc
44
45 .PRECIOUS: hash
46
47 hash:
48         ( echo '/*' ;                                                   \
49           echo ' * DO NOT EDIT' ;                                       \
50           echo -n ' * auto-generated from ' ;                           \
51           echo ${.CURDIR}/parse.c ;                                     \
52           echo ' */' ;                                                  \
53           echo '#include <sys/types.h>' ;                               \
54           echo ;                                                        \
55           echo '#include "hash_tables.h"' ;                             \
56           echo ;                                                        \
57           cat ${.CURDIR}/parse.c | sed                                  \
58             -e '1,/DIRECTIVES-START-TAG/d'                              \
59             -e '/DIRECTIVES-END-TAG/,$$d'                               \
60             -e 's/^[^"]*"\([^"]*\)".*$$/\1/' |                          \
61             ${MPH} -d2 -m1 | ${EMITC} -l -s |                           \
62             sed                                                         \
63             -e 's/^static int g\[\]/static const signed char directive_g[]/' \
64             -e 's/^static int T0\[\]/static const u_char directive_T0[]/' \
65             -e 's/^static int T1\[\]/static const u_char directive_T1[]/' \
66             -e '/^#define uchar unsigned char/d'                        \
67             -e 's/uchar/u_char/g'                                       \
68             -e 's/^hash(/directive_hash(/'                              \
69             -e 's/; \*kp;/; kp < key + len;/'                           \
70             -e 's/int len)/size_t len)/'                                \
71             -e 's/= T0\[/= directive_T0\[/'                             \
72             -e 's/= T1\[/= directive_T1\[/'                             \
73             -e 's/g\[f/directive_g[f/g' ;                               \
74           cat ${.CURDIR}/parse.c | sed                                  \
75             -e '1,/KEYWORD-START-TAG/d'                                 \
76             -e '/KEYWORD-END-TAG/,$$d'                                  \
77             -e 's/^[^"]*"\([^"]*\)".*$$/\1/' |                          \
78             ${MPH} -d2 -m1 | ${EMITC} -l -s |                           \
79             sed                                                         \
80             -e 's/^static int g\[\]/static const signed char keyword_g[]/' \
81             -e 's/^static int T0\[\]/static const u_char keyword_T0[]/' \
82             -e 's/^static int T1\[\]/static const u_char keyword_T1[]/' \
83             -e '/^#define uchar unsigned char/d'                        \
84             -e 's/uchar/u_char/g'                                       \
85             -e 's/^hash(/keyword_hash(/'                                \
86             -e 's/int len)/size_t len)/'                                \
87             -e 's/= T0\[/= keyword_T0\[/'                               \
88             -e 's/= T1\[/= keyword_T1\[/'                               \
89             -e 's/g\[f/keyword_g[f/g'                                   \
90         ) > ${.CURDIR}/hash_tables.c
91
92 # Set the shell which make(1) uses.  Bourne is the default, but a decent
93 # Korn shell works fine, and much faster.  Using the C shell for this
94 # will almost certainly break everything, but it's Unix tradition to
95 # allow you to shoot yourself in the foot if you want to :-)
96
97 MAKE_SHELL?=    sh
98 .if ${MAKE_SHELL} == "csh" || ${MAKE_SHELL} == "sh" || ${MAKE_SHELL} == "ksh"
99 CFLAGS+=        -DDEFSHELLNAME=\"${MAKE_SHELL}\"
100 .else
101 .error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"."
102 .endif
103
104 .include <bsd.prog.mk>