gzexe: optimize out a grep
[gzip.git] / Makefile.am
blob4f51b612f041b581674133081f7ea6df31d1d86f
1 # Make gzip (GNU zip).
3 # Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2022 Free Software Foundation,
4 # Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ALL_RECURSIVE_TARGETS =
21 BUILT_SOURCES =
23 SUBDIRS = lib doc . tests
24 AM_CPPFLAGS = -I$(top_srcdir)/lib
25 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
27 # Tell the linker to omit references to unused shared libraries.
28 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
30 noinst_LIBRARIES = libver.a
31 nodist_libver_a_SOURCES = version.c version.h
32 DISTCLEANFILES = version.c version.h
34 if LESS
35 ZLESS_MAN = zless.1
36 ZLESS_PROG = zless
37 else
38 ZLESS_MAN =
39 ZLESS_PROG =
40 endif
42 man_MANS = gunzip.1 gzexe.1 gzip.1 \
43   zcat.1 zcmp.1 zdiff.1 zforce.1 zgrep.1 $(ZLESS_MAN) zmore.1 znew.1
45 EXTRA_DIST = $(ACINCLUDE_INPUTS) $(man_MANS) \
46   ChangeLog-2007 \
47   cfg.mk        \
48   dist-check.mk \
49   algorithm.doc \
50   gunzip.in gzexe.in gzip.doc \
51   revision.h sample/makecrc.c \
52   sample/ztouch sample/add.c sample/sub.c sample/zread.c sample/zfile \
53   tailor.h \
54   zcat.in zcmp.in zdiff.in \
55   zegrep.in zfgrep.in zforce.in zgrep.in zless.in zmore.in znew.in
56 noinst_HEADERS = gzip.h lzw.h
58 bin_PROGRAMS = gzip
59 bin_SCRIPTS = gunzip gzexe zcat zcmp zdiff \
60   zegrep zfgrep zforce zgrep $(ZLESS_PROG) zmore znew
61 gzip_SOURCES = \
62   bits.c deflate.c gzip.c inflate.c \
63   trees.c unlzh.c unlzw.c unpack.c unzip.c util.c zip.c
64 gzip_LDADD = libver.a lib/libgzip.a
65 gzip_LDADD += $(LIB_CLOCK_GETTIME)
66 if IBM_Z_DFLTCC
67 gzip_SOURCES += dfltcc.c
68 endif
70 BUILT_SOURCES += version.c
71 version.c: Makefile
72         $(AM_V_GEN)rm -f $@
73         $(AM_V_at)printf '#include <config.h>\n' > $@t
74         $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
75         $(AM_V_at)chmod a-w $@t
76         $(AM_V_at)mv $@t $@
78 BUILT_SOURCES += version.h
79 version.h: Makefile
80         $(AM_V_GEN)rm -f $@
81         $(AM_V_at)printf 'extern char const *Version;\n' > $@t
82         $(AM_V_at)chmod a-w $@t
83         $(AM_V_at)mv $@t $@
85 gzip.doc: gzip.1
86         $(AM_V_GEN)groff -man -Tascii $(srcdir)/gzip.1 | col -b | uniq > $@-t \
87           && mv $@-t $@
89 gzip.doc.gz: gzip.doc $(bin_PROGRAMS)
90         $(AM_V_GEN)./gzip < $(srcdir)/gzip.doc >$@-t && mv $@-t $@
92 SUFFIXES = .in
93 .in:
94         $(AM_V_GEN)rm -f $@-t $@ \
95           && sed \
96                 -e 's|/bin/sh|$(SHELL)|g' \
97                 -e 's|[@]GREP@|$(GREP)|g' \
98                 -e "s|'gzip'|$(GZIP_TRANSFORMED)|g" \
99                 -e "s|'zdiff'|$(ZDIFF_TRANSFORMED)|g" \
100                 -e "s|'zgrep'|$(ZGREP_TRANSFORMED)|g" \
101                 -e 's|[@]VERSION@|$(VERSION)|g' \
102                 $(srcdir)/$@.in >$@-t \
103           && chmod a=rx $@-t \
104           && mv $@-t $@
106 # Arrange so that .tarball-version appears only in the distribution
107 # tarball, and never in a checked-out repository.
108 dist-hook: gen-ChangeLog
109         $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
111 gen_start_date = 2008-01-01
112 .PHONY: gen-ChangeLog
113 gen-ChangeLog:
114         $(AM_V_GEN)if test -d .git; then                                \
115           $(top_srcdir)/build-aux/gitlog-to-changelog                   \
116             --since=$(gen_start_date) > $(distdir)/cl-t &&              \
117             { rm -f $(distdir)/ChangeLog &&                             \
118               mv $(distdir)/cl-t $(distdir)/ChangeLog; }                \
119         fi
121 # Prepend "." to $PATH:
122 new_path = PATH=.$(PATH_SEPARATOR)$$PATH
124 # A simple test, just of gzip -- more of a sanity check than anything else.
125 FILES_TO_CHECK = $(bin_SCRIPTS) \
126   $(top_srcdir)/ChangeLog $(top_srcdir)/configure $(top_srcdir)/gzip.c
127 check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz
128         $(AM_V_GEN)$(new_path); { test '$(srcdir)' != . \
129                                     || zdiff gzip.doc.gz; }
130         $(AM_V_at)$(new_path); zdiff $(srcdir)/gzip.doc $(srcdir)/gzip.doc
131         $(AM_V_at)$(new_path); zdiff $(srcdir)/gzip.doc gzip.doc.gz
132         $(AM_V_at)$(new_path); zdiff - $(srcdir)/gzip.doc <gzip.doc.gz
133         $(AM_V_at)$(new_path); zdiff gzip.doc.gz gzip.doc.gz
134         $(AM_V_at)$(new_path); zgrep -iV >/dev/null
135         $(AM_V_at)$(new_path);                          \
136         for opt in --rsyncable '' -1 -9; do             \
137           for file in $(FILES_TO_CHECK); do             \
138             gzip $$opt -c -- "$$file"                   \
139               | gzip -d | cmp - "$$file" || exit 1;     \
140           done;                                         \
141         done
143 install-exec-hook: remove-installed-links
144 install-exec-hook remove-installed-links:
145         @for prog_ext in $(bin_PROGRAMS) $(bin_SCRIPTS); do \
146           prog=`echo "$$prog_ext"|sed 's/$(EXEEXT)$$//'`; \
147           case $$prog in \
148           gunzip) aliases='uncompress';; \
149           *) continue;; \
150           esac; \
151           transform='$(transform)'; \
152           test "X$$prog" = "X$$prog_ext" || \
153             transform="$$transform"';s/$$/$(EXEEXT)/'; \
154           destbindir=$(DESTDIR)$(bindir); \
155           source=`echo "$$prog"|sed "$$transform"`; \
156           for alias in $$aliases; do \
157             dest=`echo "$$alias"|sed "$$transform"`; \
158             (set -x; \
159              cd "$$destbindir" && \
160              rm -f "$$dest" && \
161              case $@ in \
162              install-exec-hook) \
163                ln "$$source" "$$dest" || $(LN_S) "$$source" "$$dest";; \
164              esac \
165             ) || exit; \
166           done; \
167         done
169 uninstall-local: remove-installed-links
171 ALL_RECURSIVE_TARGETS += distcheck-hook
172 distcheck-hook:
173         $(MAKE) my-distcheck
175 MAINTAINERCLEANFILES = gzip.doc
177 MOSTLYCLEANFILES = _match.i match_.s _match.S gzip.doc.gz \
178   gunzip gzexe zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew
180 # gzip, zdiff and zgrep are used by installed scripts, and installed names
181 # might be transformed by 'configure' options like --program-transform-name.
182 # Create executabls in the current directory by the transformed names,
183 # for the benefit of 'make check'.
184 if GZIP_IS_TRANSFORMED
185 BUILT_SOURCES += $(GZIP_TRANSFORMED)
186 MOSTLYCLEANFILES += $(GZIP_TRANSFORMED)
187 $(GZIP_TRANSFORMED):
188         printf '%s\n' >'$@' \
189           '#!$(SHELL)' \
190           'exec '\''$(abs_top_builddir)/gzip'\'' "$$@"'
191         chmod a+x $@
192 endif
193 if ZDIFF_IS_TRANSFORMED
194 BUILT_SOURCES += $(ZDIFF_TRANSFORMED)
195 MOSTLYCLEANFILES += $(ZDIFF_TRANSFORMED)
196 $(ZDIFF_TRANSFORMED):
197         printf '%s\n' >'$@' \
198           '#!$(SHELL)' \
199           'exec '\''$(abs_top_builddir)/zdiff'\'' "$$@"'
200         chmod a+x $@
201 endif
202 if ZGREP_IS_TRANSFORMED
203 BUILT_SOURCES += $(ZGREP_TRANSFORMED)
204 MOSTLYCLEANFILES += $(ZGREP_TRANSFORMED)
205 $(ZGREP_TRANSFORMED):
206         printf '%s\n' >'$@' \
207           '#!$(SHELL)' \
208           'exec '\''$(abs_top_builddir)/zgrep'\'' "$$@"'
209         chmod a+x $@
210 endif