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