source: trunk/essentials/sys-devel/automake-1.8/lib/am/distdir.am

Last change on this file was 3118, checked in by bird, 18 years ago

automake 1.8.5

File size: 15.5 KB
Line 
1## automake - create Makefile.in from Makefile.am
2## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3
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.
8
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.
13
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.
18
19## DIST_COMMON comes first so that README can be the very first file.
20DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
21
22if %?TOPDIR_P%
23distdir = $(PACKAGE)-$(VERSION)
24top_distdir = $(distdir)
25
26am__remove_distdir = \
27 { test ! -d $(distdir) \
28 || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
29 && rm -fr $(distdir); }; }
30endif %?TOPDIR_P%
31
32.PHONY: distdir
33distdir: $(DISTFILES)
34##
35## For Gnits users, this is pretty handy. Look at 15 lines
36## in case some explanatory text is desirable.
37##
38if %?TOPDIR_P%
39if %?CK-NEWS%
40 @case `sed 15q $(srcdir)/NEWS` in \
41 *"$(VERSION)"*) : ;; \
42 *) \
43 echo "NEWS not updated; not releasing" 1>&2; \
44 exit 1;; \
45 esac
46endif %?CK-NEWS%
47endif %?TOPDIR_P%
48##
49## Only for the top dir.
50##
51if %?TOPDIR_P%
52 $(am__remove_distdir)
53 mkdir $(distdir)
54endif %?TOPDIR_P%
55##
56##
57?DISTDIRS? $(mkdir_p) %DISTDIRS%
58##
59##
60 @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
61 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
62 list='$(DISTFILES)'; for file in $$list; do \
63##
64## Yet another hack to support SUN make.
65##
66## Let's assume `foo' appears in DISTFILES and is not a built file.
67## When building with VPATH=$(srcdir), SUN make and OSF1/Tru64 will
68## rewrite `foo' as `$(srcdir)/foo'. An attempt to install the file
69## with
70## cp $file $(distdir)/$file
71## will thus install $(srcdir)/foo as $(distdir)/$(srcdir)/foo
72## instead of $(distdir)/foo.
73##
74## So let's strip this leading $(srcdir)/ when it exists. (As far we
75## know, only SUN make and OSF1/Tru64 make add it.) Searching whether
76## the file is to be found in the source or build directory will be
77## done latter.
78##
79## In case we are _not_ using SUN or OSF1/Tru64 make, how can we be sure
80## we are not stripping a legitimate filename that starts with the
81## same pattern as $(srcdir)?
82## Well, it can't happen without the Makefile author distributing
83## something out of the distribution (which is bad). As an example,
84## consider `EXTRA_DIST = ../bar'. This is an issue if $srcdir is `..',
85## however getting this value for srcdir is impossible: `EXTRA_DIST = ../bar'
86## implies we are in a subdirectory (so `../bar' is within the package),
87## hence `$srcdir' is something like `../../subdir'.
88##
89## There is more to say about files which are above the current directory,
90## like `../bar' in the previous example. The OSF1/Tru64 make
91## implementation can simplify filenames resulting from a VPATH lookup.
92## For instance if `VPATH = ../../subdir' and `../bar' is found in that
93## VPATH directory, then occurrences of `../bar' will be replaced by
94## `../../bar' (instead of `../../subdir/../bar'). This obviously defeats
95## any attempt to strip a leading $srcdir. Presently we have no workaround
96## for this. We avoid this issue by writing `EXTRA_DIST = $(srcdir)/../bar'
97## instead of `EXTRA_DIST = ../bar'. This prefixing is needed only for files
98## above the current directory. Fortunately, apart from auxdir files which
99## can be located in .. or ../.., this situation hardly occurs in practice.
100##
101 case $$file in \
102 $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
103## Also rewrite $(top_srcdir) (which sometimes appears in DISTFILES, and can
104## be absolute) by $(top_builddir) (which is always relative). $(srcdir) will
105## be prepended latter.
106 $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
107 esac; \
108##
109## Always look for the file in the build directory first. That way
110## for something like yacc output we will correctly pick up the latest
111## version. Also check for directories in the build directory first,
112## so one can ship generated directories.
113##
114 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
115##
116## Make the subdirectory for the file. This is going to make `dist'
117## really crawl, but it seems like the only way to do it, given that
118## files in subdirectories can be specified for `dist' conditionally.
119##
120 dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
121 if test "$$dir" != "$$file" && test "$$dir" != "."; then \
122 dir="/$$dir"; \
123 $(mkdir_p) "$(distdir)$$dir"; \
124 else \
125 dir=''; \
126 fi; \
127##
128## Use cp, not ln. There are situations in which "ln" can fail. For
129## instance a file to distribute could actually be a cross-filesystem
130## symlink -- this can easily happen if "gettextize" was run on the
131## distribution.
132##
133 if test -d $$d/$$file; then \
134## Don't mention $$file in destination argument, since this fails if
135## destination directory already exists. Also, use `-R' and not `-r'.
136## `-r' is almost always incorrect.
137##
138## If a directory exists both in `.' and $(srcdir), then
139## We copy the files from $(srcdir) first and then install those from
140## `.'. This can help people who distribute directories made of
141## source files _and_ generated files. It is also important when the
142## directory exists only in $(srcdir), because some vendor Make (such
143## as Tru64) will magically create an empty directory in `.'
144 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
145 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
146 fi; \
147 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
148 else \
149## Test for file existence because sometimes a file gets included in
150## DISTFILES twice. For example this happens when a single source
151## file is used in building more than one program.
152 test -f $(distdir)/$$file \
153 || cp -p $$d/$$file $(distdir)/$$file \
154 || exit 1; \
155 fi; \
156 done
157##
158## Test for directory existence here because previous automake
159## invocation might have created some directories. Note that we
160## explicitly set distdir for the subdir make; that lets us mix-n-match
161## many automake-using packages into one large package, and have "dist"
162## at the top level do the right thing. If we're in the topmost
163## directory, then we use `distdir' instead of `top_distdir'; this lets
164## us work correctly with an enclosing package.
165##
166if %?SUBDIRS%
167 list='$(%DIST_SUBDIR_NAME%)'; for subdir in $$list; do \
168 if test "$$subdir" = .; then :; else \
169 test -d "$(distdir)/$$subdir" \
170 || mkdir "$(distdir)/$$subdir" \
171 || exit 1; \
172 (cd $$subdir && \
173 $(MAKE) $(AM_MAKEFLAGS) \
174 top_distdir="../$(top_distdir)" \
175 distdir="../$(distdir)/$$subdir" \
176 distdir) \
177 || exit 1; \
178 fi; \
179 done
180endif %?SUBDIRS%
181##
182## We might have to perform some last second updates, such as updating
183## info files.
184## We must explicitly set distdir and top_distdir for these sub-makes.
185##
186if %?DIST-TARGETS%
187 $(MAKE) $(AM_MAKEFLAGS) \
188 top_distdir="$(top_distdir)" distdir="$(distdir)" \
189 %DIST-TARGETS%
190endif %?DIST-TARGETS%
191##
192## This complex find command will try to avoid changing the modes of
193## links into the source tree, in case they're hard-linked. It will
194## also make directories writable by everybody, because some
195## brain-dead tar implementations change ownership and permissions of
196## a directory before extracting the files, thus becoming unable to
197## extract them.
198##
199## Ignore return result from chmod, because it might give an error
200## if we chmod a symlink.
201##
202## Another nastiness: if the file is unreadable by us, we make it
203## readable regardless of the number of links to it. This only
204## happens in perverse cases.
205##
206## We use $(install_sh) because that is a known-portable way to modify
207## the file in place in the source tree.
208##
209if %?TOPDIR_P%
210 -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
211 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
212 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
213 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
214 || chmod -R a+r $(distdir)
215endif %?TOPDIR_P%
216
217
218
219
220## --------------------------------------- ##
221## Building various distribution flavors. ##
222## --------------------------------------- ##
223
224## Note that we don't use GNU tar's `-z' option. One reason (but not
225## the only reason) is that some versions of tar (e.g., OSF1)
226## interpret `-z' differently.
227##
228## The -o option of GNU tar used to exclude empty directories. This
229## behavior was fixed in tar 1.12 (released on 1997-04-25). But older
230## versions of tar are still used (for instance NetBSD 1.6.1 ships
231## with tar 1.11.2). We do not do anything specific w.r.t. this
232## incompatibility since packages where empty directories need to be
233## present in the archive are really unusual.
234
235if %?TOPDIR_P%
236
237?GZIP?DIST_ARCHIVES += $(distdir).tar.gz
238GZIP_ENV = --best
239.PHONY: dist-gzip
240dist-gzip: distdir
241 $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
242 $(am__remove_distdir)
243
244?BZIP2?DIST_ARCHIVES += $(distdir).tar.bz2
245.PHONY: dist-bzip2
246dist-bzip2: distdir
247 $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
248 $(am__remove_distdir)
249
250?COMPRESS?DIST_ARCHIVES += $(distdir).tar.Z
251.PHONY: dist-tarZ
252dist-tarZ: distdir
253 $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
254 $(am__remove_distdir)
255
256?SHAR?DIST_ARCHIVES += $(distdir).shar.gz
257.PHONY: dist-shar
258dist-shar: distdir
259 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
260 $(am__remove_distdir)
261
262?ZIP?DIST_ARCHIVES += $(distdir).zip
263.PHONY: dist-zip
264dist-zip: distdir
265 -rm -f $(distdir).zip
266 zip -rq $(distdir).zip $(distdir)
267 $(am__remove_distdir)
268
269endif %?TOPDIR_P%
270
271
272
273## ------------------------------------------------- ##
274## Building all the requested distribution flavors. ##
275## ------------------------------------------------- ##
276
277## Currently we cannot use if/endif inside a rule. The file_contents
278## parser needs work.
279
280if %?TOPDIR_P%
281
282.PHONY: dist dist-all
283dist dist-all: distdir
284?GZIP? $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
285?BZIP2? $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
286?COMPRESS? $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
287?SHAR? shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
288?ZIP? -rm -f $(distdir).zip
289?ZIP? zip -rq $(distdir).zip $(distdir)
290 $(am__remove_distdir)
291
292endif %?TOPDIR_P%
293
294
295## ------------------------- ##
296## Checking a distribution. ##
297## ------------------------- ##
298
299
300if %?TOPDIR_P%
301# This target untars the dist file and tries a VPATH configuration. Then
302# it guarantees that the distribution is self-contained by making another
303# tarfile.
304.PHONY: distcheck
305distcheck: dist
306 case '$(DIST_ARCHIVES)' in \
307 *.tar.gz*) \
308 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - ;;\
309 *.tar.bz2*) \
310 bunzip2 -c $(distdir).tar.bz2 | $(AMTAR) xf - ;;\
311 *.tar.Z*) \
312 uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\
313 *.shar.gz*) \
314 GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
315 *.zip*) \
316 unzip $(distdir).zip ;;\
317 esac
318## Make the new source tree read-only. Distributions ought to work in
319## this case. However, make the top-level directory writable so we
320## can make our new subdirs.
321 chmod -R a-w $(distdir); chmod a+w $(distdir)
322 mkdir $(distdir)/_build
323 mkdir $(distdir)/_inst
324## Undo the write access.
325 chmod a-w $(distdir)
326## Compute the absolute path of `_inst'. Strip any leading DOS drive
327## to allow DESTDIR installations. Otherwise "$(DESTDIR)$(prefix)" would
328## expand to "c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst".
329 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
330## We will attemp a DESTDIR install in $dc_destdir. We don't
331## create this directory under $dc_install_base, because it would
332## create very long directory names.
333 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
334?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
335 && cd $(distdir)/_build \
336 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
337?GETTEXT? --with-included-gettext \
338## Additional flags for configure. Keep this last in the configure
339## invocation so the user can override previous options.
340 $(DISTCHECK_CONFIGURE_FLAGS) \
341 && $(MAKE) $(AM_MAKEFLAGS) \
342 && $(MAKE) $(AM_MAKEFLAGS) dvi \
343 && $(MAKE) $(AM_MAKEFLAGS) check \
344 && $(MAKE) $(AM_MAKEFLAGS) install \
345 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
346 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
347 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
348 distuninstallcheck \
349## Make sure the package has proper DESTDIR support (we could not test this
350## in the previous install/installcheck/uninstall test, because it's reasonable
351## for installcheck to fail in a DESTDIR install).
352## We make the `$dc_install_base' read-only because this is where files
353## with missing DESTDIR support are likely to be installed.
354 && chmod -R a-w "$$dc_install_base" \
355## The logic here is quite convoluted because we must clean $dc_destdir
356## whatever happens (it won't be erased by the next run of distcheck like
357## $(distdir) is).
358 && ({ \
359## Build the directory, so we can cd into it even if `make install'
360## didn't create it. Use mkdir, not $(mkdir_p) because we want to
361## fail if the directory already exists (PR/413).
362 (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
363 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
364 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
365 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
366 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
367 } || { rm -rf "$$dc_destdir"; exit 1; }) \
368 && rm -rf "$$dc_destdir" \
369 && $(MAKE) $(AM_MAKEFLAGS) dist \
370## Make sure to remove the dists we created in the test build directory.
371 && rm -rf $(DIST_ARCHIVES) \
372 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
373 $(am__remove_distdir)
374 @(echo "$(distdir) archives ready for distribution: "; \
375 list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
376 sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
377
378## Define distuninstallcheck_listfiles and distuninstallcheck separately
379## from distcheck, so that they can be overridden by the user.
380.PHONY: distuninstallcheck
381distuninstallcheck_listfiles = find . -type f -print
382distuninstallcheck:
383## We use -le 1 because the `dir' file (created by install-info)
384## might still exist after uninstall.
385 @cd $(distuninstallcheck_dir) \
386 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
387 || { echo "ERROR: files left after uninstall:" ; \
388 if test -n "$(DESTDIR)"; then \
389 echo " (check DESTDIR support)"; \
390 fi ; \
391 $(distuninstallcheck_listfiles) ; \
392 exit 1; } >&2
393
394## Define distcleancheck_listfiles and distcleancheck separately
395## from distcheck, so that they can be overridden by the user.
396.PHONY: distcleancheck
397distcleancheck_listfiles = find . -type f -print
398distcleancheck: distclean
399 @if test '$(srcdir)' = . ; then \
400 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
401 exit 1 ; \
402 fi
403 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
404 || { echo "ERROR: files left in build directory after distclean:" ; \
405 $(distcleancheck_listfiles) ; \
406 exit 1; } >&2
407endif %?TOPDIR_P%
Note: See TracBrowser for help on using the repository browser.