1#!/bin/bash
2# Script that checks against build infrastructure mistakes in the examples.
3
4# Copyright (C) 2018 Free Software Foundation, Inc.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
19
20# func_init sample
21# sets environment variables for building and running the given sample.
22func_init ()
23{
24  case "$1" in
25    hello-objc-gnustep) . /usr/share/GNUstep/Makefiles/GNUstep.sh ;;
26  esac
27}
28
29
30# func_autogen sample
31# adds generated build infrastructure files to the given sample.
32func_autogen ()
33{
34  case "$1" in
35    hello-objc-gnustep)
36      (func_init "$1"; cd "$1" && ./autogen.sh)
37      ;;
38    *)
39      (cd "$1" && ./autogen.sh)
40      ;;
41  esac
42}
43
44# func_autoclean sample
45# removes generated build infrastructure files from the given sample.
46func_autoclean ()
47{
48  case "$1" in
49    hello-objc-gnustep)
50      (func_init "$1"; cd "$1" && ./autoclean.sh)
51      ;;
52    *)
53      (cd "$1" && ./autoclean.sh)
54      ;;
55  esac
56}
57
58# func_configure sample [builddir]
59# runs configure for the given sample, optionally in a VPATH build.
60func_configure ()
61{
62  case "$1" in
63    hello-objc-gnustep) ;;
64    *)
65      if test -n "$2"; then
66        (cd "$1"
67         mkdir "$2"
68         (cd "$2" && ../configure)
69        )
70      else
71        (cd "$1" && ./configure)
72      fi
73      ;;
74  esac
75}
76
77# func_distclean sample [builddir]
78# undoes the effects of func_configure sample [builddir].
79func_distclean ()
80{
81  case "$1" in
82    hello-objc-gnustep) ;;
83    *)
84      if test -n "$2"; then
85        (cd "$1/$2" && make distclean)
86      else
87        (cd "$1" && make distclean)
88      fi
89      ;;
90  esac
91}
92
93# func_maintainerclean sample [builddir]
94# also removes files that are expensive to rebuild.
95func_maintainerclean ()
96{
97  case "$1" in
98    hello-objc-gnustep)
99      (func_init "$1"; cd "$1" && make distclean)
100      ;;
101    *)
102      if test -n "$2"; then
103        (cd "$1/$2" && make maintainer-clean)
104      else
105        (cd "$1" && make maintainer-clean)
106      fi
107      ;;
108  esac
109}
110
111
112# func_check_autoclean sample
113# checks whether the autoclean.sh script is complete.
114func_check_autoclean ()
115{
116  sample="$1"
117  rm -rf "$sample.bak"
118  cp -a "$sample" "$sample.bak"
119  func_autogen "$sample"
120  func_autoclean "$sample"
121  LC_ALL=C diff -r -q "$sample.bak" "$sample" | sed -n -e 's/^Only in //p' | sed -e 's|: |/|' > "$sample.out"
122  if ! test -s "$sample.out"; then
123    rm -f "$sample.out"
124  fi
125  rm -rf "$sample.bak"
126}
127
128func_check_autoclean_all ()
129{
130  rm -f hello-*.out
131  func_check_autoclean hello-c
132  func_check_autoclean hello-c-gnome
133  func_check_autoclean hello-c-gnome3
134  func_check_autoclean hello-c++
135  func_check_autoclean hello-c++-qt
136  func_check_autoclean hello-c++-kde
137  func_check_autoclean hello-c++-gnome
138  func_check_autoclean hello-c++-wxwidgets
139  func_check_autoclean hello-objc
140  func_check_autoclean hello-objc-gnustep
141  func_check_autoclean hello-objc-gnome
142  func_check_autoclean hello-sh
143  func_check_autoclean hello-python
144  func_check_autoclean hello-clisp
145  func_check_autoclean hello-librep
146  func_check_autoclean hello-guile
147  func_check_autoclean hello-smalltalk
148  func_check_autoclean hello-java
149  func_check_autoclean hello-java-awt
150  func_check_autoclean hello-java-swing
151  func_check_autoclean hello-java-qtjambi
152  func_check_autoclean hello-csharp
153  func_check_autoclean hello-csharp-forms
154  func_check_autoclean hello-gawk
155  func_check_autoclean hello-pascal
156  func_check_autoclean hello-ycp
157  func_check_autoclean hello-tcl
158  func_check_autoclean hello-tcl-tk
159  func_check_autoclean hello-perl
160  func_check_autoclean hello-php
161  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
162    echo "*** func_check_autoclean error: Leftover files:"
163    cat hello-*.out
164    rm -f hello-*.out
165    exit 1
166  fi
167}
168
169
170# Known configure failures:
171# hello-c-gnome: error: Could not find the gnomeConf.sh file that is generated by gnome-libs install
172# hello-c-gnome3: error: can't find gtk+-3.0 >= 3.10
173# hello-c++-qt: error: cannot find correct Qt headers!
174# hello-c++-kde: configure: error: Qt (>= Qt 3.1.0) (headers and libraries) not found. Please check your installation!
175# hello-c++-gnome: error: Could not find the gnomeConf.sh file that is generated by gnome-libs install
176# hello-objc-gnome: error: Could not find the gnomeConf.sh file that is generated by gnome-libs install
177# hello-ycp: *** Essential program y2base not found
178
179# func_check_distclean sample
180# checks 'make distclean' directly after 'configure'.
181func_check_distclean ()
182{
183  sample="$1"
184  rm -rf "$sample.bak"
185  func_autogen "$sample"
186  cp -a "$sample" "$sample.bak"
187  if func_configure "$sample" > "$sample.log" 2>&1; then
188    rm -f "$sample.log"
189    func_distclean "$sample"
190    LC_ALL=C diff -r -q "$sample.bak" "$sample" | sed -n -e 's/^Only in //p' | sed -e 's|: |/|' > "$sample.out"
191  fi
192  func_autoclean "$sample"
193  if ! test -s "$sample.out"; then
194    rm -f "$sample.out"
195  fi
196  rm -rf "$sample.bak"
197}
198
199func_check_distclean_all ()
200{
201  rm -f hello-*.log hello-*.out
202  func_check_distclean hello-c
203 #func_check_distclean hello-c-gnome
204 #func_check_distclean hello-c-gnome3
205  func_check_distclean hello-c++
206 #func_check_distclean hello-c++-qt
207 #func_check_distclean hello-c++-kde
208 #func_check_distclean hello-c++-gnome
209  func_check_distclean hello-c++-wxwidgets
210  func_check_distclean hello-objc
211  func_check_distclean hello-objc-gnustep
212 #func_check_distclean hello-objc-gnome
213  func_check_distclean hello-sh
214  func_check_distclean hello-python
215  func_check_distclean hello-clisp
216  func_check_distclean hello-librep
217  func_check_distclean hello-guile
218  func_check_distclean hello-smalltalk
219  func_check_distclean hello-java
220  func_check_distclean hello-java-awt
221  func_check_distclean hello-java-swing
222  func_check_distclean hello-java-qtjambi
223  func_check_distclean hello-csharp
224  func_check_distclean hello-csharp-forms
225  func_check_distclean hello-gawk
226  func_check_distclean hello-pascal
227 #func_check_distclean hello-ycp
228  func_check_distclean hello-tcl
229  func_check_distclean hello-tcl-tk
230  func_check_distclean hello-perl
231  func_check_distclean hello-php
232  if (shopt -s failglob; echo hello-*.log) >/dev/null 2>/dev/null; then
233    echo "*** func_check_distclean error: 'configure' failures"
234    echo hello-*.log
235    exit 1
236  fi
237  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
238    echo "*** func_check_distclean error: incomplete 'make distclean'"
239    echo hello-*.out
240    exit 1
241  fi
242}
243
244
245# Known make failures:
246# hello-java-qtjambi: error: package com.trolltech.qt.core does not exist
247
248# func_check_maintainerclean sample
249# checks 'make distclean' after 'configure; make'.
250func_check_maintainerclean ()
251{
252  sample="$1"
253  rm -rf "$sample.bak"
254  func_autogen "$sample"
255  cp -a "$sample" "$sample.bak"
256  if func_configure "$sample"; then
257    if (func_init "$sample"; cd "$sample" && make) > "$sample.log" 2>&1; then
258      rm -f "$sample.log"
259    fi
260  fi
261  func_maintainerclean "$sample"
262  # TODO: Remove .pot files workaround after next release.
263  # TODO: Remove .po~ files workaround.
264  LC_ALL=C diff -r -q "$sample.bak" "$sample" | sed -n -e 's/^Only in //p' | sed -e 's|: |/|' | grep "^${sample}/" | { if test -f "$sample"/po/Makevars || test "$sample" = hello-objc-gnustep; then grep -v '\.pot$'; else cat; fi; } | grep -v '\.po~$' > "$sample.out"
265  func_autoclean "$sample"
266  if ! test -s "$sample.out"; then
267    rm -f "$sample.out"
268  fi
269  rm -rf "$sample.bak"
270}
271
272func_check_maintainerclean_all ()
273{
274  rm -f hello-*.log hello-*.out
275  func_check_maintainerclean hello-c
276 #func_check_maintainerclean hello-c-gnome
277 #func_check_maintainerclean hello-c-gnome3
278  func_check_maintainerclean hello-c++
279 #func_check_maintainerclean hello-c++-qt
280 #func_check_maintainerclean hello-c++-kde
281 #func_check_maintainerclean hello-c++-gnome
282  func_check_maintainerclean hello-c++-wxwidgets
283  func_check_maintainerclean hello-objc
284  func_check_maintainerclean hello-objc-gnustep
285 #func_check_maintainerclean hello-objc-gnome
286  func_check_maintainerclean hello-sh
287  func_check_maintainerclean hello-python
288  func_check_maintainerclean hello-clisp
289  func_check_maintainerclean hello-librep
290  func_check_maintainerclean hello-guile
291  func_check_maintainerclean hello-smalltalk
292  func_check_maintainerclean hello-java
293  func_check_maintainerclean hello-java-awt
294  func_check_maintainerclean hello-java-swing
295 #func_check_maintainerclean hello-java-qtjambi
296  func_check_maintainerclean hello-csharp
297  func_check_maintainerclean hello-csharp-forms
298  func_check_maintainerclean hello-gawk
299  func_check_maintainerclean hello-pascal
300 #func_check_maintainerclean hello-ycp
301  func_check_maintainerclean hello-tcl
302  func_check_maintainerclean hello-tcl-tk
303  func_check_maintainerclean hello-perl
304  func_check_maintainerclean hello-php
305  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
306    echo "*** func_check_maintainerclean error: 'make' failures"
307    echo hello-*.log
308    exit 1
309  fi
310  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
311    echo "*** func_check_maintainerclean error: incomplete 'make maintainer-clean'"
312    echo hello-*.out
313    exit 1
314  fi
315}
316
317
318# func_check_maintainerclean_vpath sample
319# checks 'make distclean' after 'configure; make' with a VPATH build.
320func_check_maintainerclean_vpath ()
321{
322  sample="$1"
323  case "$sample" in
324    hello-objc-gnustep) ;;
325    *)
326      rm -rf "$sample.bak"
327      func_autogen "$sample"
328      cp -a "$sample" "$sample.bak"
329      if func_configure "$sample" build; then
330        if (func_init "$sample"; cd "$sample"/build && make) > "$sample.log" 2>&1; then
331          rm -f "$sample.log"
332        fi
333      fi
334      func_maintainerclean "$sample" build
335      # TODO: Remove .pot files workaround after next release.
336      # TODO: Remove .po~ files workaround.
337      find "$sample"/build -type f | LC_ALL=C sort | { if test -f "$sample"/po/Makevars; then grep -v '\.pot$'; else cat; fi; } | grep -v '\.po~$' > "$sample.out"
338      rm -rf "$sample"/build
339      func_autoclean "$sample"
340      if ! test -s "$sample.out"; then
341        rm -f "$sample.out"
342      fi
343      rm -rf "$sample.bak"
344      ;;
345  esac
346}
347
348func_check_maintainerclean_vpath_all ()
349{
350  rm -f hello-*.log hello-*.out
351  func_check_maintainerclean_vpath hello-c
352 #func_check_maintainerclean_vpath hello-c-gnome
353 #func_check_maintainerclean_vpath hello-c-gnome3
354  func_check_maintainerclean_vpath hello-c++
355 #func_check_maintainerclean_vpath hello-c++-qt
356 #func_check_maintainerclean_vpath hello-c++-kde
357 #func_check_maintainerclean_vpath hello-c++-gnome
358  func_check_maintainerclean_vpath hello-c++-wxwidgets
359  func_check_maintainerclean_vpath hello-objc
360  func_check_maintainerclean_vpath hello-objc-gnustep
361 #func_check_maintainerclean_vpath hello-objc-gnome
362  func_check_maintainerclean_vpath hello-sh
363  func_check_maintainerclean_vpath hello-python
364  func_check_maintainerclean_vpath hello-clisp
365  func_check_maintainerclean_vpath hello-librep
366  func_check_maintainerclean_vpath hello-guile
367  func_check_maintainerclean_vpath hello-smalltalk
368  func_check_maintainerclean_vpath hello-java
369  func_check_maintainerclean_vpath hello-java-awt
370  func_check_maintainerclean_vpath hello-java-swing
371 #func_check_maintainerclean_vpath hello-java-qtjambi
372  func_check_maintainerclean_vpath hello-csharp
373  func_check_maintainerclean_vpath hello-csharp-forms
374  func_check_maintainerclean_vpath hello-gawk
375  func_check_maintainerclean_vpath hello-pascal
376 #func_check_maintainerclean_vpath hello-ycp
377  func_check_maintainerclean_vpath hello-tcl
378  func_check_maintainerclean_vpath hello-tcl-tk
379  func_check_maintainerclean_vpath hello-perl
380  func_check_maintainerclean_vpath hello-php
381  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
382    echo "*** func_check_maintainerclean_vpath error: 'make' failures"
383    echo hello-*.log
384    exit 1
385  fi
386  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
387    echo "*** func_check_maintainerclean_vpath error: incomplete 'make maintainer-clean'"
388    echo hello-*.out
389    exit 1
390  fi
391}
392
393
394# func_check_dist sample
395# checks 'make dist' after 'configure; make'.
396func_check_dist ()
397{
398  sample="$1"
399  case "$sample" in
400    hello-objc-gnustep) ;;
401    *)
402      func_autogen "$sample"
403      if func_configure "$sample"; then
404        if (func_init "$sample"; cd "$sample" && make); then
405          if (func_init "$sample"; cd "$sample" && make dist) > "$sample.log" 2>&1; then
406            rm -f "$sample.log"
407            (func_init "$sample"; cd "$sample" && make distclean)
408            rm -f `find "$sample" -name '*~'` `find "$sample" -name '*.orig'`
409            rm -rf "$sample/autom4te.cache"
410            if test -f "$sample/$sample-0.tar.gz"; then
411              (cd "$sample" && tar xfz "$sample-0.tar.gz")
412              LC_ALL=C diff -r -q "$sample" "$sample/$sample-0" | grep -v "^Only in $sample: $sample-0$" | grep -v "^Only in $sample: $sample-0.tar.gz$" | grep -v "^Only in $sample: BUGS$" > "$sample.out"
413            else
414              echo "$sample-0.tar.gz was not created" > "$sample.out"
415            fi
416          fi
417          rm -rf "$sample/$sample-0"
418          rm -f "$sample/$sample-0.tar.gz"
419        fi
420      fi
421      func_configure "$sample"
422      func_maintainerclean "$sample"
423      func_autoclean "$sample"
424      if ! test -s "$sample.out"; then
425        rm -f "$sample.out"
426      fi
427      ;;
428  esac
429}
430
431func_check_dist_all ()
432{
433  rm -f hello-*.log hello-*.out
434  func_check_dist hello-c
435 #func_check_dist hello-c-gnome
436 #func_check_dist hello-c-gnome3
437  func_check_dist hello-c++
438 #func_check_dist hello-c++-qt
439 #func_check_dist hello-c++-kde
440 #func_check_dist hello-c++-gnome
441  func_check_dist hello-c++-wxwidgets
442  func_check_dist hello-objc
443  func_check_dist hello-objc-gnustep
444 #func_check_dist hello-objc-gnome
445  func_check_dist hello-sh
446  func_check_dist hello-python
447  func_check_dist hello-clisp
448  func_check_dist hello-librep
449  func_check_dist hello-guile
450  func_check_dist hello-smalltalk
451  func_check_dist hello-java
452  func_check_dist hello-java-awt
453  func_check_dist hello-java-swing
454 #func_check_dist hello-java-qtjambi
455  func_check_dist hello-csharp
456  func_check_dist hello-csharp-forms
457  func_check_dist hello-gawk
458  func_check_dist hello-pascal
459 #func_check_dist hello-ycp
460  func_check_dist hello-tcl
461  func_check_dist hello-tcl-tk
462  func_check_dist hello-perl
463  func_check_dist hello-php
464  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
465    echo "*** func_check_dist error: 'make dist' failures"
466    echo hello-*.log
467    exit 1
468  fi
469  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
470    echo "*** func_check_dist error: tarball created by 'make dist' does not contain the expected files"
471    echo hello-*.out
472    exit 1
473  fi
474}
475
476
477# func_check_dist_vpath sample
478# checks 'make dist' after 'configure; make' with a VPATH build
479func_check_dist_vpath ()
480{
481  sample="$1"
482  case "$sample" in
483    hello-objc-gnustep) ;;
484    *)
485      func_autogen "$sample"
486      if func_configure "$sample" build; then
487        if (func_init "$sample"; cd "$sample"/build && make); then
488          if (func_init "$sample"; cd "$sample"/build && make dist) > "$sample.log" 2>&1; then
489            rm -f "$sample.log"
490            (func_init "$sample"; cd "$sample"/build && make distclean)
491            rm -f `find "$sample" -name '*~'` `find "$sample" -name '*.orig'`
492            rm -rf "$sample/autom4te.cache"
493            if test -f "$sample/build/$sample-0.tar.gz"; then
494              (cd "$sample"/build && tar xfz "$sample-0.tar.gz")
495              # TODO: Remove stamp-po workaround after next release.
496              LC_ALL=C diff -r -q "$sample" "$sample/build/$sample-0" | grep -v "^Only in $sample: build$" | grep -v "^Only in $sample: BUGS$" | { if test -f "$sample"/po/Makevars; then grep -v "^Only in $sample/build/$sample-0/po: stamp-po$"; else cat; fi; } > "$sample.out"
497            else
498              echo "$sample-0.tar.gz was not created" > "$sample.out"
499            fi
500          fi
501          rm -rf "$sample/build/$sample-0"
502          rm -f "$sample/build/$sample-0.tar.gz"
503        fi
504      fi
505      rm -rf "$sample"/build
506      func_autoclean "$sample"
507      if ! test -s "$sample.out"; then
508        rm -f "$sample.out"
509      fi
510      ;;
511  esac
512}
513
514func_check_dist_vpath_all ()
515{
516  rm -f hello-*.log hello-*.out
517  func_check_dist_vpath hello-c
518 #func_check_dist_vpath hello-c-gnome
519 #func_check_dist_vpath hello-c-gnome3
520  func_check_dist_vpath hello-c++
521 #func_check_dist_vpath hello-c++-qt
522 #func_check_dist_vpath hello-c++-kde
523 #func_check_dist_vpath hello-c++-gnome
524  func_check_dist_vpath hello-c++-wxwidgets
525  func_check_dist_vpath hello-objc
526  func_check_dist_vpath hello-objc-gnustep
527 #func_check_dist_vpath hello-objc-gnome
528  func_check_dist_vpath hello-sh
529  func_check_dist_vpath hello-python
530  func_check_dist_vpath hello-clisp
531  func_check_dist_vpath hello-librep
532  func_check_dist_vpath hello-guile
533  func_check_dist_vpath hello-smalltalk
534  func_check_dist_vpath hello-java
535  func_check_dist_vpath hello-java-awt
536  func_check_dist_vpath hello-java-swing
537 #func_check_dist_vpath hello-java-qtjambi
538  func_check_dist_vpath hello-csharp
539  func_check_dist_vpath hello-csharp-forms
540  func_check_dist_vpath hello-gawk
541  func_check_dist_vpath hello-pascal
542 #func_check_dist_vpath hello-ycp
543  func_check_dist_vpath hello-tcl
544  func_check_dist_vpath hello-tcl-tk
545  func_check_dist_vpath hello-perl
546  func_check_dist_vpath hello-php
547  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
548    echo "*** func_check_dist_vpath error: 'make dist' failures"
549    echo hello-*.log
550    exit 1
551  fi
552  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
553    echo "*** func_check_dist_vpath error: tarball created by 'make dist' does not contain the expected files"
554    echo hello-*.out
555    exit 1
556  fi
557}
558
559
560# Base installation directory for all samples.
561instdir=/tmp/gtexinst
562
563# func_check_install sample
564# checks 'make install' after 'configure; make'.
565# You need to check afterwards whether the installed binaries work.
566func_check_install ()
567{
568  sample="$1"
569  case "$sample" in
570    hello-objc-gnustep)
571      # In this sample, you have to check the uninstalled binaries (see the INSTALL file).
572      ;;
573    *)
574      func_autogen "$sample"
575      if (cd "$sample" && ./configure --prefix="$instdir/$sample"); then
576        if (func_init "$sample"; cd "$sample" && make); then
577          if (func_init "$sample"; cd "$sample" && make install) > "$sample.log" 2>&1; then
578            rm -f "$sample.log"
579          fi
580        fi
581      fi
582      func_maintainerclean "$sample"
583      func_autoclean "$sample"
584      ;;
585  esac
586}
587
588func_check_install_all ()
589{
590  rm -f hello-*.log
591  rm -rf "$instdir/hello-*"
592  func_check_install hello-c
593 #func_check_install hello-c-gnome
594 #func_check_install hello-c-gnome3
595  func_check_install hello-c++
596 #func_check_install hello-c++-qt
597 #func_check_install hello-c++-kde
598 #func_check_install hello-c++-gnome
599  func_check_install hello-c++-wxwidgets
600  func_check_install hello-objc
601  func_check_install hello-objc-gnustep
602 #func_check_install hello-objc-gnome
603  func_check_install hello-sh
604  func_check_install hello-python
605  func_check_install hello-clisp
606  func_check_install hello-librep
607  func_check_install hello-guile
608  func_check_install hello-smalltalk
609  func_check_install hello-java
610  func_check_install hello-java-awt
611  func_check_install hello-java-swing
612 #func_check_install hello-java-qtjambi
613  func_check_install hello-csharp
614  func_check_install hello-csharp-forms
615  func_check_install hello-gawk
616  func_check_install hello-pascal
617 #func_check_install hello-ycp
618  func_check_install hello-tcl
619  func_check_install hello-tcl-tk
620  func_check_install hello-perl
621  func_check_install hello-php
622  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
623    echo "*** func_check_install error: 'make install' failures"
624    echo hello-*.log
625    exit 1
626  fi
627}
628
629
630# func_check_uninstall sample
631# checks 'make uninstall' after 'configure; make; make install'.
632func_check_uninstall ()
633{
634  sample="$1"
635  case "$sample" in
636    hello-objc-gnustep)
637      # In this sample, you have to check the uninstalled binaries (see the INSTALL file).
638      ;;
639    *)
640      func_autogen "$sample"
641      if (cd "$sample" && ./configure --prefix="$instdir/$sample"); then
642        if (func_init "$sample"; cd "$sample" && make); then
643          if (func_init "$sample"; cd "$sample" && make install); then
644            if (func_init "$sample"; cd "$sample" && make uninstall) > "$sample.log" 2>&1; then
645              rm -f "$sample.log"
646              (cd "$instdir" && find "$sample" -type f | LC_ALL=C sort) > "$sample.out"
647            fi
648          fi
649        fi
650      fi
651      func_maintainerclean "$sample"
652      func_autoclean "$sample"
653      if ! test -s "$sample.out"; then
654        rm -f "$sample.out"
655      fi
656      ;;
657  esac
658}
659
660func_check_uninstall_all ()
661{
662  rm -f hello-*.log hello-*.out
663  rm -rf "$instdir/hello-*"
664  func_check_uninstall hello-c
665 #func_check_uninstall hello-c-gnome
666 #func_check_uninstall hello-c-gnome3
667  func_check_uninstall hello-c++
668 #func_check_uninstall hello-c++-qt
669 #func_check_uninstall hello-c++-kde
670 #func_check_uninstall hello-c++-gnome
671  func_check_uninstall hello-c++-wxwidgets
672  func_check_uninstall hello-objc
673  func_check_uninstall hello-objc-gnustep
674 #func_check_uninstall hello-objc-gnome
675  func_check_uninstall hello-sh
676  func_check_uninstall hello-python
677  func_check_uninstall hello-clisp
678  func_check_uninstall hello-librep
679  func_check_uninstall hello-guile
680  func_check_uninstall hello-smalltalk
681  func_check_uninstall hello-java
682  func_check_uninstall hello-java-awt
683  func_check_uninstall hello-java-swing
684 #func_check_uninstall hello-java-qtjambi
685  func_check_uninstall hello-csharp
686  func_check_uninstall hello-csharp-forms
687  func_check_uninstall hello-gawk
688  func_check_uninstall hello-pascal
689 #func_check_uninstall hello-ycp
690  func_check_uninstall hello-tcl
691  func_check_uninstall hello-tcl-tk
692  func_check_uninstall hello-perl
693  func_check_uninstall hello-php
694  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
695    echo "*** func_check_uninstall error: 'make uninstall' failures"
696    echo hello-*.log
697    exit 1
698  fi
699  if (shopt -s failglob; echo hello-*.out) >/dev/null 2>/dev/null; then
700    echo "*** func_check_uninstall error: left-over files"
701    echo hello-*.out
702    exit 1
703  fi
704}
705
706
707# func_check_distcheck sample
708# checks 'make distcheck' after 'configure; make'.
709func_check_distcheck ()
710{
711  sample="$1"
712  case "$sample" in
713    hello-objc-gnustep) ;;
714    *)
715      func_autogen "$sample"
716      if func_configure "$sample"; then
717        if (func_init "$sample"; cd "$sample" && make); then
718          if (func_init "$sample"; cd "$sample" && make distcheck) > "$sample.log" 2>&1; then
719            rm -f "$sample.log"
720          fi
721          if test -d "$sample/$sample-0"; then chmod -R u+w "$sample/$sample-0"; fi
722          rm -rf "$sample/$sample-0"
723          rm -f "$sample/$sample-0.tar.gz"
724        fi
725      fi
726      func_maintainerclean "$sample"
727      func_autoclean "$sample"
728      if ! test -s "$sample.out"; then
729        rm -f "$sample.out"
730      fi
731      ;;
732  esac
733}
734
735func_check_distcheck_all ()
736{
737  rm -f hello-*.log
738  func_check_distcheck hello-c
739 #func_check_distcheck hello-c-gnome
740 #func_check_distcheck hello-c-gnome3
741  func_check_distcheck hello-c++
742 #func_check_distcheck hello-c++-qt
743 #func_check_distcheck hello-c++-kde
744 #func_check_distcheck hello-c++-gnome
745  func_check_distcheck hello-c++-wxwidgets
746  func_check_distcheck hello-objc
747  func_check_distcheck hello-objc-gnustep
748 #func_check_distcheck hello-objc-gnome
749  func_check_distcheck hello-sh
750  func_check_distcheck hello-python
751  func_check_distcheck hello-clisp
752  func_check_distcheck hello-librep
753  func_check_distcheck hello-guile
754  func_check_distcheck hello-smalltalk
755  func_check_distcheck hello-java
756  func_check_distcheck hello-java-awt
757  func_check_distcheck hello-java-swing
758 #func_check_distcheck hello-java-qtjambi
759  func_check_distcheck hello-csharp
760  func_check_distcheck hello-csharp-forms
761  func_check_distcheck hello-gawk
762  func_check_distcheck hello-pascal
763 #func_check_distcheck hello-ycp
764  func_check_distcheck hello-tcl
765  func_check_distcheck hello-tcl-tk
766  func_check_distcheck hello-perl
767  func_check_distcheck hello-php
768  if (shopt -s failglob; echo hello-*log) >/dev/null 2>/dev/null; then
769    echo "*** func_check_distcheck error: 'make distcheck' failures"
770    echo hello-*.log
771    exit 1
772  fi
773}
774
775
776# If you want to extend this script:
777
778# A dummy check function.
779func_check ()
780{
781  :
782}
783
784# Complete list of samples.
785func_check_all ()
786{
787  func_check hello-c
788  func_check hello-c-gnome
789  func_check hello-c-gnome3
790  func_check hello-c++
791  func_check hello-c++-qt
792  func_check hello-c++-kde
793  func_check hello-c++-gnome
794  func_check hello-c++-wxwidgets
795  func_check hello-objc
796  func_check hello-objc-gnustep
797  func_check hello-objc-gnome
798  func_check hello-sh
799  func_check hello-python
800  func_check hello-clisp
801  func_check hello-librep
802  func_check hello-guile
803  func_check hello-smalltalk
804  func_check hello-java
805  func_check hello-java-awt
806  func_check hello-java-swing
807  func_check hello-java-qtjambi
808  func_check hello-csharp
809  func_check hello-csharp-forms
810  func_check hello-gawk
811  func_check hello-pascal
812  func_check hello-ycp
813  func_check hello-tcl
814  func_check hello-tcl-tk
815  func_check hello-perl
816  func_check hello-php
817}
818
819
820# Top-level code.
821
822func_check_autoclean_all
823func_check_distclean_all
824func_check_maintainerclean_all
825func_check_maintainerclean_vpath_all
826func_check_dist_all
827func_check_dist_vpath_all
828func_check_install_all
829func_check_uninstall_all
830func_check_distcheck_all
831