cond8.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #! /bin/sh
  2. # Copyright (C) 1999-2017 Free Software Foundation, Inc.
  3. #
  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)
  7. # any later version.
  8. #
  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.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test to make sure _PROGRAMS conditionals can be written in a useful
  17. # way.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_CC
  21. AM_CONDITIONAL([X], [test "$x" = yes])
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. if X
  26. bin_PROGRAMS = x y
  27. else
  28. noinst_PROGRAMS = x y
  29. endif
  30. .PHONY: get-built get-install not-install
  31. get-built:
  32. test -f x.$(OBJEXT)
  33. test -f y.$(OBJEXT)
  34. test -f x$(EXEEXT)
  35. test -f y$(EXEEXT)
  36. get-installed:
  37. test -f $(bindir)/x$(EXEEXT)
  38. test -f $(bindir)/y$(EXEEXT)
  39. not-installed:
  40. if find $(prefix) -type f | grep .; then exit 1; else :; fi
  41. END
  42. $ACLOCAL
  43. $AUTOMAKE
  44. $AUTOCONF
  45. cat > x.c <<'END'
  46. int main (void)
  47. {
  48. return 0;
  49. }
  50. END
  51. cp x.c y.c
  52. instdir=$(pwd)/_inst || fatal_ "cannot get current directory"
  53. # Skip the rest of the test in case of e.g. missing C compiler.
  54. ./configure --prefix="$instdir" x=yes || exit $?
  55. $MAKE install
  56. $MAKE get-built
  57. $MAKE get-installed
  58. $MAKE distclean
  59. rm -rf _inst
  60. ./configure --prefix="$instdir" x=no
  61. $MAKE install
  62. $MAKE get-built
  63. $MAKE not-installed
  64. :