1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright 2001 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
21 ## DIST_COMMON comes first so that README can be the very first file.
22 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
24 top_distdir = %TOP_DISTDIR%
25 ?DISTDIR?distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
29 ## For Gnits users, this is pretty handy. Look at 15 lines
30 ## in case some explanatory text is desirable.
34 @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" >/dev/null; \
36 echo "NEWS not updated; not releasing" 1>&2; \
42 ## Only for the top dir.
45 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
50 ?DISTDIRS? $(mkinstalldirs) %DISTDIRS%
53 @for file in $(DISTFILES); do \
55 ## In loop, test for file existence because sometimes a file gets
56 ## included in DISTFILES twice. For example this happens when a single
57 ## source file is used in building more than one program. Also, there
58 ## are situations in which "ln" can fail. For instance a file to
59 ## distribute could actually be a cross-filesystem symlink -- this can
60 ## easily happen if "gettextize" was run on the distribution.
62 ?CYGNUS? if test -f $$file; then d=.; else d=$(srcdir); fi; \
63 ?!CYGNUS? d=$(srcdir); \
64 ## Make the subdirectory for the file. This is going to make `dist'
65 ## really crawl, but it seems like the only way to do it, given that
66 ## files in subdirectories can be specified for `dist' conditionally.
67 dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
68 if test "$$dir" != "$$file" && test "$$dir" != "."; then \
69 $(mkinstalldirs) "$(distdir)/$$dir"; \
72 if test -d $$d/$$file; then \
73 ## Don't mention $$file in destination argument, since this fails if
74 ## destination directory already exists. Also, use `-R' and not `-r'.
75 ## `-r' is almost always incorrect.
76 cp -pR $$d/$$file $(distdir) \
79 test -f $(distdir)/$$file \
80 || cp -p $$d/$$file $(distdir)/$$file \
85 ## Test for directory existence here because previous automake
86 ## invocation might have created some directories. Note that we
87 ## explicitly set distdir for the subdir make; that lets us mix-n-match
88 ## many automake-using packages into one large package, and have "dist"
89 ## at the top level do the right thing. If we're in the topmost
90 ## directory, then we use `distdir' instead of `top_distdir'; this lets
91 ## us work correctly with an enclosing package.
94 for subdir in $(%DIST_SUBDIR_NAME%); do \
95 if test "$$subdir" = .; then :; else \
96 test -d $(distdir)/$$subdir \
97 || mkdir $(distdir)/$$subdir \
100 $(MAKE) $(AM_MAKEFLAGS) \
101 top_distdir="$(top_distdir)" \
102 distdir=../$(distdir)/$$subdir \
109 ## We might have to perform some last second updates, such as updating
111 ## We must explicitly set distdir and top_distdir for these sub-makes.
114 $(MAKE) $(AM_MAKEFLAGS) \
115 top_distdir="${top_distdir}" distdir="$(distdir)" \
117 endif %?DIST-TARGETS%
119 ## This complex find command will try to avoid changing the modes of
120 ## links into the source tree, in case they're hard-linked. It will
121 ## also make directories writable by everybody, because some
122 ## brain-dead tar implementations change ownership and permissions of
123 ## a directory before extracting the files, thus becoming unable to
126 ## Ignore return result from chmod, because it might give an error
127 ## if we chmod a symlink.
129 ## Another nastiness: if the file is unreadable by us, we make it
130 ## readable regardless of the number of links to it. This only
131 ## happens in perverse cases.
133 ## We use $(install_sh) because that is a known-portable way to modify
134 ## the file in place in the source tree.
137 -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
138 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
139 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
140 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
141 || chmod -R a+r $(distdir)
147 ## --------------------------------------- ##
148 ## Building various distribution flavors. ##
149 ## --------------------------------------- ##
151 ## Note that we don't use GNU tar's `-z' option. One reason (but not
152 ## the only reason) is that some versions of tar (e.g., OSF1)
153 ## interpret `-z' differently.
160 $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
161 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
166 $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
167 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
174 $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
175 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
182 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
183 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
190 -rm -f $(distdir).zip
191 zip -rq $(distdir).zip $(distdir)
192 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
199 ## ------------------------------------------------- ##
200 ## Building all the requested distribution flavors. ##
201 ## ------------------------------------------------- ##
203 ## Currently we cannot use if/endif inside a rule. The file_contents
204 ## parser needs work.
210 $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
211 ?BZIP2? $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
212 ?COMPRESS? $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
213 ?SHAR? shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
214 ?ZIP? -rm -f $(distdir).zip
215 ?ZIP? zip -rq $(distdir).zip $(distdir)
216 -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir)
221 ## ------------------------- ##
222 ## Checking a distribution. ##
223 ## ------------------------- ##
227 # This target untars the dist file and tries a VPATH configuration. Then
228 # it guarantees that the distribution is self-contained by making another
232 ## Make sure we can remove distdir before trying to remove it.
233 -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
234 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
235 ## Make the new source tree read-only. Distributions ought to work in
236 ## this case. However, make the top-level directory writable so we
237 ## can make our new subdirs.
238 chmod -R a-w $(distdir); chmod a+w $(distdir)
239 mkdir $(distdir)/=build
240 mkdir $(distdir)/=inst
241 ## Undo the write access.
243 dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \
244 ?DISTCHECK-HOOK? && $(MAKE) $(AM_MAKEFLAGS) distcheck-hook \
245 && cd $(distdir)/=build \
246 && ../configure --srcdir=.. --prefix=$$dc_install_base \
247 ?GETTEXT? --with-included-gettext \
248 && $(MAKE) $(AM_MAKEFLAGS) \
249 && $(MAKE) $(AM_MAKEFLAGS) dvi \
250 && $(MAKE) $(AM_MAKEFLAGS) check \
251 && $(MAKE) $(AM_MAKEFLAGS) install \
252 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
253 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
254 ## We use -le 1 because the `dir' file might still exist after uninstall.
255 && test `find $$dc_install_base -type f -print | wc -l` -le 1 \
256 && $(MAKE) $(AM_MAKEFLAGS) dist \
257 && $(MAKE) $(AM_MAKEFLAGS) distclean \
258 ## Make sure to remove the dist file we created in the test build
260 && rm -f $(distdir).tar.gz \
261 && (test `find . -type f -print | wc -l` -eq 0 \
262 || (echo "Error: files left after distclean" 1>&2; \
264 -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)
265 @echo "$(distdir).tar.gz is ready for distribution" | \
266 sed 'h;s/./=/g;p;x;p;x'