summaryrefslogtreecommitdiffstats
path: root/contrib/bmake/Makefile
blob: 625c254afcdd931a336e731a330472eebbe100b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#	$Id: Makefile,v 1.49 2015/12/20 22:54:40 sjg Exp $

# Base version on src date
MAKE_VERSION= 20151220

PROG=	bmake

SRCS= \
	arch.c \
	buf.c \
	compat.c \
	cond.c \
	dir.c \
	for.c \
	hash.c \
	job.c \
	main.c \
	make.c \
	make_malloc.c \
	meta.c \
	metachar.c \
	parse.c \
	str.c \
	strlist.c \
	suff.c \
	targ.c \
	trace.c \
	util.c \
	var.c

# from lst.lib/
SRCS+= \
	lstAppend.c \
	lstAtEnd.c \
	lstAtFront.c \
	lstClose.c \
	lstConcat.c \
	lstDatum.c \
	lstDeQueue.c \
	lstDestroy.c \
	lstDupl.c \
	lstEnQueue.c \
	lstFind.c \
	lstFindFrom.c \
	lstFirst.c \
	lstForEach.c \
	lstForEachFrom.c \
	lstInit.c \
	lstInsert.c \
	lstIsAtEnd.c \
	lstIsEmpty.c \
	lstLast.c \
	lstMember.c \
	lstNext.c \
	lstOpen.c \
	lstPrev.c \
	lstRemove.c \
	lstReplace.c \
	lstSucc.c

# this file gets generated by configure
.-include "Makefile.config"

.if !empty(LIBOBJS)
SRCS+= ${LIBOBJS:T:.o=.c}
.endif

# just in case
prefix?= /usr
srcdir?= ${.CURDIR}

DEFAULT_SYS_PATH?= ${prefix}/share/mk

CPPFLAGS+= -DUSE_META
CFLAGS+= ${CPPFLAGS}
CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""

# meta mode can be useful even without filemon 
FILEMON_H ?= /usr/include/dev/filemon/filemon.h
.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
.endif

.PATH:	${srcdir}
.PATH:	${srcdir}/lst.lib

.if make(obj) || make(clean)
SUBDIR+= unit-tests
.endif

# start-delete1 for bsd.after-import.mk
# we skip a lot of this when building as part of FreeBSD etc.

# list of OS's which are derrived from BSD4.4
BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
# we are...
OS!= uname -s
# are we 4.4BSD ?
isBSD44:=${BSD44_LIST:M${OS}}

.if ${isBSD44} == ""
MANTARGET= cat
INSTALL?=${srcdir}/install-sh
.if (${MACHINE} == "sun386")
# even I don't have one of these anymore :-)
CFLAGS+= -DPORTAR
.elif (${MACHINE} != "sunos")
SRCS+= sigcompat.c
CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
.endif
.else
MANTARGET?= man
.endif

# turn this on by default - ignored if we are root
WITH_INSTALL_AS_USER=

# suppress with -DWITHOUT_*
OPTIONS_DEFAULT_YES+= \
	AUTOCONF_MK \
	INSTALL_MK \
	PROG_LINK

OPTIONS_DEFAULT_NO+= \
	PROG_VERSION

# process options now
.include <own.mk>

.if ${MK_PROG_VERSION} == "yes"
PROG_NAME= ${PROG}-${MAKE_VERSION}
.if ${MK_PROG_LINK} == "yes"
SYMLINKS+= ${PROG}-${MAKE_VERSION} ${BINDIR}/${PROG}
.endif
.endif

EXTRACT_MAN=no
# end-delete1

MAN= ${PROG}.1
MAN1= ${MAN}

.if (${PROG} != "make")
CLEANFILES+= my.history
.if make(${MAN}) || !exists(${srcdir}/${MAN})
my.history: ${MAKEFILE}
	@(echo ".Nm"; \
	echo "is derived from NetBSD"; \
	echo ".Xr make 1 ."; \
	echo "It uses autoconf to facilitate portability to other platforms."; \
	echo ".Pp") > $@

.NOPATH: ${MAN}
${MAN}:	make.1 my.history
	@echo making $@
	@sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
	-e '/^.Sh HISTORY/rmy.history' \
	-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@

all beforeinstall: ${MAN}
_mfromdir=.
.endif
.endif

MANTARGET?= cat
MANDEST?= ${MANDIR}/${MANTARGET}1

.if ${MANTARGET} == "cat"
_mfromdir=${srcdir}
.endif

.include <prog.mk>

CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
COPTS.var.c += -Wno-cast-qual
COPTS.job.c += -Wno-format-nonliteral
COPTS.parse.c += -Wno-format-nonliteral
COPTS.var.c += -Wno-format-nonliteral

# Force these
SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
BINDIR= ${BINDIR.bmake:U${prefix}/bin}
MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}

.if !exists(.depend)
${OBJS}: config.h
.endif

# make sure that MAKE_VERSION gets updated.
main.o: ${SRCS} ${MAKEFILE}

# start-delete2 for bsd.after-import.mk
.if ${MK_AUTOCONF_MK} == "yes"
.include <autoconf.mk>
.endif
SHARE_MK?=${SHAREDIR}/mk
MKSRC=${srcdir}/mk
INSTALL?=${srcdir}/install-sh

.if ${MK_INSTALL_MK} == "yes"
install: install-mk
.endif

beforeinstall:
	test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
	test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}

install-mk:
.if exists(${MKSRC}/install-mk)
	test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
	sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
.else
	@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
.endif
# end-delete2

# A simple unit-test driver to help catch regressions
accept test:
	cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
OpenPOWER on IntegriCloud