Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_c_declare_block.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_C_DECLARE_BLOCK
  8. #
  9. # DESCRIPTION
  10. #
  11. # The macro will compile a test program to see whether the compiler does
  12. # allow new variable declarations in the middle of a C statement block,
  13. # i.e. after some non-declaration line. New compilers will allow that
  14. # which makes the behave a bit more like C++ - the gcc did support it for
  15. # quite a time already.
  16. #
  17. # #define DECLARE_BLOCK_NEEDED says they need to be at the beginning of of
  18. # a statement block. Additionally two defines DECLARE_BLOCK { and
  19. # DECLARE_END } are being set. That makes it possible to do the following
  20. # in your source code (which this macro is really made up for):
  21. #
  22. # #define ___ DECLARE_BLOCK
  23. # #define ____ DECLARE_END
  24. #
  25. # int f() {
  26. # char buffer[1024];
  27. # fgets(buffer, 1024, stdin);
  28. # ___ int i; int ii = strlen(buffer);
  29. # for (i=0; i < ii; i++) {
  30. # fputc(buffer[i], stdout);
  31. # }____;
  32. # }
  33. #
  34. # LICENSE
  35. #
  36. # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  37. #
  38. # This program is free software; you can redistribute it and/or modify it
  39. # under the terms of the GNU General Public License as published by the
  40. # Free Software Foundation; either version 3 of the License, or (at your
  41. # option) any later version.
  42. #
  43. # This program is distributed in the hope that it will be useful, but
  44. # WITHOUT ANY WARRANTY; without even the implied warranty of
  45. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  46. # Public License for more details.
  47. #
  48. # You should have received a copy of the GNU General Public License along
  49. # with this program. If not, see <https://www.gnu.org/licenses/>.
  50. #
  51. # As a special exception, the respective Autoconf Macro's copyright owner
  52. # gives unlimited permission to copy, distribute and modify the configure
  53. # scripts that are the output of Autoconf when processing the Macro. You
  54. # need not follow the terms of the GNU General Public License when using
  55. # or distributing such scripts, even though portions of the text of the
  56. # Macro appear in them. The GNU General Public License (GPL) does govern
  57. # all other use of the material that constitutes the Autoconf Macro.
  58. #
  59. # This special exception to the GPL applies to versions of the Autoconf
  60. # Macro released by the Autoconf Archive. When you make and distribute a
  61. # modified version of the Autoconf Macro, you may extend this special
  62. # exception to the GPL to apply to your modified version as well.
  63. #serial 10
  64. AC_DEFUN([AX_C_DECLARE_BLOCK],[dnl
  65. AC_CACHE_CHECK(
  66. [if C variables must be declared at the beginning of a block],
  67. ax_cv_c_declare_block,[
  68. AC_TRY_COMPILE([#include <stdio.h>
  69. int f() {
  70. char buffer[1024];
  71. fgets(buffer, 1024, stdin);
  72. int i; int ii = strlen(buffer);
  73. for (i=0; i < ii; i++) {
  74. fputc(buffer[i], stdout);
  75. }
  76. }],
  77. [],
  78. ax_cv_c_declare_block=no, ax_cv_c_declare_block=yes)])
  79. if test "$ax_cv_c_declare_block" = yes; then
  80. AC_DEFINE([DECLARE_BLOCK_NEEDED],[1],
  81. [if C variables must be declared at the beginning of a block])
  82. AC_DEFINE([DECLARE_BLOCK],[{],
  83. [set to { if variable declarations need a block start before])
  84. AC_DEFINE([DECLARE_END],[}],
  85. [set to } if variable declarations need a block start before])
  86. fi
  87. ])