118730Ssteve#	@(#)Makefile	5.2 (Berkeley) 12/28/90
294589Sobrien#	$Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $
350477Speter# $FreeBSD$
41590Srgrimes
5234782Skib.include <bsd.own.mk>
6234782Skib
71590SrgrimesPROG=	make
8143657ShartiCFLAGS+=-I${.CURDIR}
9146056ShartiSRCS=	arch.c buf.c cond.c dir.c for.c hash.c hash_tables.c job.c	\
10146574Sharti	lst.c main.c make.c parse.c proc.c shell.c str.c suff.c targ.c	\
11146574Sharti	util.c var.c
121590Srgrimes
13235152Simp.if !defined(MK_SHARED_TOOLCHAIN) || ${MK_SHARED_TOOLCHAIN} == "no"
14139112SruNO_SHARED?=	YES
15234782Skib.endif
1676801Ssobomax
17228157Sfjoe# Version has the RYYYYMMDDX format, where R is from RELENG_<R>
18237282SobrienCFLAGS+=-DMAKE_VERSION=\"10201205300\"
19228157Sfjoe
20134843Sjmg# There is no obvious performance improvement currently.
21104475Sphk# CFLAGS+=-DUSE_KQUEUE
22104475Sphk
23146608Sharti# Make object files which depend on preprocessor symbols defined in
24146608Sharti# the Makefile which are not compilation options but rather configuration
25146608Sharti# options dependend on the Makefile. main.c needs MAKE_VERSION while
26146608Sharti# shell.c uses DEFSHELLNAME. This will cause recompilation in the case
27146608Sharti# the definition is changed in the makefile. It will of course not cause
28146608Sharti# recompilation if one does 'make MAKE_SHELL=csh'.
29146579Shartimain.o shell.o: ${MAKEFILE}
3097121Sru
31145616Sharti# Directive and keyword tables. We use hash tables. These hash tables have been
32150598Sphk# generated with mph (ports/devel/mph)
33145616Sharti# If you change the directives or keywords (adding, deleting, reordering) you
34145616Sharti# need to create new tables and hash functions (directive_hash, keyword_hash).
35145612Sharti#
36145612Sharti# The following changes have been made to the generated code:
37145612Sharti#
38145616Sharti#	o prefix the names of the g, T0 and T1 arrays with 'directive_'
39145616Sharti#	  resp. 'keyword_'.
40145612Sharti#
41145612Sharti#	o make the type of the tables 'const [un]signed char' (if you change
42145612Sharti#	  anything make sure that the numbers fit into a char).
43145612Sharti#
44145612Sharti#	o make the hash function use the length for termination,
45145616Sharti#	  not the trailing '\0', via the -l flag in emitc and some editing
46145616Sharti#	  (only for directive_hash).
47145612Sharti
48145612ShartiLOCALBASE ?= /usr/local
49145612ShartiMPH	?= ${LOCALBASE}/bin/mph
50145612ShartiEMITC	?= ${LOCALBASE}/bin/emitc
51145612Sharti
52145612Sharti.PRECIOUS: hash
53145616Sharti
54145612Shartihash:
55145612Sharti	( echo '/*' ;							\
56145612Sharti	  echo ' * DO NOT EDIT' ;					\
57145614Sharti	  echo ' * $$''FreeBSD$$' ;					\
58145612Sharti	  echo -n ' * auto-generated from ' ;				\
59145612Sharti	  sed -nEe '/\$$FreeBSD/s/^.*\$$(.*)\$$.*$$/\1/p'		\
60145612Sharti		${.CURDIR}/parse.c ;					\
61145612Sharti	  echo ' * DO NOT EDIT' ;					\
62145612Sharti	  echo ' */' ;							\
63145612Sharti	  echo '#include <sys/types.h>' ;				\
64145612Sharti	  echo ;							\
65145683Sharti	  echo '#include "hash_tables.h"' ;				\
66145612Sharti	  echo ;							\
67145612Sharti	  cat ${.CURDIR}/parse.c | sed					\
68145612Sharti	    -e '1,/DIRECTIVES-START-TAG/d'				\
69145612Sharti	    -e '/DIRECTIVES-END-TAG/,$$d'				\
70145612Sharti	    -e 's/^[^"]*"\([^"]*\)".*$$/\1/' |				\
71145612Sharti	    ${MPH} -d2 -m1 | ${EMITC} -l -s |				\
72145612Sharti	    sed								\
73145612Sharti	    -e 's/^static int g\[\]/static const signed char directive_g[]/' \
74145612Sharti	    -e 's/^static int T0\[\]/static const u_char directive_T0[]/' \
75145612Sharti	    -e 's/^static int T1\[\]/static const u_char directive_T1[]/' \
76145612Sharti	    -e '/^#define uchar unsigned char/d'			\
77145612Sharti	    -e 's/uchar/u_char/g'					\
78145612Sharti	    -e 's/^hash(/directive_hash(/'				\
79145612Sharti	    -e 's/; \*kp;/; kp < key + len;/'				\
80145612Sharti	    -e 's/int len)/size_t len)/'				\
81145612Sharti	    -e 's/= T0\[/= directive_T0\[/'				\
82145612Sharti	    -e 's/= T1\[/= directive_T1\[/'				\
83145616Sharti	    -e 's/g\[f/directive_g[f/g' ;				\
84145616Sharti	  cat ${.CURDIR}/parse.c | sed					\
85145616Sharti	    -e '1,/KEYWORD-START-TAG/d'					\
86145616Sharti	    -e '/KEYWORD-END-TAG/,$$d'					\
87145616Sharti	    -e 's/^[^"]*"\([^"]*\)".*$$/\1/' |				\
88145616Sharti	    ${MPH} -d2 -m1 | ${EMITC} -l -s |				\
89145616Sharti	    sed								\
90145616Sharti	    -e 's/^static int g\[\]/static const signed char keyword_g[]/' \
91145616Sharti	    -e 's/^static int T0\[\]/static const u_char keyword_T0[]/' \
92145616Sharti	    -e 's/^static int T1\[\]/static const u_char keyword_T1[]/' \
93145616Sharti	    -e '/^#define uchar unsigned char/d'			\
94145616Sharti	    -e 's/uchar/u_char/g'					\
95145616Sharti	    -e 's/^hash(/keyword_hash(/'				\
96145616Sharti	    -e 's/int len)/size_t len)/'				\
97145616Sharti	    -e 's/= T0\[/= keyword_T0\[/'				\
98145616Sharti	    -e 's/= T1\[/= keyword_T1\[/'				\
99145616Sharti	    -e 's/g\[f/keyword_g[f/g'					\
100145683Sharti	) > ${.CURDIR}/hash_tables.c
101145612Sharti
10264739Sgreen# Set the shell which make(1) uses.  Bourne is the default, but a decent
10364739Sgreen# Korn shell works fine, and much faster.  Using the C shell for this
10464739Sgreen# will almost certainly break everything, but it's Unix tradition to
10564739Sgreen# allow you to shoot yourself in the foot if you want to :-)
10664739Sgreen
10764739SgreenMAKE_SHELL?=	sh
108146571Sharti.if ${MAKE_SHELL} == "csh" || ${MAKE_SHELL} == "sh" || ${MAKE_SHELL} == "ksh"
109146571ShartiCFLAGS+=	-DDEFSHELLNAME=\"${MAKE_SHELL}\"
11064739Sgreen.else
11164739Sgreen.error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"."
11264739Sgreen.endif
11364739Sgreen
114250719Ssjg.if defined(MK_BMAKE) && ${MK_BMAKE} != "no"
115250699Ssjg# if we are here we don't want this called 'make'
116250699SsjgPROG=	fmake
117250699Ssjgfmake.1: make.1
118250699Ssjg	cp ${.ALLSRC} ${.TARGET}
119250699Ssjg.endif
120250699Ssjg
121264996Sjmmv.if ${MK_TESTS} != "no"
122264996SjmmvSUBDIR+= tests
123264996Sjmmv.endif
124264996Sjmmv
1251590Srgrimes.include <bsd.prog.mk>
126