summaryrefslogtreecommitdiff
path: root/src/Makefile.am
blob: 1aebcf7f9601485f01eda97d69167d362fad0285 (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
## Process this file with automake to create Makefile.in
# Copyright 1997-1998, 2005-2020 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

LN = ln

AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) $(PCRE_CFLAGS)

# Tell the linker to omit references to unused shared libraries.
AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)

bin_PROGRAMS = grep
bin_SCRIPTS = egrep fgrep
grep_SOURCES =					\
  dfasearch.c					\
  die.h						\
  grep.c					\
  kwsearch.c					\
  kwset.c					\
  searchutils.c
if USE_PCRE
grep_SOURCES += pcresearch.c
endif

noinst_HEADERS = grep.h kwset.h search.h system.h

# Sometimes, the expansion of $(LIBINTL) includes -lc which may
# include modules defining variables like 'optind', so libgreputils.a
# must precede $(LIBINTL) in order to ensure we use GNU getopt.
# But libgreputils.a must also follow $(LIBINTL), since libintl uses
# replacement functions defined in libgreputils.a.
LDADD = \
  ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a $(LIBICONV) \
  $(LIBTHREAD)

grep_LDADD = $(LDADD) $(PCRE_LIBS) $(LIBCSTACK)
localedir = $(datadir)/locale
AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib

EXTRA_DIST = egrep.sh

egrep fgrep: egrep.sh Makefile
	$(AM_V_GEN)grep=`echo grep | sed -e '$(transform)'` &&		\
	case $@ in egrep) option=-E;; fgrep) option=-F;; esac &&	\
	shell_does_substrings='set x/y && d=$${1%/*} && test "$$d" = x' && \
	if $(SHELL) -c "$$shell_does_substrings" 2>/dev/null; then	\
	  edit_substring='s,X,X,';					\
	else								\
	  edit_substring='s,\$${0%/\*},`expr "X$$0" : '\''X\\(.*\\)/'\''`,g'; \
	fi &&								\
	sed -e 's|[@]SHELL@|$(SHELL)|g'					\
	    -e "$$edit_substring"					\
	    -e "s|[@]grep@|$$grep|g"					\
	    -e "s|[@]option@|$$option|g" <$(srcdir)/egrep.sh >$@-t
	$(AM_V_at)chmod +x $@-t
	$(AM_V_at)mv $@-t $@

CLEANFILES = egrep fgrep *-t