1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 ## 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 3, 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)"; }; }
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. It will
283 ## also make directories writable by everybody, because some
284 ## brain-dead tar implementations change ownership and permissions of
285 ## a directory before extracting the files, thus becoming unable to
288 ## Ignore return result from chmod, because it might give an error
289 ## if we chmod a symlink.
291 ## Another nastiness: if the file is unreadable by us, we make it
292 ## readable regardless of the number of links to it. This only
293 ## happens in perverse cases.
295 ## We use $(install_sh) because that is a known-portable way to modify
296 ## the file in place in the source tree.
298 ## If we are being invoked recursively, then there is no need to walk
299 ## the whole subtree again. This is a complexity reduction for a deep
300 ## hierarchy of subpackages.
303 -test -n "$(am__skip_mode_fix)" \
304 || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
305 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
306 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
307 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
308 || chmod -R a+r "$(distdir)"
309 if %?FILENAME_FILTER%
310 @if test -z "$(am__skip_length_check)" && find "$(distdir)" -type f -print | \
311 grep '^%FILENAME_FILTER%' 1>&2; then \
312 echo 'error: the above filenames are too long' 1>&2; \
315 endif %?FILENAME_FILTER%
320 ## --------------------------------------- ##
321 ## Building various distribution flavors. ##
322 ## --------------------------------------- ##
324 ## Note that we don't use GNU tar's `-z' option. One reason (but not
325 ## the only reason) is that some versions of tar (e.g., OSF1)
326 ## interpret `-z' differently.
328 ## The -o option of GNU tar used to exclude empty directories. This
329 ## behavior was fixed in tar 1.12 (released on 1997-04-25). But older
330 ## versions of tar are still used (for instance NetBSD 1.6.1 ships
331 ## with tar 1.11.2). We do not do anything specific w.r.t. this
332 ## incompatibility since packages where empty directories need to be
333 ## present in the archive are really unusual.
337 ?GZIP?DIST_ARCHIVES += $(distdir).tar.gz
341 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
342 $(am__remove_distdir)
344 ?BZIP2?DIST_ARCHIVES += $(distdir).tar.bz2
347 tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
348 $(am__remove_distdir)
350 ?LZMA?DIST_ARCHIVES += $(distdir).tar.lzma
353 tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
354 $(am__remove_distdir)
356 ?XZ?DIST_ARCHIVES += $(distdir).tar.xz
359 tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
360 $(am__remove_distdir)
362 ?COMPRESS?DIST_ARCHIVES += $(distdir).tar.Z
365 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
366 $(am__remove_distdir)
368 ?SHAR?DIST_ARCHIVES += $(distdir).shar.gz
371 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
372 $(am__remove_distdir)
374 ?ZIP?DIST_ARCHIVES += $(distdir).zip
377 -rm -f $(distdir).zip
378 zip -rq $(distdir).zip $(distdir)
379 $(am__remove_distdir)
385 ## ------------------------------------------------- ##
386 ## Building all the requested distribution flavors. ##
387 ## ------------------------------------------------- ##
389 ## Currently we cannot use if/endif inside a rule. The file_contents
390 ## parser needs work.
394 .PHONY: dist dist-all
396 AM_RECURSIVE_TARGETS += dist dist-all
399 dist dist-all: distdir
400 ?GZIP? tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
401 ?BZIP2? tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
402 ?LZMA? tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
403 ?XZ? tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
404 ?COMPRESS? tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
405 ?SHAR? shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
406 ?ZIP? -rm -f $(distdir).zip
407 ?ZIP? zip -rq $(distdir).zip $(distdir)
408 $(am__remove_distdir)
413 ## ------------------------- ##
414 ## Checking a distribution. ##
415 ## ------------------------- ##
420 AM_RECURSIVE_TARGETS += distcheck
423 # This target untars the dist file and tries a VPATH configuration. Then
424 # it guarantees that the distribution is self-contained by making another
428 case '$(DIST_ARCHIVES)' in \
430 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
432 bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
434 unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
436 xz -dc $(distdir).tar.xz | $(am__untar) ;;\
438 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
440 GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
442 unzip $(distdir).zip ;;\
444 ## Make the new source tree read-only. Distributions ought to work in
445 ## this case. However, make the top-level directory writable so we
446 ## can make our new subdirs.
447 chmod -R a-w $(distdir); chmod a+w $(distdir)
448 mkdir $(distdir)/_build
449 mkdir $(distdir)/_inst
450 ## Undo the write access.
452 ## With GNU make, the following command will be executed even with `make -n',
453 ## due to the presence of `$(MAKE)'. That is normally all well (and `$(MAKE)'
454 ## is necessary for things like parallel distcheck), but here we don't want
455 ## execution. To avoid MAKEFLAGS parsing hassles, use a witness file that a
456 ## non-`-n' run would have just created.
457 test -d $(distdir)/_build || exit 0; \
458 ## Compute the absolute path of `_inst'. Strip any leading DOS drive
459 ## to allow DESTDIR installations. Otherwise "$(DESTDIR)$(prefix)" would
460 ## expand to "c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst".
461 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
462 ## We will attempt a DESTDIR install in $dc_destdir. We don't
463 ## create this directory under $dc_install_base, because it would
464 ## create very long directory names.
465 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
466 ?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
467 ## Parallel BSD make may not start a new shell for each command in a recipe,
468 ## so be sure to `cd' back to the original directory after this.
470 && $(am__cd) $(distdir)/_build \
471 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
472 ?GETTEXT? --with-included-gettext \
473 ## Additional flags for configure. Keep this last in the configure
474 ## invocation so the user can override previous options.
475 $(DISTCHECK_CONFIGURE_FLAGS) \
476 && $(MAKE) $(AM_MAKEFLAGS) \
477 && $(MAKE) $(AM_MAKEFLAGS) dvi \
478 && $(MAKE) $(AM_MAKEFLAGS) check \
479 && $(MAKE) $(AM_MAKEFLAGS) install \
480 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
481 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
482 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
484 ## Make sure the package has proper DESTDIR support (we could not test this
485 ## in the previous install/installcheck/uninstall test, because it's reasonable
486 ## for installcheck to fail in a DESTDIR install).
487 ## We make the `$dc_install_base' read-only because this is where files
488 ## with missing DESTDIR support are likely to be installed.
489 && chmod -R a-w "$$dc_install_base" \
490 ## The logic here is quite convoluted because we must clean $dc_destdir
491 ## whatever happens (it won't be erased by the next run of distcheck like
494 ## Build the directory, so we can cd into it even if `make install'
495 ## didn't create it. Use mkdir, not $(MKDIR_P) because we want to
496 ## fail if the directory already exists (PR/413).
497 (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
498 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
499 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
500 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
501 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
502 } || { rm -rf "$$dc_destdir"; exit 1; }) \
503 && rm -rf "$$dc_destdir" \
504 && $(MAKE) $(AM_MAKEFLAGS) dist \
505 ## Make sure to remove the dists we created in the test build directory.
506 && rm -rf $(DIST_ARCHIVES) \
507 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
508 ## Cater to parallel BSD make (see above).
511 $(am__remove_distdir)
512 @(echo "$(distdir) archives ready for distribution: "; \
513 list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
514 sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
516 ## Define distuninstallcheck_listfiles and distuninstallcheck separately
517 ## from distcheck, so that they can be overridden by the user.
518 .PHONY: distuninstallcheck
519 distuninstallcheck_listfiles = find . -type f -print
521 ## We use -le 1 because the `dir' file (created by install-info)
522 ## might still exist after uninstall.
523 @$(am__cd) '$(distuninstallcheck_dir)' \
524 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
525 || { echo "ERROR: files left after uninstall:" ; \
526 if test -n "$(DESTDIR)"; then \
527 echo " (check DESTDIR support)"; \
529 $(distuninstallcheck_listfiles) ; \
532 ## Define distcleancheck_listfiles and distcleancheck separately
533 ## from distcheck, so that they can be overridden by the user.
534 .PHONY: distcleancheck
535 distcleancheck_listfiles = find . -type f -print
536 distcleancheck: distclean
537 @if test '$(srcdir)' = . ; then \
538 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
541 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
542 || { echo "ERROR: files left in build directory after distclean:" ; \
543 $(distcleancheck_listfiles) ; \