xref: /freebsd/usr.bin/grep/Makefile (revision 4232f826683298e85d469c0ef17259cecd13b2c7)
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# Extra files ported backported form some regex improvements
19.PATH: ${.CURDIR}/regex
20SRCS+=	fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c xmalloc.c
21CFLAGS+=-I${.CURDIR}/regex
22
23.if ${MK_BSD_GREP} == "yes"
24LINKS=	${BINDIR}/grep ${BINDIR}/egrep \
25	${BINDIR}/grep ${BINDIR}/fgrep \
26	${BINDIR}/grep ${BINDIR}/zgrep \
27	${BINDIR}/grep ${BINDIR}/zegrep \
28	${BINDIR}/grep ${BINDIR}/zfgrep
29
30MLINKS= grep.1 egrep.1 \
31	grep.1 fgrep.1 \
32	grep.1 zgrep.1 \
33	grep.1 zegrep.1 \
34	grep.1 zfgrep.1
35.endif
36
37LIBADD=	z
38
39.if ${MK_LZMA_SUPPORT} != "no"
40LIBADD+=	lzma
41
42.if ${MK_BSD_GREP} == "yes"
43LINKS+=	${BINDIR}/${PROG} ${BINDIR}/xzgrep \
44	${BINDIR}/${PROG} ${BINDIR}/xzegrep \
45	${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
46	${BINDIR}/${PROG} ${BINDIR}/lzgrep \
47	${BINDIR}/${PROG} ${BINDIR}/lzegrep \
48	${BINDIR}/${PROG} ${BINDIR}/lzfgrep
49
50MLINKS+= grep.1 xzgrep.1 \
51	 grep.1 xzegrep.1 \
52	 grep.1 xzfgrep.1 \
53	 grep.1 lzgrep.1 \
54	 grep.1 lzegrep.1 \
55	 grep.1 lzfgrep.1
56.endif
57.else
58CFLAGS+= -DWITHOUT_LZMA
59.endif
60
61.if ${MK_BZIP2_SUPPORT} != "no"
62LIBADD+=	bz2
63
64.if ${MK_BSD_GREP} == "yes"
65LINKS+= ${BINDIR}/grep ${BINDIR}/bzgrep \
66	${BINDIR}/grep ${BINDIR}/bzegrep \
67	${BINDIR}/grep ${BINDIR}/bzfgrep
68MLINKS+= grep.1 bzgrep.1 \
69	 grep.1 bzegrep.1 \
70	 grep.1 bzfgrep.1
71.endif
72.else
73CFLAGS+= -DWITHOUT_BZIP2
74.endif
75
76.if ${MK_GNU_GREP_COMPAT} != "no"
77CFLAGS+= -I${DESTDIR}/usr/include/gnu
78LIBADD+=	gnuregex
79.endif
80
81.if ${MK_NLS} != "no"
82.include "${.CURDIR}/nls/Makefile.inc"
83.else
84CFLAGS+= -DWITHOUT_NLS
85.endif
86
87.if ${MK_TESTS} != "no"
88SUBDIR+=	tests
89.endif
90
91.include <bsd.prog.mk>
92