1#	$OpenBSD: Makefile,v 1.3 2020/07/18 14:19:13 deraadt Exp $
2
3.include <bsd.own.mk>    # for KEEPKERNELS
4
5S=	${.CURDIR}/../..
6KFILE=	GENERIC
7.if exists(conf/GENERIC.MP)
8KFILE=	GENERIC.MP
9.endif
10#TDIRS=	${_arch} include pci
11TDIRS=	${_arch} include
12TAGS=	${.CURDIR}/tags
13
14NOPROG=
15NOMAN=
16NOOBJ=
17SUBDIR=	stand
18.if !defined(KEEPKERNELS) || !(make(clean) || make(cleandir))
19SUBDIR+=compile
20.endif
21
22# config the fattest kernel we can find into a temporary dir
23# to create a Makefile.  Then use make to pull some variables
24# out and push them into the sub-shell to expand the paths,
25# and finally run ctags.
26tags::
27	TDIR=`mktemp -d /tmp/_tagXXXXXXXXXX` || exit 1; \
28	eval "S=${S}" && \
29	config -s ${S} -b $${TDIR} ${.CURDIR}/conf/${KFILE} && \
30	eval "_arch=\"`make -V _arch -f $${TDIR}/Makefile`\"" && \
31	eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \
32	eval "_machdir=\$S/arch/$${_mach}" && \
33	eval "_archdir=\$S/arch/$${_arch}" && \
34	eval "HFILES=\"`find $S \( -path $S/arch -o -path $S/stand -o -path $S/lib/libsa -o -path $S/lib/libkern/arch \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_arch} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \
35	eval "SFILES=\"`make -V SFILES -f $${TDIR}/Makefile`\"" && \
36	eval "CFILES=\"`make -V CFILES -f $${TDIR}/Makefile`\"" && \
37	eval "AFILES=\"`make -V AFILES -f $${TDIR}/Makefile`\"" && \
38	ctags -wd -f ${TAGS} $${CFILES} $${HFILES} && \
39	egrep "^[_A-Z]*ENTRY[_A-Z]*\(.*\)" $${SFILES} $${AFILES} | \
40	    sed "s;\\([^:]*\\):\\([^(]*\\)(\\([^, )]*\\)\\(.*\\);\\3	\\1	/^\\2(\\3\\4$$/;" \
41	    >> ${TAGS} && \
42	sort -o ${TAGS} ${TAGS} && \
43	rm -rf $${TDIR}
44
45links:
46	-for i in conf ${TDIRS}; do \
47	    (cd $$i && rm -f tags; ln -s tags tags); done
48
49obj:	_SUBDIRUSE
50
51.include <bsd.prog.mk>
52