Install msysDTK-1.0.1
[msysgit.git] / share / automake-1.7 / am / distdir.am
blob67f3f59a667449a62f56079b23bb02c56efdc8a5
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; if not, write to the Free Software
16 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 ## 02111-1307, USA.
19 ## DIST_COMMON comes first so that README can be the very first file.
20 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
22 top_distdir = %TOP_DISTDIR%
23 if %?TOPDIR_P%
24 ## Avoid unsightly `./'.
25 ?DISTDIR?distdir = $(PACKAGE)-$(VERSION)
26 else !%?TOPDIR_P%
27 ?DISTDIR?distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
28 endif !%?TOPDIR_P%
30 if %?TOPDIR_P%
31 am__remove_distdir = \
32   { test ! -d $(distdir) \
33     || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
34          && rm -fr $(distdir); }; }
35 endif %?TOPDIR_P%
37 .PHONY: distdir
38 distdir: $(DISTFILES)
40 ## For Gnits users, this is pretty handy.  Look at 15 lines
41 ## in case some explanatory text is desirable.
43 if %?TOPDIR_P%
44 if  %?CK-NEWS%
45         @case `sed 15q $(srcdir)/NEWS` in \
46         *"$(VERSION)"*) : ;; \
47         *) \
48           echo "NEWS not updated; not releasing" 1>&2; \
49           exit 1;; \
50         esac
51 endif  %?CK-NEWS%
52 endif %?TOPDIR_P%
54 ## Only for the top dir.
56 if %?TOPDIR_P%
57         $(am__remove_distdir)
58         mkdir $(distdir)
59 endif %?TOPDIR_P%
62 ?DISTDIRS?      $(mkinstalldirs) %DISTDIRS%
65         @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
66         topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
67         list='$(DISTFILES)'; for file in $$list; do \
69 ## Yet another hack to support SUN make.
71 ## Let's assume `foo' appears in DISTFILES and is not a built file.
72 ## When building with VPATH=$(srcdir), SUN make will rewrite `foo' as
73 ## `$(srcdir)/foo'.  An attempt to install the file with
74 ##    cp $file $(distdir)/$file
75 ## will thus install $(srcdir)/foo as $(distdir)/$(srcdir)/foo
76 ## instead of $(distdir)/foo.
78 ## So let's strip this leading $(srcdir)/ when it exists.  (As far we
79 ## know, only SUN make adds it.)  Searching whether the file is to be
80 ## found in the source or build directory will be done latter.
82 ## In case we are _not_ using SUN make, how can we be sure we are
83 ## not stripping a legitimate filename that starts with the same
84 ## pattern as $(srcdir)?
85 ## Well, it can't happen without the Makefile author distributing
86 ## something out of the distribution (which is bad).   As an example,
87 ## consider `EXTRA_DIST = ../bar'.  This is an issue if $srcdir is `..',
88 ## however getting this value for srcdir is impossible: `EXTRA_DIST = ../bar'
89 ## implies we are in a subdirectory (so `../bar' is within the package),
90 ## hence `$srcdir' is something like `../../subdir'.
92           case $$file in \
93             $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
94 ## Also rewrite $(top_srcdir) (which sometimes appears in DISTFILES, and can
95 ## be absolute) by $(top_builddir) (which is always relative).  $(srcdir) will
96 ## be prepended latter.
97             $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
98           esac; \
100 ## Always look for the file in the build directory first.  That way
101 ## for something like yacc output we will correctly pick up the latest
102 ## version.  Also check for directories in the build directory first,
103 ## so one can ship generated directories.
105           if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
107 ## Make the subdirectory for the file.  This is going to make `dist'
108 ## really crawl, but it seems like the only way to do it, given that
109 ## files in subdirectories can be specified for `dist' conditionally.
111           dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
112           if test "$$dir" != "$$file" && test "$$dir" != "."; then \
113             dir="/$$dir"; \
114             $(mkinstalldirs) "$(distdir)$$dir"; \
115           else \
116             dir=''; \
117           fi; \
119 ## Use cp, not ln.  There are situations in which "ln" can fail.  For
120 ## instance a file to distribute could actually be a cross-filesystem
121 ## symlink -- this can easily happen if "gettextize" was run on the
122 ## distribution.
124           if test -d $$d/$$file; then \
125 ## Don't mention $$file in destination argument, since this fails if
126 ## destination directory already exists.  Also, use `-R' and not `-r'.
127 ## `-r' is almost always incorrect.
129 ## If a directory exists both in `.' and $(srcdir), then
130 ## We copy the files from $(srcdir) first and then install those from
131 ## `.'.  This can help people who distribute directories made of
132 ## source files _and_ generated files.  It is also important when the
133 ## directory exists only in $(srcdir), because some vendor Make (such
134 ## as Tru64) will magically create an empty directory in `.'
135             if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
136               cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
137             fi; \
138             cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
139           else \
140 ## Test for file existence because sometimes a file gets included in
141 ## DISTFILES twice.  For example this happens when a single source
142 ## file is used in building more than one program.
143             test -f $(distdir)/$$file \
144             || cp -p $$d/$$file $(distdir)/$$file \
145             || exit 1; \
146           fi; \
147         done
149 ## Test for directory existence here because previous automake
150 ## invocation might have created some directories.  Note that we
151 ## explicitly set distdir for the subdir make; that lets us mix-n-match
152 ## many automake-using packages into one large package, and have "dist"
153 ## at the top level do the right thing.  If we're in the topmost
154 ## directory, then we use `distdir' instead of `top_distdir'; this lets
155 ## us work correctly with an enclosing package.
157 if %?SUBDIRS%
158         list='$(%DIST_SUBDIR_NAME%)'; for subdir in $$list; do \
159           if test "$$subdir" = .; then :; else \
160             test -d $(distdir)/$$subdir \
161             || mkdir $(distdir)/$$subdir \
162             || exit 1; \
163             (cd $$subdir && \
164               $(MAKE) $(AM_MAKEFLAGS) \
165                 top_distdir="$(top_distdir)" \
166                 distdir=../$(distdir)/$$subdir \
167                 distdir) \
168               || exit 1; \
169           fi; \
170         done
171 endif %?SUBDIRS%
173 ## We might have to perform some last second updates, such as updating
174 ## info files.
175 ## We must explicitly set distdir and top_distdir for these sub-makes.
177 if %?DIST-TARGETS%
178         $(MAKE) $(AM_MAKEFLAGS) \
179           top_distdir="$(top_distdir)" distdir="$(distdir)" \
180           %DIST-TARGETS%
181 endif %?DIST-TARGETS%
183 ## This complex find command will try to avoid changing the modes of
184 ## links into the source tree, in case they're hard-linked.  It will
185 ## also make directories writable by everybody, because some
186 ## brain-dead tar implementations change ownership and permissions of
187 ## a directory before extracting the files, thus becoming unable to
188 ## extract them.
190 ## Ignore return result from chmod, because it might give an error
191 ## if we chmod a symlink.
193 ## Another nastiness: if the file is unreadable by us, we make it
194 ## readable regardless of the number of links to it.  This only
195 ## happens in perverse cases.
197 ## We use $(install_sh) because that is a known-portable way to modify
198 ## the file in place in the source tree.
200 if %?TOPDIR_P%
201         -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
202           ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
203           ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
204           ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
205         || chmod -R a+r $(distdir)
206 endif %?TOPDIR_P%
211 ## --------------------------------------- ##
212 ## Building various distribution flavors.  ##
213 ## --------------------------------------- ##
215 ## Note that we don't use GNU tar's `-z' option.  One reason (but not
216 ## the only reason) is that some versions of tar (e.g., OSF1)
217 ## interpret `-z' differently.
219 if %?TOPDIR_P%
221 GZIP_ENV = --best
222 .PHONY: dist-gzip
223 dist-gzip: distdir
224         $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
225         $(am__remove_distdir)
227 if  %?BZIP2%
228 .PHONY: dist-bzip2
229 dist-bzip2: distdir
230         $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
231         $(am__remove_distdir)
232 endif  %?BZIP2%
235 if  %?COMPRESS%
236 .PHONY: dist-tarZ
237 dist-tarZ: distdir
238         $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
239         $(am__remove_distdir)
240 endif  %?COMPRESS%
243 if  %?SHAR%
244 .PHONY: dist-shar
245 dist-shar: distdir
246         shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
247         $(am__remove_distdir)
248 endif  %?SHAR%
251 if  %?ZIP%
252 .PHONY: dist-zip
253 dist-zip: distdir
254         -rm -f $(distdir).zip
255         zip -rq $(distdir).zip $(distdir)
256         $(am__remove_distdir)
257 endif  %?ZIP%
259 endif %?TOPDIR_P%
263 ## ------------------------------------------------- ##
264 ## Building all the requested distribution flavors.  ##
265 ## ------------------------------------------------- ##
267 ## Currently we cannot use if/endif inside a rule.  The file_contents
268 ## parser needs work.
270 if %?TOPDIR_P%
272 .PHONY: dist dist-all
273 dist dist-all: distdir
274         $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
275 ?BZIP2? $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
276 ?COMPRESS?      $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
277 ?SHAR?  shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
278 ?ZIP?   -rm -f $(distdir).zip
279 ?ZIP?   zip -rq $(distdir).zip $(distdir)
280         $(am__remove_distdir)
282 endif %?TOPDIR_P%
285 ## ------------------------- ##
286 ## Checking a distribution.  ##
287 ## ------------------------- ##
290 if %?TOPDIR_P%
291 # This target untars the dist file and tries a VPATH configuration.  Then
292 # it guarantees that the distribution is self-contained by making another
293 # tarfile.
294 .PHONY: distcheck
295 distcheck: dist
296         $(am__remove_distdir)
297         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
298 ## Make the new source tree read-only.  Distributions ought to work in
299 ## this case.  However, make the top-level directory writable so we
300 ## can make our new subdirs.
301         chmod -R a-w $(distdir); chmod a+w $(distdir)
302         mkdir $(distdir)/=build
303         mkdir $(distdir)/=inst
304 ## Undo the write access.
305         chmod a-w $(distdir)
306         dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \
307 ## We will attemp a DESTDIR install in $dc_destdir.  We don't
308 ## create this directory under $dc_install_base, because it would
309 ## create very long directory names.
310           && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
311 ?DISTCHECK-HOOK?          && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
312           && cd $(distdir)/=build \
313           && ../configure --srcdir=.. --prefix="$$dc_install_base" \
314 ?GETTEXT?           --with-included-gettext \
315 ## Additional flags for configure.  Keep this last in the configure
316 ## invocation so the user can override previous options.
317             $(DISTCHECK_CONFIGURE_FLAGS) \
318           && $(MAKE) $(AM_MAKEFLAGS) \
319           && $(MAKE) $(AM_MAKEFLAGS) dvi \
320           && $(MAKE) $(AM_MAKEFLAGS) check \
321           && $(MAKE) $(AM_MAKEFLAGS) install \
322           && $(MAKE) $(AM_MAKEFLAGS) installcheck \
323           && $(MAKE) $(AM_MAKEFLAGS) uninstall \
324           && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
325                 distuninstallcheck \
326 ## Make sure the package has proper DESTDIR support (we could not test this
327 ## in the previous install/installcheck/uninstall test, because it's reasonable
328 ## for installcheck to fail in a DESTDIR install).
329 ## We make the `$dc_install_base' read-only because this is where files
330 ## with missing DESTDIR support are likely to be installed.
331           && chmod -R a-w "$$dc_install_base" \
332 ## The logic here is quite convoluted because we must clean $dc_destdir
333 ## whatever happens (it won't be erased by the next run of distcheck like
334 ## $(distdir) is).
335           && ({ \
336 ## Build the directory, so we can cd into it even if `make install'
337 ## didn't create it.
338                (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
339                && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
340                && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
341                && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
342                     distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
343               } || { rm -rf "$$dc_destdir"; exit 1; }) \
344           && rm -rf "$$dc_destdir" \
345           && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
346 ## Make sure to remove the dist file we created in the test build
347 ## directory.
348           && rm -f $(distdir).tar.gz \
349           && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
350         $(am__remove_distdir)
351         @echo "$(distdir).tar.gz is ready for distribution" | \
352           sed 'h;s/./=/g;p;x;p;x'
354 ## Define distuninstallcheck_listfiles and distuninstallcheck separately
355 ## from distcheck, so that they can be overridden by the user.
356 .PHONY: distuninstallcheck
357 distuninstallcheck_listfiles = find . -type f -print
358 distuninstallcheck:
359 ## We use -le 1 because the `dir' file might still exist after
360 ## uninstall.
361         cd $(distuninstallcheck_dir) \
362         && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
363            || { echo "ERROR: files left after uninstall:" ; \
364                 if test -n "$(DESTDIR)"; then \
365                   echo "  (check DESTDIR support)"; \
366                 fi ; \
367                 $(distuninstallcheck_listfiles) ; \
368                 exit 1; } >&2
370 ## Define distcleancheck_listfiles and distcleancheck separately
371 ## from distcheck, so that they can be overridden by the user.
372 .PHONY: distcleancheck
373 distcleancheck_listfiles = find . -type f -print
374 distcleancheck: distclean
375         if test '$(srcdir)' = . ; then \
376           echo "ERROR: distcleancheck can only run from a VPATH build" ; \
377           exit 1 ; \
378         fi
379         test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
380           || { echo "ERROR: files left in build directory after distclean:" ; \
381                $(distcleancheck_listfiles) ; \
382                exit 1; } >&2
383 endif %?TOPDIR_P%