xref: /freebsd/usr.bin/grep/Makefile (revision 5c831a5bd61576cacb48b39f8eeb47b92707a355)
1#	$NetBSD: Makefile,v 1.4 2011/02/16 01:31:33 joerg Exp $
2#	$FreeBSD$
3#	$OpenBSD: Makefile,v 1.6 2003/06/25 15:00:04 millert Exp $
4
5.include <src.opts.mk>
6
7.if ${MK_BSD_GREP} == "yes"
8PROG=	grep
9.else
10PROG=	bsdgrep
11CLEANFILES+= bsdgrep.1
12
13bsdgrep.1: grep.1
14	${CP} ${.ALLSRC} ${.TARGET}
15.endif
16SRCS=	file.c grep.c queue.c util.c
17
18.if ${MK_BSD_GREP_FASTMATCH} == "yes"
19# Extra files ported backported for some regex improvements
20.PATH: ${.CURDIR}/regex
21SRCS+=	fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c
22CFLAGS+=-I${.CURDIR}/regex
23.else
24CFLAGS+= -DWITHOUT_FASTMATCH
25.endif
26
27CFLAGS.gcc+= --param max-inline-insns-single=500
28
29.if ${MK_BSD_GREP} == "yes"
30LINKS=	${BINDIR}/grep ${BINDIR}/egrep \
31	${BINDIR}/grep ${BINDIR}/fgrep \
32	${BINDIR}/grep ${BINDIR}/rgrep \
33	${BINDIR}/grep ${BINDIR}/zgrep \
34	${BINDIR}/grep ${BINDIR}/zegrep \
35	${BINDIR}/grep ${BINDIR}/zfgrep
36
37MLINKS= grep.1 egrep.1 \
38	grep.1 fgrep.1 \
39	grep.1 rgrep.1 \
40	grep.1 zgrep.1 \
41	grep.1 zegrep.1 \
42	grep.1 zfgrep.1
43.endif
44
45LIBADD=	z
46
47.if ${MK_LZMA_SUPPORT} != "no"
48LIBADD+=	lzma
49
50.if ${MK_BSD_GREP} == "yes"
51LINKS+=	${BINDIR}/${PROG} ${BINDIR}/xzgrep \
52	${BINDIR}/${PROG} ${BINDIR}/xzegrep \
53	${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
54	${BINDIR}/${PROG} ${BINDIR}/lzgrep \
55	${BINDIR}/${PROG} ${BINDIR}/lzegrep \
56	${BINDIR}/${PROG} ${BINDIR}/lzfgrep
57
58MLINKS+= grep.1 xzgrep.1 \
59	 grep.1 xzegrep.1 \
60	 grep.1 xzfgrep.1 \
61	 grep.1 lzgrep.1 \
62	 grep.1 lzegrep.1 \
63	 grep.1 lzfgrep.1
64.endif
65.else
66CFLAGS+= -DWITHOUT_LZMA
67.endif
68
69.if ${MK_BZIP2_SUPPORT} != "no"
70LIBADD+=	bz2
71
72.if ${MK_BSD_GREP} == "yes"
73LINKS+= ${BINDIR}/grep ${BINDIR}/bzgrep \
74	${BINDIR}/grep ${BINDIR}/bzegrep \
75	${BINDIR}/grep ${BINDIR}/bzfgrep
76MLINKS+= grep.1 bzgrep.1 \
77	 grep.1 bzegrep.1 \
78	 grep.1 bzfgrep.1
79.endif
80.else
81CFLAGS+= -DWITHOUT_BZIP2
82.endif
83
84.if ${MK_GNU_GREP_COMPAT} != "no"
85CFLAGS+= -I${SYSROOT:U${DESTDIR}}/usr/include/gnu -DWITH_GNU
86LIBADD+=	gnuregex
87.endif
88
89.if ${MK_NLS} != "no"
90.include "${.CURDIR}/nls/Makefile.inc"
91.else
92CFLAGS+= -DWITHOUT_NLS
93.endif
94
95HAS_TESTS=
96SUBDIR.${MK_TESTS}+= tests
97
98.include <bsd.prog.mk>
99