4
0

stdio_h.m4 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # stdio_h.m4 serial 44
  2. dnl Copyright (C) 2007-2015 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. AC_DEFUN([gl_STDIO_H],
  7. [
  8. dnl For __USE_MINGW_ANSI_STDIO
  9. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  10. AC_REQUIRE([gl_STDIO_H_DEFAULTS])
  11. gl_NEXT_HEADERS([stdio.h])
  12. dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
  13. dnl inttypes.h behave like gnu instead of system; we must give our
  14. dnl printf wrapper the right attribute to match.
  15. AC_CACHE_CHECK([whether inttypes macros match system or gnu printf],
  16. [gl_cv_func_printf_attribute_flavor],
  17. [AC_EGREP_CPP([findme .(ll|j)d. findme],
  18. [#define __STDC_FORMAT_MACROS 1
  19. #include <stdio.h>
  20. #include <inttypes.h>
  21. findme PRIdMAX findme
  22. ], [gl_cv_func_printf_attribute_flavor=gnu],
  23. [gl_cv_func_printf_attribute_flavor=system])])
  24. if test "$gl_cv_func_printf_attribute_flavor" = gnu; then
  25. AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1],
  26. [Define to 1 if printf and friends should be labeled with
  27. attribute "__gnu_printf__" instead of "__printf__"])
  28. fi
  29. dnl No need to create extra modules for these functions. Everyone who uses
  30. dnl <stdio.h> likely needs them.
  31. GNULIB_FSCANF=1
  32. gl_MODULE_INDICATOR([fscanf])
  33. GNULIB_SCANF=1
  34. gl_MODULE_INDICATOR([scanf])
  35. GNULIB_FGETC=1
  36. GNULIB_GETC=1
  37. GNULIB_GETCHAR=1
  38. GNULIB_FGETS=1
  39. GNULIB_FREAD=1
  40. dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c"
  41. dnl "expected source file, required through AC_LIBSOURCES, not found". It is
  42. dnl also an optimization, to avoid performing a configure check whose result
  43. dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
  44. dnl or GNULIB_NONBLOCKING redundant.
  45. m4_ifdef([gl_NONBLOCKING_IO], [
  46. gl_NONBLOCKING_IO
  47. if test $gl_cv_have_nonblocking != yes; then
  48. REPLACE_STDIO_READ_FUNCS=1
  49. AC_LIBOBJ([stdio-read])
  50. fi
  51. ])
  52. dnl No need to create extra modules for these functions. Everyone who uses
  53. dnl <stdio.h> likely needs them.
  54. GNULIB_FPRINTF=1
  55. GNULIB_PRINTF=1
  56. GNULIB_VFPRINTF=1
  57. GNULIB_VPRINTF=1
  58. GNULIB_FPUTC=1
  59. GNULIB_PUTC=1
  60. GNULIB_PUTCHAR=1
  61. GNULIB_FPUTS=1
  62. GNULIB_PUTS=1
  63. GNULIB_FWRITE=1
  64. dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
  65. dnl "expected source file, required through AC_LIBSOURCES, not found". It is
  66. dnl also an optimization, to avoid performing a configure check whose result
  67. dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
  68. dnl GNULIB_SIGPIPE redundant.
  69. m4_ifdef([gl_SIGNAL_SIGPIPE], [
  70. gl_SIGNAL_SIGPIPE
  71. if test $gl_cv_header_signal_h_SIGPIPE != yes; then
  72. REPLACE_STDIO_WRITE_FUNCS=1
  73. AC_LIBOBJ([stdio-write])
  74. fi
  75. ])
  76. dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
  77. dnl "expected source file, required through AC_LIBSOURCES, not found". It is
  78. dnl also an optimization, to avoid performing a configure check whose result
  79. dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
  80. dnl or GNULIB_NONBLOCKING redundant.
  81. m4_ifdef([gl_NONBLOCKING_IO], [
  82. gl_NONBLOCKING_IO
  83. if test $gl_cv_have_nonblocking != yes; then
  84. REPLACE_STDIO_WRITE_FUNCS=1
  85. AC_LIBOBJ([stdio-write])
  86. fi
  87. ])
  88. dnl Check for declarations of anything we want to poison if the
  89. dnl corresponding gnulib module is not in use, and which is not
  90. dnl guaranteed by both C89 and C11.
  91. gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
  92. ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
  93. renameat snprintf tmpfile vdprintf vsnprintf])
  94. ])
  95. AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
  96. [
  97. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  98. AC_REQUIRE([gl_STDIO_H_DEFAULTS])
  99. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  100. dnl Define it also as a C macro, for the benefit of the unit tests.
  101. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  102. ])
  103. AC_DEFUN([gl_STDIO_H_DEFAULTS],
  104. [
  105. GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF])
  106. GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
  107. GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN])
  108. GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
  109. GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC])
  110. GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS])
  111. GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
  112. GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
  113. GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
  114. GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE])
  115. GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
  116. GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
  117. GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD])
  118. GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
  119. GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF])
  120. GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
  121. GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
  122. GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
  123. GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
  124. GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
  125. GNULIB_GETC=0; AC_SUBST([GNULIB_GETC])
  126. GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR])
  127. GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
  128. GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
  129. GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
  130. GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
  131. GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE])
  132. GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
  133. GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN])
  134. GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
  135. GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX])
  136. GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC])
  137. GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR])
  138. GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS])
  139. GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE])
  140. GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME])
  141. GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT])
  142. GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF])
  143. GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
  144. GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
  145. GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
  146. GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
  147. GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
  148. GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
  149. GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF])
  150. GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF])
  151. GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
  152. GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
  153. GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
  154. GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF])
  155. GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
  156. GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
  157. GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
  158. dnl Assume proper GNU behavior unless another module says otherwise.
  159. HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE])
  160. HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO])
  161. HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
  162. HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM])
  163. HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE])
  164. HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
  165. HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
  166. HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
  167. HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
  168. HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
  169. HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
  170. HAVE_PCLOSE=1; AC_SUBST([HAVE_PCLOSE])
  171. HAVE_POPEN=1; AC_SUBST([HAVE_POPEN])
  172. HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
  173. HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
  174. HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
  175. REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF])
  176. REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE])
  177. REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN])
  178. REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
  179. REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
  180. REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
  181. REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE])
  182. REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
  183. REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK])
  184. REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO])
  185. REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL])
  186. REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO])
  187. REPLACE_GETDELIM=0; AC_SUBST([REPLACE_GETDELIM])
  188. REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE])
  189. REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF])
  190. REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR])
  191. REPLACE_POPEN=0; AC_SUBST([REPLACE_POPEN])
  192. REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF])
  193. REPLACE_REMOVE=0; AC_SUBST([REPLACE_REMOVE])
  194. REPLACE_RENAME=0; AC_SUBST([REPLACE_RENAME])
  195. REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT])
  196. REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
  197. REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
  198. REPLACE_STDIO_READ_FUNCS=0; AC_SUBST([REPLACE_STDIO_READ_FUNCS])
  199. REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
  200. REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE])
  201. REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
  202. REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF])
  203. REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
  204. REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF])
  205. REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF])
  206. REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
  207. ])