Merge commit 'upstream/1.4'
[debian/gzip] / Makefile.am
1 # Make gzip (GNU zip).
2
3 # Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2010 Free Software Foundation,
4 # Inc.
5
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.
10
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.
15
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.
19
20 SUBDIRS = lib doc
21 ACLOCAL_AMFLAGS = -I m4
22 AM_CPPFLAGS = -I$(top_srcdir)/lib
23 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
24
25 man_MANS = gunzip.1 gzexe.1 gzip.1 \
26   zcat.1 zcmp.1 zdiff.1 zforce.1 zgrep.1 zless.1 zmore.1 znew.1
27
28 EXTRA_DIST = $(ACINCLUDE_INPUTS) $(man_MANS) \
29   ChangeLog-2007 \
30   tests/hufts-segv.gz \
31   algorithm.doc amiga/match.a amiga/Makefile.gcc amiga/Makefile.sasc \
32   amiga/tailor.c amiga/utime.h atari/Makefile.st crypt.h \
33   gunzip.in gzexe.in gzip.doc gzip.h lzw.h msdos/match.asm msdos/tailor.c \
34   msdos/gzip.prj msdos/doturboc.bat msdos/Makefile.msc msdos/Makefile.bor \
35   msdos/Makefile.djg nt/Makefile.nt os2/gzip.def os2/Makefile.os2 \
36   os2/gzip16.def primos/include/errno.h primos/include/fcntl.h \
37   primos/include/stdlib.h primos/include/sysStat.h \
38   primos/include/sysTypes.h primos/build.cpl primos/readme \
39   primos/primos.c primos/ci.opts revision.h sample/makecrc.c \
40   sample/ztouch sample/add.c sample/sub.c sample/zread.c sample/zfile \
41   tailor.h vms/Makefile.mms vms/gzip.hlp vms/vms.c vms/Readme.vms \
42   vms/Makefile.vms vms/Makefile.gcc vms/makegzip.com zcat.in zcmp.in zdiff.in \
43   zegrep.in zfgrep.in zforce.in zgrep.in zless.in zmore.in znew.in \
44   tests/init.sh
45
46 bin_PROGRAMS = gzip
47 bin_SCRIPTS = gunzip gzexe zcat zcmp zdiff \
48   zegrep zfgrep zforce zgrep zless zmore znew
49 gzip_SOURCES = \
50   bits.c crypt.c deflate.c gzip.c inflate.c lzw.c \
51   trees.c unlzh.c unlzw.c unpack.c unzip.c util.c zip.c
52 gzip_LDADD = lib/libgzip.a
53 gzip_LDADD += $(LIB_CLOCK_GETTIME)
54
55 gzip.doc: gzip.1
56         $(AM_V_GEN)groff -man -Tascii $(srcdir)/gzip.1 | col -b | uniq > $@-t \
57           && mv $@-t $@
58
59 gzip.doc.gz: gzip.doc $(bin_PROGRAMS)
60         $(AM_V_GEN)./gzip < $(srcdir)/gzip.doc >$@-t && mv $@-t $@
61
62 gzip.doc.gz: gzip.doc
63         gzip <$? >$@
64
65 SUFFIXES = .in
66 .in:
67         $(AM_V_GEN)sed \
68                 -e 's|/bin/sh|$(SHELL)|g' \
69                 -e 's|[@]bindir@|'\''$(bindir)'\''|g' \
70                 -e 's|[@]VERSION@|$(VERSION)|g' \
71                 $(srcdir)/$@.in >$@-t \
72           && chmod a+x $@-t \
73           && mv $@-t $@
74
75 # Arrange so that .tarball-version appears only in the distribution
76 # tarball, and never in a checked-out repository.
77 dist-hook: gen-ChangeLog
78         $(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
79
80 gen_start_date = 2008-01-01
81 .PHONY: gen-ChangeLog
82 gen-ChangeLog:
83         $(AM_V_GEN)if test -d .git; then                                \
84           $(top_srcdir)/build-aux/gitlog-to-changelog                   \
85             --since=$(gen_start_date) > $(distdir)/cl-t;                \
86           rm -f $(distdir)/ChangeLog;                                   \
87           mv $(distdir)/cl-t $(distdir)/ChangeLog;                      \
88         fi
89
90 # A simple test, just of gzip -- more of a sanity check than anything else.
91 FILES_TO_CHECK = $(bin_SCRIPTS) \
92   $(top_srcdir)/ChangeLog $(top_srcdir)/configure $(top_srcdir)/gzip.c
93 check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz
94         { test '$(srcdir)' != . || ./zdiff --__bindir . -c gzip.doc.gz; }
95         ./zdiff --__bindir . -c $(srcdir)/gzip.doc $(srcdir)/gzip.doc
96         ./zdiff --__bindir . $(srcdir)/gzip.doc gzip.doc.gz
97         ./zdiff --__bindir . -c - $(srcdir)/gzip.doc <gzip.doc.gz
98         ./zdiff --__bindir . -c gzip.doc.gz gzip.doc.gz
99         ./zgrep --__bindir . -iV >/dev/null
100         for file in $(FILES_TO_CHECK); do \
101           ./gzip -cv -- "$$file" | ./gzip -d | cmp - "$$file" || exit 1; \
102         done
103         ./gzip -dc $(srcdir)/tests/hufts-segv.gz > /dev/null 2>&1; \
104           test $$? = 1
105         k=in-$$$$; printf a | ./gzip > $$k && \
106           test "`cat $$k | ./gzip -dc $$k - $$k`" = aaa && rm $$k
107         @echo 'Test succeeded.'
108
109 TESTS =                                         \
110   tests/helin-segv                              \
111   tests/memcpy-abuse                            \
112   tests/trailing-nul                            \
113   tests/zdiff                                   \
114   tests/zgrep-f
115
116 EXTRA_DIST += $(TESTS)
117
118 # A simple test, just of gzip -- more of a sanity check than anything else.
119 FILES_TO_CHECK = $(bin_SCRIPTS) $(gzip_LDADD) \
120   $(top_srcdir)/ChangeLog $(top_srcdir)/configure $(top_srcdir)/gzip.c
121 check-local: $(FILES_TO_CHECK) gzip.doc.gz
122         { test '$(srcdir)' != . || GZIP_BINDIR=. ./zdiff -c gzip.doc.gz; }
123         GZIP_BINDIR=. ./zdiff -c $(srcdir)/gzip.doc $(srcdir)/gzip.doc
124         GZIP_BINDIR=. ./zdiff $(srcdir)/gzip.doc gzip.doc.gz
125         GZIP_BINDIR=. ./zdiff -c - $(srcdir)/gzip.doc <gzip.doc.gz
126         GZIP_BINDIR=. ./zdiff -c gzip.doc.gz gzip.doc.gz
127         GZIP_BINDIR=. ./zgrep -iV >/dev/null
128         for file in $(FILES_TO_CHECK); do \
129           ./gzip -cv -- "$$file" | ./gzip -d | cmp - "$$file" || exit; \
130         done
131         @echo 'Test succeeded.'
132
133 install-exec-hook: remove-installed-links
134 install-exec-hook remove-installed-links:
135         @for prog_ext in $(bin_PROGRAMS) $(bin_SCRIPTS); do \
136           prog=`echo "$$prog_ext"|sed 's/$(EXEEXT)$$//'`; \
137           case $$prog in \
138           gunzip) aliases='uncompress';; \
139           *) continue;; \
140           esac; \
141           transform='$(transform)'; \
142           test "X$$prog" = "X$$prog_ext" || \
143             transform="$$transform"';s/$$/$(EXEEXT)/'; \
144           destbindir=$(DESTDIR)$(bindir); \
145           source=`echo "$$prog"|sed "$$transform"`; \
146           for alias in $$aliases; do \
147             dest=`echo "$$alias"|sed "$$transform"`; \
148             (set -x; \
149              cd "$$destbindir" && \
150              rm -f "$$dest" && \
151              case $@ in \
152              install-exec-hook) \
153                ln "$$source" "$$dest" || $(LN_S) "$$source" "$$dest";; \
154              esac \
155             ) || exit; \
156           done; \
157         done
158
159 uninstall-local: remove-installed-links
160
161 MAINTAINERCLEANFILES = gzip.doc
162
163 MOSTLYCLEANFILES = _match.i match_.s _match.S gzip.doc.gz \
164   gunzip gzexe zcat zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew
165
166 # Note that the first lines are statements.  They ensure that environment
167 # variables that can perturb tests are unset or set to expected values.
168 # The rest are envvar settings that propagate build-related Makefile
169 # variables to test scripts.
170 TESTS_ENVIRONMENT =                             \
171   tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
172   TMPDIR=$$tmp__; export TMPDIR;                \
173   exec 9>&2;                                    \
174   shell_or_perl_() {                            \
175     if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then                 \
176       if $(PERL) -e 'use warnings' > /dev/null 2>&1; then               \
177         grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=;   \
178         $(PERL) -w$$T_ -I$(srcdir) -MCoreutils                          \
179               -M"CuTmpdir qw($$f)" -- "$$1";    \
180       else                                      \
181         echo 1>&2 "$$tst: configure did not find a usable version of Perl," \
182           "so skipping this test";              \
183         (exit 77);                              \
184       fi;                                       \
185     else                                        \
186       $(SHELL) "$$1";                           \
187     fi;                                         \
188   };                                            \
189   export                                        \
190   abs_top_builddir='$(abs_top_builddir)'        \
191   abs_top_srcdir='$(abs_top_srcdir)'            \
192   abs_srcdir='$(abs_srcdir)'                    \
193   srcdir='$(srcdir)'                            \
194   top_srcdir='$(top_srcdir)'                    \
195   CC='$(CC)'                                    \
196   MAKE=$(MAKE)                                  \
197   PACKAGE_BUGREPORT='$(PACKAGE_BUGREPORT)'      \
198   PACKAGE_VERSION=$(PACKAGE_VERSION)            \
199   PERL='$(PERL)'                                \
200   PREFERABLY_POSIX_SHELL='$(PREFERABLY_POSIX_SHELL)' \
201   REPLACE_GETCWD=$(REPLACE_GETCWD)              \
202   PATH='$(abs_top_builddir)$(PATH_SEPARATOR)'"$$PATH" \
203   ; shell_or_perl_
204
205 VERBOSE = yes