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