xref: /freebsd-12.1/gnu/usr.bin/grep/Makefile (revision 612c330d)
1# $FreeBSD$
2
3.include <src.opts.mk>
4
5GREP_LIBZ=YES
6
7.if ${MK_BSD_GREP} != "yes"
8PROG=	grep
9.else
10PROG=	gnugrep
11.endif
12SRCS=	closeout.c dfa.c error.c exclude.c grep.c grepmat.c hard-locale.c \
13	isdir.c kwset.c obstack.c quotearg.c savedir.c search.c xmalloc.c \
14	xstrtoumax.c
15CLEANFILES+=	gnugrep.1
16
17CFLAGS+=-I${.CURDIR} -I${SYSROOT:U${DESTDIR}}/usr/include/gnu -DHAVE_CONFIG_H
18
19.if ${MK_BSD_GREP} != "yes"
20LINKS+=	${BINDIR}/grep ${BINDIR}/egrep \
21	${BINDIR}/grep ${BINDIR}/fgrep
22MLINKS=	grep.1 egrep.1 grep.1 fgrep.1
23.endif
24
25LIBADD=	gnuregex bz2
26
27.if defined(GREP_LIBZ) && !empty(GREP_LIBZ)
28LIBADD+=	z
29CFLAGS+=-DHAVE_LIBZ=1
30.endif
31
32gnugrep.1: grep.1
33	${CP} ${.ALLSRC} ${.TARGET}
34
35check:	all
36	@failed=0; total=0; \
37	for tst in ${TESTS}; do \
38		total=$$(($$total+1)); \
39		if GREP=${.OBJDIR}/${PROG} srcdir=${.CURDIR}/tests \
40		   ${.CURDIR}/tests/$$tst; then \
41			echo "PASS: $$tst"; \
42		else \
43			failed=$$(($$failed+1)); \
44			echo "FAIL: $$tst"; \
45		fi; \
46	done; \
47	if [ "$$failed" -eq 0 ]; then \
48		echo "All $$total tests passed"; \
49	else \
50		echo "$$failed of $$total tests failed"; \
51	fi
52
53TESTS=	warning.sh khadafy.sh spencer1.sh bre.sh ere.sh status.sh empty.sh \
54	options.sh backref.sh file.sh
55
56.include <bsd.prog.mk>
57