1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free
3 ## 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"`; \
69 ## For Gnits users, this is pretty handy. Look at 15 lines
70 ## in case some explanatory text is desirable.
74 @case `sed 15q $(srcdir)/NEWS` in \
75 *"$(VERSION)"*) : ;; \
77 echo "NEWS not updated; not releasing" 1>&2; \
83 ## `missing help2man' may have created some bogus man pages. Ensure they
84 ## are not distributed.
88 @list='$(MANS)'; if test -n "$$list"; then \
89 list=`for p in $$list; do \
90 if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
91 ## Note that we check existing man pages here only. If there are man pages
92 ## which are not distributed, and may be generated only conditionally, then
93 ## we should not error out because of them. This could be refined to take
94 ## into account only dist_*_MANS, but then we'd be missing out on those
95 ## the user distributes with EXTRA_DIST.
96 if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
97 if test -n "$$list" && \
98 grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
99 echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
100 grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
101 echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
102 echo " typically \`make maintainer-clean' will remove them" >&2; \
109 ## Only for the top dir.
112 $(am__remove_distdir)
113 test -d "$(distdir)" || mkdir "$(distdir)"
117 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
118 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
120 ## Yet another hack to support SUN make.
122 ## Let's assume `foo' appears in DISTFILES and is not a built file.
123 ## When building with VPATH=$(srcdir), SUN make and OSF1/Tru64 will
124 ## rewrite `foo' as `$(srcdir)/foo'. An attempt to install the file
126 ## cp $file $(distdir)/$file
127 ## will thus install $(srcdir)/foo as $(distdir)/$(srcdir)/foo
128 ## instead of $(distdir)/foo.
130 ## So let's strip this leading $(srcdir)/ when it exists. (As far we
131 ## know, only SUN make and OSF1/Tru64 make add it.) Searching whether
132 ## the file is to be found in the source or build directory will be
135 ## In case we are _not_ using SUN or OSF1/Tru64 make, how can we be sure
136 ## we are not stripping a legitimate filename that starts with the
137 ## same pattern as $(srcdir)?
138 ## Well, it can't happen without the Makefile author distributing
139 ## something out of the distribution (which is bad). As an example,
140 ## consider `EXTRA_DIST = ../bar'. This is an issue if $srcdir is `..',
141 ## however getting this value for srcdir is impossible: `EXTRA_DIST = ../bar'
142 ## implies we are in a subdirectory (so `../bar' is within the package),
143 ## hence `$srcdir' is something like `../../subdir'.
145 ## There is more to say about files which are above the current directory,
146 ## like `../bar' in the previous example. The OSF1/Tru64 make
147 ## implementation can simplify filenames resulting from a VPATH lookup.
148 ## For instance if `VPATH = ../../subdir' and `../bar' is found in that
149 ## VPATH directory, then occurrences of `../bar' will be replaced by
150 ## `../../bar' (instead of `../../subdir/../bar'). This obviously defeats
151 ## any attempt to strip a leading $srcdir. Presently we have no workaround
152 ## for this. We avoid this issue by writing `EXTRA_DIST = $(srcdir)/../bar'
153 ## instead of `EXTRA_DIST = ../bar'. This prefixing is needed only for files
154 ## above the current directory. Fortunately, apart from auxdir files which
155 ## can be located in .. or ../.., this situation hardly occurs in practice.
157 ## Also rewrite $(top_srcdir) (which sometimes appears in DISTFILES, and can
158 ## be absolute) by $(top_builddir) (which is always relative). $(srcdir) will
159 ## be prepended later.
160 list='$(DISTFILES)'; \
161 dist_files=`for file in $$list; do echo $$file; done | \
162 sed -e "s|^$$srcdirstrip/||;t" \
163 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
164 ## (The second `t' command clears the flag for the next round.)
166 ## Make the subdirectories for the files.
168 case $$dist_files in \
169 */*) $(MKDIR_P) `echo "$$dist_files" | \
170 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
175 for file in $$dist_files; do \
177 ## Always look for the file in the build directory first. That way
178 ## for something like yacc output we will correctly pick up the latest
179 ## version. Also check for directories in the build directory first,
180 ## so one can ship generated directories.
182 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
184 ## Use cp, not ln. There are situations in which "ln" can fail. For
185 ## instance a file to distribute could actually be a cross-filesystem
186 ## symlink -- this can easily happen if "gettextize" was run on the
189 if test -d $$d/$$file; then \
190 ## Don't mention $$file in the destination argument, since this fails if
191 ## the destination directory already exists. Also, use `-R' and not `-r'.
192 ## `-r' is almost always incorrect.
194 ## If a directory exists both in `.' and $(srcdir), then
195 ## We copy the files from $(srcdir) first and then install those from
196 ## `.'. This can help people who distribute directories made of
197 ## source files _and_ generated files. It is also important when the
198 ## directory exists only in $(srcdir), because some vendor Make (such
199 ## as Tru64) will magically create an empty directory in `.'
200 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
201 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
202 cp -pR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
204 cp -pR $$d/$$file "$(distdir)$$dir" || exit 1; \
206 ## Test for file existence because sometimes a file gets included in
207 ## DISTFILES twice. For example this happens when a single source
208 ## file is used in building more than one program.
209 test -f "$(distdir)/$$file" \
210 || cp -p $$d/$$file "$(distdir)/$$file" \
215 ## Test for directory existence here because previous automake
216 ## invocation might have created some directories. Note that we
217 ## explicitly set distdir for the subdir make; that lets us mix-n-match
218 ## many automake-using packages into one large package, and have "dist"
219 ## at the top level do the right thing. If we're in the topmost
220 ## directory, then we use `distdir' instead of `top_distdir'; this lets
221 ## us work correctly with an enclosing package.
224 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
225 if test "$$subdir" = .; then :; else \
226 test -d "$(distdir)/$$subdir" \
227 || $(MKDIR_P) "$(distdir)/$$subdir" \
229 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
231 new_distdir=$$reldir; \
232 dir1=$$subdir; dir2="$(top_distdir)"; \
234 new_top_distdir=$$reldir; \
235 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
236 echo " am__remove_distdir=: am__skip_length_check=: distdir)"; \
237 ($(am__cd) $$subdir && \
238 $(MAKE) $(AM_MAKEFLAGS) \
239 top_distdir="$$new_top_distdir" \
240 distdir="$$new_distdir" \
241 ## Disable am__remove_distdir so that sub-packages do not clear a
242 ## directory we have already cleared and might even have populated
243 ## (e.g. shared AUX dir in the sub-package).
244 am__remove_distdir=: \
245 ## Disable filename length check:
246 am__skip_length_check=: \
253 ## We might have to perform some last second updates, such as updating
255 ## We must explicitly set distdir and top_distdir for these sub-makes.
258 $(MAKE) $(AM_MAKEFLAGS) \
259 top_distdir="$(top_distdir)" distdir="$(distdir)" \
261 endif %?DIST-TARGETS%
263 ## This complex find command will try to avoid changing the modes of
264 ## links into the source tree, in case they're hard-linked. It will
265 ## also make directories writable by everybody, because some
266 ## brain-dead tar implementations change ownership and permissions of
267 ## a directory before extracting the files, thus becoming unable to
270 ## Ignore return result from chmod, because it might give an error
271 ## if we chmod a symlink.
273 ## Another nastiness: if the file is unreadable by us, we make it
274 ## readable regardless of the number of links to it. This only
275 ## happens in perverse cases.
277 ## We use $(install_sh) because that is a known-portable way to modify
278 ## the file in place in the source tree.
281 -find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
282 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
283 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
284 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
285 || chmod -R a+r "$(distdir)"
286 if %?FILENAME_FILTER%
287 @if test -z "$(am__skip_length_check)" && find "$(distdir)" -type f -print | \
288 grep '^%FILENAME_FILTER%' 1>&2; then \
289 echo 'error: the above filenames are too long' 1>&2; \
292 endif %?FILENAME_FILTER%
297 ## --------------------------------------- ##
298 ## Building various distribution flavors. ##
299 ## --------------------------------------- ##
301 ## Note that we don't use GNU tar's `-z' option. One reason (but not
302 ## the only reason) is that some versions of tar (e.g., OSF1)
303 ## interpret `-z' differently.
305 ## The -o option of GNU tar used to exclude empty directories. This
306 ## behavior was fixed in tar 1.12 (released on 1997-04-25). But older
307 ## versions of tar are still used (for instance NetBSD 1.6.1 ships
308 ## with tar 1.11.2). We do not do anything specific w.r.t. this
309 ## incompatibility since packages where empty directories need to be
310 ## present in the archive are really unusual.
314 ?GZIP?DIST_ARCHIVES += $(distdir).tar.gz
318 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
319 $(am__remove_distdir)
321 ?BZIP2?DIST_ARCHIVES += $(distdir).tar.bz2
324 tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
325 $(am__remove_distdir)
327 ?LZMA?DIST_ARCHIVES += $(distdir).tar.lzma
330 tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
331 $(am__remove_distdir)
333 ?XZ?DIST_ARCHIVES += $(distdir).tar.xz
336 tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
337 $(am__remove_distdir)
339 ?COMPRESS?DIST_ARCHIVES += $(distdir).tar.Z
342 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
343 $(am__remove_distdir)
345 ?SHAR?DIST_ARCHIVES += $(distdir).shar.gz
348 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
349 $(am__remove_distdir)
351 ?ZIP?DIST_ARCHIVES += $(distdir).zip
354 -rm -f $(distdir).zip
355 zip -rq $(distdir).zip $(distdir)
356 $(am__remove_distdir)
362 ## ------------------------------------------------- ##
363 ## Building all the requested distribution flavors. ##
364 ## ------------------------------------------------- ##
366 ## Currently we cannot use if/endif inside a rule. The file_contents
367 ## parser needs work.
371 .PHONY: dist dist-all
372 dist dist-all: distdir
373 ?GZIP? tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
374 ?BZIP2? tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
375 ?LZMA? tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
376 ?XZ? tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
377 ?COMPRESS? tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
378 ?SHAR? shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
379 ?ZIP? -rm -f $(distdir).zip
380 ?ZIP? zip -rq $(distdir).zip $(distdir)
381 $(am__remove_distdir)
386 ## ------------------------- ##
387 ## Checking a distribution. ##
388 ## ------------------------- ##
392 # This target untars the dist file and tries a VPATH configuration. Then
393 # it guarantees that the distribution is self-contained by making another
397 case '$(DIST_ARCHIVES)' in \
399 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
401 bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
403 unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
405 xz -dc $(distdir).tar.xz | $(am__untar) ;;\
407 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
409 GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
411 unzip $(distdir).zip ;;\
413 ## Make the new source tree read-only. Distributions ought to work in
414 ## this case. However, make the top-level directory writable so we
415 ## can make our new subdirs.
416 chmod -R a-w $(distdir); chmod a+w $(distdir)
417 mkdir $(distdir)/_build
418 mkdir $(distdir)/_inst
419 ## Undo the write access.
421 ## Compute the absolute path of `_inst'. Strip any leading DOS drive
422 ## to allow DESTDIR installations. Otherwise "$(DESTDIR)$(prefix)" would
423 ## expand to "c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst".
424 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
425 ## We will attemp a DESTDIR install in $dc_destdir. We don't
426 ## create this directory under $dc_install_base, because it would
427 ## create very long directory names.
428 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
429 ?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
430 && $(am__cd) $(distdir)/_build \
431 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
432 ?GETTEXT? --with-included-gettext \
433 ## Additional flags for configure. Keep this last in the configure
434 ## invocation so the user can override previous options.
435 $(DISTCHECK_CONFIGURE_FLAGS) \
436 && $(MAKE) $(AM_MAKEFLAGS) \
437 && $(MAKE) $(AM_MAKEFLAGS) dvi \
438 && $(MAKE) $(AM_MAKEFLAGS) check \
439 && $(MAKE) $(AM_MAKEFLAGS) install \
440 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
441 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
442 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
444 ## Make sure the package has proper DESTDIR support (we could not test this
445 ## in the previous install/installcheck/uninstall test, because it's reasonable
446 ## for installcheck to fail in a DESTDIR install).
447 ## We make the `$dc_install_base' read-only because this is where files
448 ## with missing DESTDIR support are likely to be installed.
449 && chmod -R a-w "$$dc_install_base" \
450 ## The logic here is quite convoluted because we must clean $dc_destdir
451 ## whatever happens (it won't be erased by the next run of distcheck like
454 ## Build the directory, so we can cd into it even if `make install'
455 ## didn't create it. Use mkdir, not $(MKDIR_P) because we want to
456 ## fail if the directory already exists (PR/413).
457 (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
458 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
459 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
460 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
461 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
462 } || { rm -rf "$$dc_destdir"; exit 1; }) \
463 && rm -rf "$$dc_destdir" \
464 && $(MAKE) $(AM_MAKEFLAGS) dist \
465 ## Make sure to remove the dists we created in the test build directory.
466 && rm -rf $(DIST_ARCHIVES) \
467 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
468 $(am__remove_distdir)
469 @(echo "$(distdir) archives ready for distribution: "; \
470 list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
471 sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
473 ## Define distuninstallcheck_listfiles and distuninstallcheck separately
474 ## from distcheck, so that they can be overridden by the user.
475 .PHONY: distuninstallcheck
476 distuninstallcheck_listfiles = find . -type f -print
478 ## We use -le 1 because the `dir' file (created by install-info)
479 ## might still exist after uninstall.
480 @$(am__cd) '$(distuninstallcheck_dir)' \
481 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
482 || { echo "ERROR: files left after uninstall:" ; \
483 if test -n "$(DESTDIR)"; then \
484 echo " (check DESTDIR support)"; \
486 $(distuninstallcheck_listfiles) ; \
489 ## Define distcleancheck_listfiles and distcleancheck separately
490 ## from distcheck, so that they can be overridden by the user.
491 .PHONY: distcleancheck
492 distcleancheck_listfiles = find . -type f -print
493 distcleancheck: distclean
494 @if test '$(srcdir)' = . ; then \
495 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
498 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
499 || { echo "ERROR: files left in build directory after distclean:" ; \
500 $(distcleancheck_listfiles) ; \