tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / maint.mk
1 # Maintainer makefile rules for Automake.
2 #
3 # Copyright (C) 1995-2013 Free Software Foundation, Inc.
4 #
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)
8 # any later version.
9 #
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.
14 #
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/>.
17
18 # Avoid CDPATH issues.
19 unexport CDPATH
20
21 # Program to use to fetch files from the Net.
22 WGET = wget
23
24 # --------------------------------------------------------- #
25 #  Automatic generation of the ChangeLog from git history.  #
26 # --------------------------------------------------------- #
27
28 gitlog_to_changelog_command = $(PERL) $(srcdir)/lib/gitlog-to-changelog
29 gitlog_to_changelog_fixes = $(srcdir)/.git-log-fix
30 gitlog_to_changelog_options = --amend=$(gitlog_to_changelog_fixes) \
31                               --since='2011-12-28 00:00:00' \
32                               --no-cluster --format '%s%n%n%b'
33
34 EXTRA_DIST += lib/gitlog-to-changelog
35 EXTRA_DIST += $(gitlog_to_changelog_fixes)
36
37 # When executed from a git checkout, generate the ChangeLog from the git
38 # history.  When executed from an extracted distribution tarball, just
39 # copy the distributed ChangeLog in the build directory (and if this
40 # fails, or if no distributed ChangeLog file is present, complain and
41 # give an error).
42 #
43 # The ChangeLog should be regenerated unconditionally when working from
44 # checked-out sources; otherwise, if we're working from a distribution
45 # tarball, we expect the ChangeLog to be distributed, so check that it
46 # is indeed present in the source directory.
47 ChangeLog:
48         $(AM_V_GEN)set -e; set -u; \
49         if test -d $(srcdir)/.git; then \
50           rm -f $@-t \
51             && $(gitlog_to_changelog_command) \
52                $(gitlog_to_changelog_options) >$@-t \
53             && chmod a-w $@-t \
54             && mv -f $@-t $@ \
55             || exit 1; \
56         elif test ! -f $(srcdir)/$@; then \
57           echo "Source tree is not a git checkout, and no pre-existent" \
58                "$@ file has been found there" >&2; \
59           exit 1; \
60         fi
61 .PHONY: ChangeLog
62
63
64 # --------------------------- #
65 #  Perl coverage statistics.  #
66 # --------------------------- #
67
68 PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
69 PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
70 PERL_COVER = cover
71
72 check-coverage-run recheck-coverage-run: %-coverage-run: all
73         $(MKDIR_P) $(PERL_COVERAGE_DB)
74         PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
75         WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
76         $(MAKE) $*
77
78 check-coverage-report:
79         @if test ! -d "$(PERL_COVERAGE_DB)"; then \
80           echo "No coverage database found in '$(PERL_COVERAGE_DB)'." >&2; \
81           echo "Please run \"make check-coverage\" first" >&2; \
82           exit 1; \
83         fi
84         $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
85
86 # We don't use direct dependencies here because we'd like to be able
87 # to invoke the report even after interrupted check-coverage.
88 check-coverage: check-coverage-run
89         $(MAKE) check-coverage-report
90
91 recheck-coverage: recheck-coverage-run
92         $(MAKE) check-coverage-report
93
94 clean-coverage:
95         rm -rf "$(PERL_COVERAGE_DB)"
96 clean-local: clean-coverage
97
98 .PHONY: check-coverage recheck-coverage check-coverage-run \
99         recheck-coverage-run check-coverage-report clean-coverage
100
101
102 # ---------------------------------------------------- #
103 #  Tagging and/or uploading stable and beta releases.  #
104 # ---------------------------------------------------- #
105
106 GIT = git
107
108 EXTRA_DIST += lib/gnupload
109
110 base_version_rx = ^[1-9][0-9]*\.[0-9][0-9]*
111 stable_major_version_rx = $(base_version_rx)$$
112 stable_minor_version_rx = $(base_version_rx)\.[0-9][0-9]*$$
113 beta_version_rx = $(base_version_rx)(\.[0-9][0-9]*)?[bdfhjlnprtvxz]$$
114 match_version = echo "$(VERSION)" | $(EGREP) >/dev/null
115
116 # Check that we don't have uncommitted or unstaged changes.
117 # TODO: Maybe the git suite already offers a shortcut to verify if the
118 # TODO: working directory is "clean" or not?  If yes, use that instead
119 # TODO: of duplicating the logic here.
120 git_must_have_clean_workdir = \
121   $(GIT) rev-parse --verify HEAD >/dev/null \
122     && $(GIT) update-index -q --refresh \
123     && $(GIT) diff-files --quiet \
124     && $(GIT) diff-index --quiet --cached HEAD \
125     || { echo "$@: you have uncommitted or unstaged changes" >&2; exit 1; }
126
127 determine_release_type = \
128   if $(match_version) '$(stable_major_version_rx)'; then \
129     release_type='Major release'; \
130     announcement_type='major release'; \
131     dest=ftp; \
132   elif $(match_version) '$(stable_minor_version_rx)'; then \
133     release_type='Minor release'; \
134     announcement_type='maintenance release'; \
135     dest=ftp; \
136   elif $(match_version) '$(beta_version_rx)'; then \
137     release_type='Beta release'; \
138     announcement_type='test release'; \
139     dest=alpha; \
140   else \
141     echo "$@: invalid version '$(VERSION)' for a release" >&2; \
142     exit 1; \
143   fi
144
145 # Help the debugging of $(determine_release_type) and related code.
146 print-release-type:
147         @$(determine_release_type); \
148          echo "$$release_type $(VERSION);" \
149               "it will be announced as a $$announcement_type"
150
151 git-tag-release: maintainer-check
152         @set -e -u; \
153         case '$(AM_TAG_DRYRUN)' in \
154           ""|[nN]|[nN]o|NO) run="";; \
155           *) run="echo Running:";; \
156         esac; \
157         $(determine_release_type); \
158         $(git_must_have_clean_workdir); \
159         $$run $(GIT) tag -s "v$(VERSION)" -m "$$release_type $(VERSION)"
160
161 git-upload-release:
162         @# Check this is a version we can cut a release (either test
163         @# or stable) from.
164         @$(determine_release_type)
165         @# The repository must be clean.
166         @$(git_must_have_clean_workdir)
167         @# Check that we are releasing from a valid tag.
168         @tag=`$(GIT) describe` \
169           && case $$tag in "v$(VERSION)") true;; *) false;; esac \
170           || { echo "$@: you can only create a release from a tagged" \
171                     "version" >&2; \
172                exit 1; }
173         @# Build the distribution tarball(s).
174         $(MAKE) dist
175         @# Upload it to the correct FTP repository.
176         @$(determine_release_type) \
177           && dest=$$dest.gnu.org:automake \
178           && echo "Will upload to $$dest: $(DIST_ARCHIVES)" \
179           && $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) --to $$dest \
180                                     $(DIST_ARCHIVES)
181
182 .PHONY: print-release-type git-upload-release git-tag-release
183
184
185 # ------------------------------------------------------------------ #
186 #  Explore differences of autogenerated files in different commits.  #
187 # ------------------------------------------------------------------ #
188
189 # Visually comparing differences between the Makefile.in files in
190 # automake's own build system as generated in two different branches
191 # might help to catch bugs and blunders.  This has already happened a
192 # few times in the past, when we used to version-control Makefile.in.
193 autodiffs:
194         @set -u; \
195          NEW_COMMIT=$${NEW_COMMIT-"HEAD"}; \
196          OLD_COMMIT=$${OLD_COMMIT-"HEAD~1"}; \
197          am_gitdir='$(abs_top_srcdir)/.git'; \
198          get_autofiles_from_rev () \
199          { \
200              rev=$$1 dir=$$2 \
201                && echo "$@: will get files from revision $$rev" \
202                && $(GIT) clone -q --depth 1 "$$am_gitdir" tmp \
203                && cd tmp \
204                && $(GIT) checkout -q "$$rev" \
205                && echo "$@: bootstrapping $$rev" \
206                && $(SHELL) ./bootstrap.sh \
207                && echo "$@: copying files from $$rev" \
208                && makefile_ins=`find . -name Makefile.in` \
209                && (tar cf - configure aclocal.m4 $$makefile_ins) | \
210                   (cd .. && cd "$$dir" && tar xf -) \
211                && cd .. \
212                && rm -rf tmp; \
213          }; \
214          outdir=$@.dir \
215            && : Before proceeding, ensure the specified revisions truly exist. \
216            && $(GIT) --git-dir="$$am_gitdir" describe $$OLD_COMMIT >/dev/null \
217            && $(GIT) --git-dir="$$am_gitdir" describe $$NEW_COMMIT >/dev/null \
218            && rm -rf $$outdir \
219            && mkdir $$outdir \
220            && cd $$outdir \
221            && mkdir new old \
222            && get_autofiles_from_rev $$OLD_COMMIT old \
223            && get_autofiles_from_rev $$NEW_COMMIT new \
224            && exit 0
225
226 # With lots of eye candy; we like our developers pampered and spoiled :-)
227 compare-autodiffs: autodiffs
228         @set -u; \
229         : $${COLORDIFF=colordiff} $${DIFF=diff}; \
230         dir=autodiffs.dir; \
231         if test ! -d "$$dir"; then \
232           echo "$@: $$dir: Not a directory" >&2; \
233           exit 1; \
234         fi; \
235         mydiff=false mypager=false; \
236         if test -t 1; then \
237           if ($$COLORDIFF -r . .) </dev/null >/dev/null 2>&1; then \
238             mydiff=$$COLORDIFF; \
239             mypager="less -R"; \
240           else \
241             mypager=less; \
242           fi; \
243         else \
244           mypager=cat; \
245         fi; \
246         if test "$$mydiff" = false; then \
247           if ($$DIFF -r -u . .); then \
248             mydiff=$$DIFF; \
249           else \
250             echo "$@: no good-enough diff program specified" >&2; \
251             exit 1; \
252           fi; \
253         fi; \
254         st=0; $$mydiff -r -u $$dir/old $$dir/new | $$mypager || st=$$?; \
255         rm -rf $$dir; \
256         exit $$st
257 .PHONY: autodiffs compare-autodiffs
258
259 # ---------------------------------------------- #
260 #  Help writing the announcement for a release.  #
261 # ---------------------------------------------- #
262
263 PACKAGE_MAILINGLIST = automake@gnu.org
264
265 announcement: NEWS
266         $(AM_V_GEN): \
267           && rm -f $@ $@-t \
268           && $(determine_release_type) \
269           && ftp_base="ftp://$$dest.gnu.org/gnu/$(PACKAGE)" \
270           && X () { printf '%s\n' "$$*" >> $@-t; } \
271           && X "We are pleased to announce the $(PACKAGE_NAME) $(VERSION)" \
272                "$$announcement_type." \
273           && X \
274           && X "**TODO** Brief description of the release here." \
275           && X \
276           && X "**TODO** This description can span multiple paragraphs." \
277           && X \
278           && X "See below for the detailed list of changes since the" \
279           && X "previous version, as summarized by the NEWS file." \
280           && X \
281           && X "Download here:" \
282           && X \
283           && X "  $$ftp_base/$(PACKAGE)-$(VERSION).tar.gz" \
284           && X "  $$ftp_base/$(PACKAGE)-$(VERSION).tar.xz" \
285           && X \
286           && X "Please report bugs and problems to" \
287                "<$(PACKAGE_BUGREPORT)>," \
288           && X "and send general comments and feedback to" \
289                "<$(PACKAGE_MAILINGLIST)>." \
290           && X \
291           && X "Thanks to everyone who has reported problems, contributed" \
292           && X "patches, and helped testing Automake!" \
293           && X \
294           && X "-*-*-*-" \
295           && X \
296           && $(AWK) '\
297                 ($$0 == "New in $(VERSION):") { wait_for_end=1; } \
298                 (/^~~~/ && wait_for_end) { exit(0) } \
299                 { print } \
300              ' <$(srcdir)/NEWS >> $@-t \
301           && mv -f $@-t $@
302 .PHONY: announcement
303 CLEANFILES += announcement
304
305 # --------------------------------------------------------------------- #
306 #  Synchronize third-party files that are committed in our repository.  #
307 # --------------------------------------------------------------------- #
308
309 # Git repositories on Savannah.
310 git-sv-host = git.savannah.gnu.org
311
312 # Some repositories we sync files from.
313 SV_CVS    = 'http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/'
314 SV_GIT_CF = 'http://$(git-sv-host)/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
315 SV_GIT_AC = 'http://$(git-sv-host)/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
316 SV_GIT_GL = 'http://$(git-sv-host)/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
317
318 # Files that we fetch and which we compare against.
319 # Note that the 'lib/COPYING' file must still be synced by hand.
320 FETCHFILES = \
321   $(SV_GIT_CF)config.guess \
322   $(SV_GIT_CF)config.sub \
323   $(SV_CVS)texinfo/texinfo/doc/texinfo.tex \
324   $(SV_CVS)texinfo/texinfo/util/gendocs.sh \
325   $(SV_CVS)texinfo/texinfo/util/gendocs_template \
326   $(SV_GIT_GL)build-aux/gitlog-to-changelog \
327   $(SV_GIT_GL)build-aux/gnupload \
328   $(SV_GIT_GL)build-aux/update-copyright \
329   $(SV_GIT_GL)doc/INSTALL
330
331 # Fetch the latest versions of few scripts and files we care about.
332 # A retrieval failure or a copying failure usually mean serious problems,
333 # so we'll just bail out if 'wget' or 'cp' fail.
334 fetch:
335         $(AM_V_at)rm -rf Fetchdir
336         $(AM_V_at)mkdir Fetchdir
337         $(AM_V_GEN)set -e; \
338         if $(AM_V_P); then wget_opts=; else wget_opts=-nv; fi; \
339         for url in $(FETCHFILES); do \
340            file=`printf '%s\n' "$$url" | sed 's|^.*/||; s|^.*=||'`; \
341            $(WGET) $$wget_opts "$$url" -O Fetchdir/$$file || exit 1; \
342            if cmp Fetchdir/$$file $(srcdir)/lib/$$file >/dev/null; then \
343              : Nothing to do; \
344            else \
345              echo "$@: updating file $$file"; \
346              cp Fetchdir/$$file $(srcdir)/lib/$$file || exit 1; \
347            fi; \
348         done
349         $(AM_V_at)rm -rf Fetchdir
350 .PHONY: fetch
351
352 # ---------------------------------------------------------------------- #
353 #  Generate and upload manuals in several formats, for the GNU website.  #
354 # ---------------------------------------------------------------------- #
355
356 web_manual_dir = doc/web-manual
357
358 RSYNC = rsync
359 CVS = cvs
360 CVSU = cvsu
361 CVS_USER = $${USER}
362 WEBCVS_ROOT = cvs.savannah.gnu.org:/web
363 CVS_RSH = ssh
364 export CVS_RSH
365
366 .PHONY: web-manual web-manual-update
367 web-manual web-manual-update: t = $@.dir
368
369 # Build manual in several formats.  Note to the recipe:
370 # 1. The symlinking of automake.texi into the temporary directory is
371 #    required to pacify extra checks from gendocs.sh.
372 # 2. The redirection to /dev/null before the invocation of gendocs.sh
373 #    is done to better respect silent rules.
374 web-manual:
375         $(AM_V_at)rm -rf $(web_manual_dir) $t
376         $(AM_V_at)mkdir $t
377         $(AM_V_at)$(LN_S) '$(abs_srcdir)/doc/$(PACKAGE).texi' '$t/'
378         $(AM_V_GEN)cd $t \
379           && GENDOCS_TEMPLATE_DIR='$(abs_srcdir)/lib' \
380           && export GENDOCS_TEMPLATE_DIR \
381           && if $(AM_V_P); then :; else exec >/dev/null 2>&1; fi \
382           && $(SHELL) '$(abs_srcdir)/lib/gendocs.sh' \
383              -I '$(abs_srcdir)/doc' --email $(PACKAGE_BUGREPORT) \
384              $(PACKAGE) '$(PACKAGE_NAME)'
385         $(AM_V_at)mkdir $(web_manual_dir)
386         $(AM_V_at)mv -f $t/manual/* $(web_manual_dir)
387         $(AM_V_at)rm -rf $t
388         @! $(AM_V_P) || ls -l $(web_manual_dir)
389
390 # Upload manual to www.gnu.org, using CVS (sigh!)
391 web-manual-update:
392         $(AM_V_at)$(determine_release_type); \
393         case $$release_type in \
394           [Mm]ajor\ release|[Mm]inor\ release);; \
395           *) echo "Cannot upload manuals from a \"$$release_type\"" >&2; \
396              exit 1;; \
397         esac
398         $(AM_V_at)test -f $(web_manual_dir)/$(PACKAGE).html || { \
399           echo 'You have to run "$(MAKE) web-manuals" before' \
400                'invoking "$(MAKE) $@"' >&2; \
401           exit 1; \
402         }
403         $(AM_V_at)rm -rf $t
404         $(AM_V_at)mkdir $t
405         $(AM_V_at)cd $t \
406           && $(CVS) -z3 -d :ext:$(CVS_USER)@$(WEBCVS_ROOT)/$(PACKAGE) \
407                     co $(PACKAGE)
408         @# According to the rsync manpage, "a trailing slash on the
409         @# source [...] avoids creating an additional directory
410         @# level at the destination".  So the trailing '/' after
411         @# '$(web_manual_dir)' below is intended.
412         $(AM_V_at)$(RSYNC) -avP $(web_manual_dir)/ $t/$(PACKAGE)/manual
413         $(AM_V_GEN): \
414           && cd $t/$(PACKAGE)/manual \
415           && new_files=`$(CVSU) --types='?'` \
416           && new_files=`echo "$$new_files" | sed s/^..//` \
417           && { test -z "$$new_files" || $(CVS) add -ko $$new_files; } \
418           && $(CVS) ci -m $(VERSION)
419         $(AM_V_at)rm -rf $t
420 .PHONY: web-manual-update
421
422 clean-web-manual:
423         $(AM_V_at)rm -rf $(web_manual_dir)
424 .PHONY: clean-web-manual
425 clean-local: clean-web-manual
426
427 EXTRA_DIST += lib/gendocs.sh lib/gendocs_template
428
429 # ------------------------------------------------ #
430 #  Update copyright years of all committed files.  #
431 # ------------------------------------------------ #
432
433 EXTRA_DIST += lib/update-copyright
434
435 update_copyright_env = \
436   UPDATE_COPYRIGHT_FORCE=1 \
437   UPDATE_COPYRIGHT_USE_INTERVALS=2
438
439 # In addition to the several README files, these as well are
440 # not expected to have a copyright notice.
441 files_without_copyright = \
442   .autom4te.cfg \
443   .git-log-fix \
444   .gitattributes \
445   .gitignore \
446   INSTALL \
447   COPYING \
448   AUTHORS \
449   THANKS \
450   lib/INSTALL \
451   lib/COPYING
452
453 # This script is in the public domain.
454 files_without_copyright += lib/mkinstalldirs
455
456 # This script has an MIT-style license
457 files_without_copyright += lib/install-sh
458
459 .PHONY: update-copyright
460 update-copyright:
461         $(AM_V_GEN)set -e; \
462         current_year=`date +%Y` && test -n "$$current_year" \
463           || { echo "$@: cannot get current year" >&2; exit 1; }; \
464         sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
465           bootstrap.sh configure.ac; \
466         excluded_re=`( \
467           for url in $(FETCHFILES); do echo "$$url"; done \
468             | sed -e 's!^.*/!!' -e 's!^.*=!!' -e 's!^!lib/!' \
469           && for f in $(files_without_copyright); do echo $$f; done \
470         ) | sed -e '$$!s,$$,|,' | tr -d '\012\015'`; \
471         $(GIT) ls-files \
472           | grep -Ev '(^|/)README$$' \
473           | grep -Ev "^($$excluded_re)$$" \
474           | $(update_copyright_env) xargs $(srcdir)/lib/$@
475
476 # -------------------------------------------------------------- #
477 #  Run the testsuite with the least supported autoconf version.  #
478 # -------------------------------------------------------------- #
479
480 gnu-ftp = http://ftp.gnu.org/gnu
481
482 # Various shorthands: version, name, package name, tarball name,
483 # tarball location, installation directory.
484 ac-v = $(required_autoconf_version)
485 ac-n = autoconf
486 ac-p = $(ac-n)-$(ac-v)
487 ac-t = $(ac-p).tar.gz
488 ac-l = maintainer/$(ac-t)
489 ac-d = maintainer/$(ac-p)
490
491 fetch-minimal-autoconf: o = $(ac-l)
492 fetch-minimal-autoconf:
493         $(AM_V_at)$(MKDIR_P) $(dir $o)
494         $(AM_V_at)rm -f $o $o-t
495         $(AM_V_GEN)$(WGET) -O $o-t $(gnu-ftp)/$(ac-n)/$(ac-t)
496         $(AM_V_at)chmod a-w $o-t && mv -f $o-t $o && ls -l $o
497 .PHONY: fetch-minimal-autoconf
498
499 build-minimal-autoconf:
500         $(AM_V_GEN):; \
501         test -f $(ac-l) || { \
502           echo "$@: tarball $(ac-l) seems missing." >&2; \
503           echo "$@: have you run '$(MAKE) fetch-minimal-autoconf'?" >&2; \
504           exit 1; \
505         }; \
506           set -x \
507           && $(PERL) $(srcdir)/t/ax/deltree.pl $(ac-d) \
508           && $(MKDIR_P) $(ac-d) \
509           && cd $(ac-d) \
510           && tar xzf '$(CURDIR)/$(ac-l)' \
511           && mv $(ac-p) src \
512           && mkdir build \
513           && cd build \
514           && env CONFIG_SHELL='$(SHELL)' $(SHELL) ../src/configure \
515                --prefix='$(CURDIR)/$(ac-d)' CONFIG_SHELL='$(SHELL)' \
516           && $(MAKE) install
517         $(AM_V_at)echo ' ======' && $(ac-d)/bin/autoconf --version
518 .PHONY: build-minimal-autoconf
519
520 check-minimal-autoconf:
521         $(AM_V_at)p='$(ac-d)/bin/autoconf'; \
522           if test ! -f "$$p" || test ! -x "$$p"; then \
523             echo "$@: program '$$p' seems missing." >&2; \
524             echo "$@: have you run '$(MAKE) build-minimal-autoconf'?" >&2; \
525             exit 1; \
526           fi
527         $(AM_V_GEN): \
528           && PATH='$(CURDIR)/$(ac-d)/bin$(PATH_SEPARATOR)'$$PATH \
529           && export PATH \
530           && AUTOCONF=autoconf \
531           && AUTOHEADER=autoheader \
532           && AUTORECONF=autoreconf \
533           && AUTOM4TE=autom4te \
534           && AUTOUPDATE=autoupdate \
535           && export AUTOCONF AUTOHEADER AUTORECONF AUTOM4TE AUTOUPDATE \
536           && echo === check autoconf version '(must be = $(ac-v))' \
537           && autoconf --version \
538           && autoconf --version | sed -e 's/^/ /; s/$$/ /' -e 1q \
539                | $(FGREP) '$(ac-v)' >/dev/null \
540           && echo === configure \
541           && ./configure $(shell ./config.status --config) \
542           && echo === build and test \
543           && $(MAKE) check
544 .PHONY: check-minimal-autoconf
545
546
547 # --------------------------------------------------------------- #
548 #  Testing on real-world packages can help us avoid regressions.  #
549 # --------------------------------------------------------------- #
550
551 #
552 # NOTE (from Stefano Lattarini):
553 #
554 # This section is mostly hacky and ad-hoc, but works for me and
555 # on my system.  And while far from clean, it should help catching
556 # real regressions on real world packages, which is important.
557 # Ideas about how to improve this and make it more generic, portable,
558 # clean, etc., are welcome.
559 #
560
561 # Tiny sample package.
562 FEW_PACKAGES += hello
563 # Smallish package using recursive make setup.
564 FEW_PACKAGES += make
565 # Medium-size package using non-recursive make setup.
566 FEW_PACKAGES += coreutils
567
568 ALL_PACKAGES = \
569   $(FEW_PACKAGES) \
570   autoconf \
571   bison \
572   grep \
573   tar \
574   diffutils \
575   smalltalk
576
577 pkg-targets = check dist
578
579 # Note: "ttp" stays for "Third Party Package".
580
581 ttp-check ttp-check-all: do-clone = $(GIT) clone --verbose
582 ttp-check: ttp-packages = $(FEW_PACKAGES)
583 ttp-check-all: ttp-packages = $(ALL_PACKAGES)
584
585 # Note: some packages depend on pkg-config, and its provided macros.
586 ttp-check ttp-check-all: t/pkg-config-macros.log
587         @set -e; \
588         $(setup_autotools_paths); \
589         skip_all_ () \
590         { \
591           echo "***" >&2; \
592           echo "*** $@: WARNING: $$@" >&2; \
593           echo "*** $@: WARNING: some packages might fail to bootstrap" >&2; \
594           echo "***" >&2;  \
595         }; \
596         . t/pkg-config-macros.dir/get.sh || exit 1; \
597         mkdir $@.d && cd $@.d || exit 1; \
598         for p in $(ttp-packages); do \
599             echo; \
600             echo ========  BEGIN TTP $$p  =========; \
601             echo; \
602             set -x; \
603             $(do-clone) git://$(git-sv-host)/$$p.git || exit 1; \
604             ( \
605               cd $$p \
606                 && ls -l \
607                 && if test -f bootstrap; then \
608                      ./bootstrap --no-git; \
609                    else \
610                      $$AUTORECONF -fvi; \
611                    fi \
612                 && ./configure \
613                 && if test $$p = make; then \
614                      $(MAKE) update; \
615                    else :; fi \
616                 && for t in $(pkg-targets); do \
617                      $(MAKE) $$t WERROR_CFLAGS= || exit 1; \
618                    done \
619             ) || exit 1; \
620             set +x; \
621             echo; \
622             echo ========  END TTP $$p  =========; \
623             echo; \
624          done
625 ifndef keep-ttp-dir
626         rm -rf $@.d
627 endif
628
629 # Alias for lazy typists.
630 ttp: ttp-check
631 ttp-all: ttp-check-all
632
633 .PHONY: ttp ttp-check ttp-all ttp-check-all