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

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

automake 1.7.9

File size: 13.8 KB
Line 
1## automake - create Makefile.in from Makefile.am
2## Copyright (C) 2001, 2002, 2003 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
22top_distdir = %TOP_DISTDIR%
23if %?TOPDIR_P%
24## Avoid unsightly `./'.
25?DISTDIR?distdir = $(PACKAGE)-$(VERSION)
26else !%?TOPDIR_P%
27?DISTDIR?distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
28endif !%?TOPDIR_P%
29
30if %?TOPDIR_P%
31am__remove_distdir = \
32 { test ! -d $(distdir) \
33 || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
34 && rm -fr $(distdir); }; }
35endif %?TOPDIR_P%
36
37.PHONY: distdir
38distdir: $(DISTFILES)
39##
40## For Gnits users, this is pretty handy. Look at 15 lines
41## in case some explanatory text is desirable.
42##
43if %?TOPDIR_P%
44if %?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
51endif %?CK-NEWS%
52endif %?TOPDIR_P%
53##
54## Only for the top dir.
55##
56if %?TOPDIR_P%
57 $(am__remove_distdir)
58 mkdir $(distdir)
59endif %?TOPDIR_P%
60##
61##
62?DISTDIRS? $(mkinstalldirs) %DISTDIRS%
63##
64##
65 @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
66 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
67 list='$(DISTFILES)'; for file in $$list; do \
68##
69## Yet another hack to support SUN make.
70##
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.
77##
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.
81##
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'.
91##
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; \
99##
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.
104##
105 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
106##
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.
110##
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; \
118##
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.
123##
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.
128##
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
148##
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.
156##
157if %?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
171endif %?SUBDIRS%
172##
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.
176##
177if %?DIST-TARGETS%
178 $(MAKE) $(AM_MAKEFLAGS) \
179 top_distdir="$(top_distdir)" distdir="$(distdir)" \
180 %DIST-TARGETS%
181endif %?DIST-TARGETS%
182##
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.
189##
190## Ignore return result from chmod, because it might give an error
191## if we chmod a symlink.
192##
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.
196##
197## We use $(install_sh) because that is a known-portable way to modify
198## the file in place in the source tree.
199##
200if %?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)
206endif %?TOPDIR_P%
207
208
209
210
211## --------------------------------------- ##
212## Building various distribution flavors. ##
213## --------------------------------------- ##
214
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.
218
219if %?TOPDIR_P%
220
221GZIP_ENV = --best
222.PHONY: dist-gzip
223dist-gzip: distdir
224 $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
225 $(am__remove_distdir)
226
227if %?BZIP2%
228.PHONY: dist-bzip2
229dist-bzip2: distdir
230 $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
231 $(am__remove_distdir)
232endif %?BZIP2%
233
234
235if %?COMPRESS%
236.PHONY: dist-tarZ
237dist-tarZ: distdir
238 $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
239 $(am__remove_distdir)
240endif %?COMPRESS%
241
242
243if %?SHAR%
244.PHONY: dist-shar
245dist-shar: distdir
246 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
247 $(am__remove_distdir)
248endif %?SHAR%
249
250
251if %?ZIP%
252.PHONY: dist-zip
253dist-zip: distdir
254 -rm -f $(distdir).zip
255 zip -rq $(distdir).zip $(distdir)
256 $(am__remove_distdir)
257endif %?ZIP%
258
259endif %?TOPDIR_P%
260
261
262
263## ------------------------------------------------- ##
264## Building all the requested distribution flavors. ##
265## ------------------------------------------------- ##
266
267## Currently we cannot use if/endif inside a rule. The file_contents
268## parser needs work.
269
270if %?TOPDIR_P%
271
272.PHONY: dist dist-all
273dist 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)
281
282endif %?TOPDIR_P%
283
284
285## ------------------------- ##
286## Checking a distribution. ##
287## ------------------------- ##
288
289
290if %?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
295distcheck: 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## Compute the absolute path of `_inst'. Strip any leading DOS drive
307## to allow DESTDIR installations. Otherwise $(DESTDIR)$(prefix) would
308## expand to c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst.
309 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
310## We will attemp a DESTDIR install in $dc_destdir. We don't
311## create this directory under $dc_install_base, because it would
312## create very long directory names.
313 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
314?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
315 && cd $(distdir)/_build \
316 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
317?GETTEXT? --with-included-gettext \
318## Additional flags for configure. Keep this last in the configure
319## invocation so the user can override previous options.
320 $(DISTCHECK_CONFIGURE_FLAGS) \
321 && $(MAKE) $(AM_MAKEFLAGS) \
322 && $(MAKE) $(AM_MAKEFLAGS) dvi \
323 && $(MAKE) $(AM_MAKEFLAGS) check \
324 && $(MAKE) $(AM_MAKEFLAGS) install \
325 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
326 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
327 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
328 distuninstallcheck \
329## Make sure the package has proper DESTDIR support (we could not test this
330## in the previous install/installcheck/uninstall test, because it's reasonable
331## for installcheck to fail in a DESTDIR install).
332## We make the `$dc_install_base' read-only because this is where files
333## with missing DESTDIR support are likely to be installed.
334 && chmod -R a-w "$$dc_install_base" \
335## The logic here is quite convoluted because we must clean $dc_destdir
336## whatever happens (it won't be erased by the next run of distcheck like
337## $(distdir) is).
338 && ({ \
339## Build the directory, so we can cd into it even if `make install'
340## didn't create it.
341 (cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
342 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
343 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
344 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
345 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
346 } || { rm -rf "$$dc_destdir"; exit 1; }) \
347 && rm -rf "$$dc_destdir" \
348 && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
349## Make sure to remove the dist file we created in the test build
350## directory.
351 && rm -f $(distdir).tar.gz \
352 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
353 $(am__remove_distdir)
354 @echo "$(distdir).tar.gz is ready for distribution" | \
355 sed 'h;s/./=/g;p;x;p;x'
356
357## Define distuninstallcheck_listfiles and distuninstallcheck separately
358## from distcheck, so that they can be overridden by the user.
359.PHONY: distuninstallcheck
360distuninstallcheck_listfiles = find . -type f -print
361distuninstallcheck:
362## We use -le 1 because the `dir' file (created by install-info)
363## might still exist after uninstall.
364 @cd $(distuninstallcheck_dir) \
365 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
366 || { echo "ERROR: files left after uninstall:" ; \
367 if test -n "$(DESTDIR)"; then \
368 echo " (check DESTDIR support)"; \
369 fi ; \
370 $(distuninstallcheck_listfiles) ; \
371 exit 1; } >&2
372
373## Define distcleancheck_listfiles and distcleancheck separately
374## from distcheck, so that they can be overridden by the user.
375.PHONY: distcleancheck
376distcleancheck_listfiles = find . -type f -print
377distcleancheck: distclean
378 @if test '$(srcdir)' = . ; then \
379 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
380 exit 1 ; \
381 fi
382 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
383 || { echo "ERROR: files left in build directory after distclean:" ; \
384 $(distcleancheck_listfiles) ; \
385 exit 1; } >&2
386endif %?TOPDIR_P%
Note: See TracBrowser for help on using the repository browser.