1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
3 ## 2010 Free Software Foundation, Inc.
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2, or (at your option)
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ## DIST_COMMON comes first so that README can be the very first file.
19 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
22 distdir = $(PACKAGE)-$(VERSION)
23 top_distdir = $(distdir)
25 am__remove_distdir = \
26 { test ! -d "$(distdir)" \
27 || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
28 && rm -fr "$(distdir)"; }; }
29 am__post_remove_distdir = $(am__remove_distdir)
33 ## computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
35 ## - DIR1 relative pathname, relative to the current directory
36 ## - DIR2 relative pathname, relative to the current directory
38 ## - reldir relative pathname of DIR2, relative to DIR1
41 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
42 sed_rest='s,^[^/]*/*,,'; \
43 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
44 sed_butlast='s,/*[^/]*$$,,'; \
45 while test -n "$$dir1"; do \
46 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
47 if test "$$first" != "."; then \
48 if test "$$first" = ".."; then \
49 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
50 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
52 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
53 if test "$$first2" = "$$first"; then \
54 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
58 dir0="$$dir0"/"$$first"; \
61 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
68 AM_RECURSIVE_TARGETS += distdir
73 ## For Gnits users, this is pretty handy. Look at 15 lines
74 ## in case some explanatory text is desirable.
78 @case `sed 15q $(srcdir)/NEWS` in \
79 *"$(VERSION)"*) : ;; \
81 echo "NEWS not updated; not releasing" 1>&2; \
87 ## `missing help2man' may have created some bogus man pages. Ensure they
88 ## are not distributed.
92 @list='$(MANS)'; if test -n "$$list"; then \
93 list=`for p in $$list; do \
94 if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
95 ## Note that we check existing man pages here only. If there are man pages
96 ## which are not distributed, and may be generated only conditionally, then
97 ## we should not error out because of them. This could be refined to take
98 ## into account only dist_*_MANS, but then we'd be missing out on those
99 ## the user distributes with EXTRA_DIST.
100 if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
101 if test -n "$$list" && \
102 grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
103 echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
104 grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
105 echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
106 echo " typically \`make maintainer-clean' will remove them" >&2; \
113 ## Only for the top dir.
116 $(am__remove_distdir)
117 test -d "$(distdir)" || mkdir "$(distdir)"
121 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
122 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
124 ## Yet another hack to support SUN make.
126 ## Let's assume `foo' appears in DISTFILES and is not a built file.
127 ## When building with VPATH=$(srcdir), SUN make and OSF1/Tru64 will
128 ## rewrite `foo' as `$(srcdir)/foo'. An attempt to install the file
130 ## cp $file $(distdir)/$file
131 ## will thus install $(srcdir)/foo as $(distdir)/$(srcdir)/foo
132 ## instead of $(distdir)/foo.
134 ## So let's strip this leading $(srcdir)/ when it exists. (As far we
135 ## know, only SUN make and OSF1/Tru64 make add it.) Searching whether
136 ## the file is to be found in the source or build directory will be
139 ## In case we are _not_ using SUN or OSF1/Tru64 make, how can we be sure
140 ## we are not stripping a legitimate filename that starts with the
141 ## same pattern as $(srcdir)?
142 ## Well, it can't happen without the Makefile author distributing
143 ## something out of the distribution (which is bad). As an example,
144 ## consider `EXTRA_DIST = ../bar'. This is an issue if $srcdir is `..',
145 ## however getting this value for srcdir is impossible: `EXTRA_DIST = ../bar'
146 ## implies we are in a subdirectory (so `../bar' is within the package),
147 ## hence `$srcdir' is something like `../../subdir'.
149 ## There is more to say about files which are above the current directory,
150 ## like `../bar' in the previous example. The OSF1/Tru64 make
151 ## implementation can simplify filenames resulting from a VPATH lookup.
152 ## For instance if `VPATH = ../../subdir' and `../bar' is found in that
153 ## VPATH directory, then occurrences of `../bar' will be replaced by
154 ## `../../bar' (instead of `../../subdir/../bar'). This obviously defeats
155 ## any attempt to strip a leading $srcdir. Presently we have no workaround
156 ## for this. We avoid this issue by writing `EXTRA_DIST = $(srcdir)/../bar'
157 ## instead of `EXTRA_DIST = ../bar'. This prefixing is needed only for files
158 ## above the current directory. Fortunately, apart from auxdir files which
159 ## can be located in .. or ../.., this situation hardly occurs in practice.
161 ## Also rewrite $(top_srcdir) (which sometimes appears in DISTFILES, and can
162 ## be absolute) by $(top_builddir) (which is always relative). $(srcdir) will
163 ## be prepended later.
164 list='$(DISTFILES)'; \
165 dist_files=`for file in $$list; do echo $$file; done | \
166 sed -e "s|^$$srcdirstrip/||;t" \
167 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
168 ## (The second `t' command clears the flag for the next round.)
170 ## Make the subdirectories for the files.
172 case $$dist_files in \
173 */*) $(MKDIR_P) `echo "$$dist_files" | \
174 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
179 for file in $$dist_files; do \
181 ## Always look for the file in the build directory first. That way
182 ## for something like yacc output we will correctly pick up the latest
183 ## version. Also check for directories in the build directory first,
184 ## so one can ship generated directories.
186 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
188 ## Use cp, not ln. There are situations in which "ln" can fail. For
189 ## instance a file to distribute could actually be a cross-filesystem
190 ## symlink -- this can easily happen if "gettextize" was run on the
193 if test -d $$d/$$file; then \
194 ## Don't mention $$file in the destination argument, since this fails if
195 ## the destination directory already exists. Also, use `-R' and not `-r'.
196 ## `-r' is almost always incorrect.
198 ## If a directory exists both in `.' and $(srcdir), then
199 ## We copy the files from $(srcdir) first and then install those from
200 ## `.'. This can help people who distribute directories made of
201 ## source files _and_ generated files. It is also important when the
202 ## directory exists only in $(srcdir), because some vendor Make (such
203 ## as Tru64) will magically create an empty directory in `.'
204 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
205 ## If the destination directory already exists, it may contain read-only
206 ## files, e.g., during `make distcheck'.
207 if test -d "$(distdir)/$$file"; then \
208 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
210 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
211 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
212 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
214 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
216 ## Test for file existence because sometimes a file gets included in
217 ## DISTFILES twice. For example this happens when a single source
218 ## file is used in building more than one program.
219 test -f "$(distdir)/$$file" \
220 || cp -p $$d/$$file "$(distdir)/$$file" \
225 ## Test for directory existence here because previous automake
226 ## invocation might have created some directories. Note that we
227 ## explicitly set distdir for the subdir make; that lets us mix-n-match
228 ## many automake-using packages into one large package, and have "dist"
229 ## at the top level do the right thing. If we're in the topmost
230 ## directory, then we use `distdir' instead of `top_distdir'; this lets
231 ## us work correctly with an enclosing package.
233 ## Split the loop for the directory creation and the one for recursion,
234 ## so that with GNU make -n, only the latter is executed.
236 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
237 if test "$$subdir" = .; then :; else \
238 test -d "$(distdir)/$$subdir" \
239 || $(MKDIR_P) "$(distdir)/$$subdir" \
243 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
244 if test "$$subdir" = .; then :; else \
245 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
247 new_distdir=$$reldir; \
248 dir1=$$subdir; dir2="$(top_distdir)"; \
250 new_top_distdir=$$reldir; \
251 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
252 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
253 ($(am__cd) $$subdir && \
254 $(MAKE) $(AM_MAKEFLAGS) \
255 top_distdir="$$new_top_distdir" \
256 distdir="$$new_distdir" \
257 ## Disable am__remove_distdir so that sub-packages do not clear a
258 ## directory we have already cleared and might even have populated
259 ## (e.g. shared AUX dir in the sub-package).
260 am__remove_distdir=: \
261 ## Disable filename length check:
262 am__skip_length_check=: \
263 ## No need to fix modes more than once:
264 am__skip_mode_fix=: \
271 ## We might have to perform some last second updates, such as updating
273 ## We must explicitly set distdir and top_distdir for these sub-makes.
276 $(MAKE) $(AM_MAKEFLAGS) \
277 top_distdir="$(top_distdir)" distdir="$(distdir)" \
279 endif %?DIST-TARGETS%
281 ## This complex find command will try to avoid changing the modes of
282 ## links into the source tree, in case they're hard-linked.
284 ## Ignore return result from chmod, because it might give an error
285 ## if we chmod a symlink.
287 ## Another nastiness: if the file is unreadable by us, we make it
288 ## readable regardless of the number of links to it. This only
289 ## happens in perverse cases.
291 ## We use $(install_sh) because that is a known-portable way to modify
292 ## the file in place in the source tree.
294 ## If we are being invoked recursively, then there is no need to walk
295 ## the whole subtree again. This is a complexity reduction for a deep
296 ## hierarchy of subpackages.
299 -test -n "$(am__skip_mode_fix)" \
300 || find "$(distdir)" -type d ! -perm -755 \
301 -exec chmod u+rwx,go+rx {} \; -o \
302 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
303 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
304 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
305 || chmod -R a+r "$(distdir)"
306 if %?FILENAME_FILTER%
307 @if test -z "$(am__skip_length_check)" && find "$(distdir)" -type f -print | \
308 grep '^%FILENAME_FILTER%' 1>&2; then \
309 echo 'error: the above filenames are too long' 1>&2; \
312 endif %?FILENAME_FILTER%
317 ## --------------------------------------- ##
318 ## Building various distribution flavors. ##
319 ## --------------------------------------- ##
321 ## Note that we don't use GNU tar's `-z' option. One reason (but not
322 ## the only reason) is that some versions of tar (e.g., OSF1)
323 ## interpret `-z' differently.
325 ## The -o option of GNU tar used to exclude empty directories. This
326 ## behavior was fixed in tar 1.12 (released on 1997-04-25). But older
327 ## versions of tar are still used (for instance NetBSD 1.6.1 ships
328 ## with tar 1.11.2). We do not do anything specific w.r.t. this
329 ## incompatibility since packages where empty directories need to be
330 ## present in the archive are really unusual.
332 ## We order DIST_TARGETS by expected duration of the compressors,
333 ## slowest first, for better parallelism in `make dist'. Do not
334 ## reorder DIST_ARCHIVES, users may expect gzip to be first.
338 ?GZIP?DIST_ARCHIVES += $(distdir).tar.gz
342 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
343 $(am__post_remove_distdir)
345 ?BZIP2?DIST_ARCHIVES += $(distdir).tar.bz2
348 tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
349 $(am__post_remove_distdir)
351 ?LZIP?DIST_ARCHIVES += $(distdir).tar.lz
354 tardir=$(distdir) && $(am__tar) | lzip -9 -c >$(distdir).tar.lz
355 $(am__post_remove_distdir)
357 ?LZMA?DIST_ARCHIVES += $(distdir).tar.lzma
360 tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
361 $(am__post_remove_distdir)
363 ?XZ?DIST_ARCHIVES += $(distdir).tar.xz
366 tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--9} xz -c >$(distdir).tar.xz
367 $(am__post_remove_distdir)
369 ?COMPRESS?DIST_ARCHIVES += $(distdir).tar.Z
372 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
373 $(am__post_remove_distdir)
375 ?SHAR?DIST_ARCHIVES += $(distdir).shar.gz
378 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
379 $(am__post_remove_distdir)
381 ?ZIP?DIST_ARCHIVES += $(distdir).zip
384 -rm -f $(distdir).zip
385 zip -rq $(distdir).zip $(distdir)
386 $(am__post_remove_distdir)
388 ?LZMA?DIST_TARGETS += dist-lzma
389 ?LZIP?DIST_TARGETS += dist-lzip
390 ?XZ?DIST_TARGETS += dist-xz
391 ?SHAR?DIST_TARGETS += dist-shar
392 ?BZIP2?DIST_TARGETS += dist-bzip2
393 ?GZIP?DIST_TARGETS += dist-gzip
394 ?ZIP?DIST_TARGETS += dist-zip
395 ?COMPRESS?DIST_TARGETS += dist-tarZ
401 ## ------------------------------------------------- ##
402 ## Building all the requested distribution flavors. ##
403 ## ------------------------------------------------- ##
405 ## Currently we cannot use if/endif inside a rule. The file_contents
406 ## parser needs work.
410 .PHONY: dist dist-all
412 AM_RECURSIVE_TARGETS += dist dist-all
416 $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
417 $(am__post_remove_distdir)
422 ## ------------------------- ##
423 ## Checking a distribution. ##
424 ## ------------------------- ##
429 AM_RECURSIVE_TARGETS += distcheck
432 # This target untars the dist file and tries a VPATH configuration. Then
433 # it guarantees that the distribution is self-contained by making another
437 case '$(DIST_ARCHIVES)' in \
439 GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
441 bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
443 lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
445 lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
447 xz -dc $(distdir).tar.xz | $(am__untar) ;;\
449 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
451 GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
453 unzip $(distdir).zip ;;\
455 ## Make the new source tree read-only. Distributions ought to work in
456 ## this case. However, make the top-level directory writable so we
457 ## can make our new subdirs.
458 chmod -R a-w $(distdir); chmod a+w $(distdir)
459 mkdir $(distdir)/_build
460 mkdir $(distdir)/_inst
461 ## Undo the write access.
463 ## With GNU make, the following command will be executed even with `make -n',
464 ## due to the presence of `$(MAKE)'. That is normally all well (and `$(MAKE)'
465 ## is necessary for things like parallel distcheck), but here we don't want
466 ## execution. To avoid MAKEFLAGS parsing hassles, use a witness file that a
467 ## non-`-n' run would have just created.
468 test -d $(distdir)/_build || exit 0; \
469 ## Compute the absolute path of `_inst'. Strip any leading DOS drive
470 ## to allow DESTDIR installations. Otherwise "$(DESTDIR)$(prefix)" would
471 ## expand to "c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst".
472 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
473 ## We will attempt a DESTDIR install in $dc_destdir. We don't
474 ## create this directory under $dc_install_base, because it would
475 ## create very long directory names.
476 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
477 ?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
478 ## Parallel BSD make may not start a new shell for each command in a recipe,
479 ## so be sure to `cd' back to the original directory after this.
481 && $(am__cd) $(distdir)/_build \
482 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
483 ?GETTEXT? --with-included-gettext \
484 ## Additional flags for configure. Keep this last in the configure
485 ## invocation so the user can override previous options.
486 $(DISTCHECK_CONFIGURE_FLAGS) \
487 && $(MAKE) $(AM_MAKEFLAGS) \
488 && $(MAKE) $(AM_MAKEFLAGS) dvi \
489 && $(MAKE) $(AM_MAKEFLAGS) check \
490 && $(MAKE) $(AM_MAKEFLAGS) install \
491 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
492 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
493 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
495 ## Make sure the package has proper DESTDIR support (we could not test this
496 ## in the previous install/installcheck/uninstall test, because it's reasonable
497 ## for installcheck to fail in a DESTDIR install).
498 ## We make the `$dc_install_base' read-only because this is where files
499 ## with missing DESTDIR support are likely to be installed.
500 && chmod -R a-w "$$dc_install_base" \
501 ## The logic here is quite convoluted because we must clean $dc_destdir
502 ## whatever happens (it won't be erased by the next run of distcheck like
505 ## Build the directory, so we can cd into it even if `make install'
506 ## didn't create it. Use mkdir, not $(MKDIR_P) because we want to
507 ## fail if the directory already exists (PR/413).
508 (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
509 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
510 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
511 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
512 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
513 } || { rm -rf "$$dc_destdir"; exit 1; }) \
514 && rm -rf "$$dc_destdir" \
515 && $(MAKE) $(AM_MAKEFLAGS) dist \
516 ## Make sure to remove the dists we created in the test build directory.
517 && rm -rf $(DIST_ARCHIVES) \
518 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
519 ## Cater to parallel BSD make (see above).
522 $(am__post_remove_distdir)
523 @(echo "$(distdir) archives ready for distribution: "; \
524 list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
525 sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
527 ## Define distuninstallcheck_listfiles and distuninstallcheck separately
528 ## from distcheck, so that they can be overridden by the user.
529 .PHONY: distuninstallcheck
530 distuninstallcheck_listfiles = find . -type f -print
532 ## We use -le 1 because the `dir' file (created by install-info)
533 ## might still exist after uninstall.
534 @$(am__cd) '$(distuninstallcheck_dir)' \
535 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
536 || { echo "ERROR: files left after uninstall:" ; \
537 if test -n "$(DESTDIR)"; then \
538 echo " (check DESTDIR support)"; \
540 $(distuninstallcheck_listfiles) ; \
543 ## Define distcleancheck_listfiles and distcleancheck separately
544 ## from distcheck, so that they can be overridden by the user.
545 .PHONY: distcleancheck
546 distcleancheck_listfiles = find . -type f -print
547 distcleancheck: distclean
548 @if test '$(srcdir)' = . ; then \
549 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
552 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
553 || { echo "ERROR: files left in build directory after distclean:" ; \
554 $(distcleancheck_listfiles) ; \