Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. # Copyright (C) 1991-2026 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, see
  13. # <https://www.gnu.org/licenses/>.
  14. #
  15. # Sub-makefile for misc portion of the library.
  16. #
  17. subdir := misc
  18. include ../Makeconfig
  19. headers := \
  20. a.out.h \
  21. ar.h \
  22. bits/err-ldbl.h \
  23. bits/error-ldbl.h \
  24. bits/error.h \
  25. bits/hwcap.h \
  26. bits/ioctl-types.h \
  27. bits/ioctls.h \
  28. bits/mman.h \
  29. bits/param.h \
  30. bits/select-decl.h \
  31. bits/select.h \
  32. bits/select2.h \
  33. bits/stab.def \
  34. bits/syslog-decl.h \
  35. bits/syslog-ldbl.h \
  36. bits/syslog-path.h \
  37. bits/syslog.h \
  38. bits/sysmacros.h \
  39. bits/types/struct_iovec.h \
  40. bits/uio-ext.h \
  41. bits/uio_lim.h \
  42. err.h \
  43. error.h \
  44. fstab.h \
  45. libgen.h \
  46. mntent.h \
  47. paths.h \
  48. regexp.h \
  49. search.h \
  50. sgtty.h \
  51. stab.h \
  52. sys/auxv.h \
  53. sys/cdefs.h \
  54. sys/dir.h \
  55. sys/file.h \
  56. sys/ioctl.h \
  57. sys/mman.h \
  58. sys/param.h \
  59. sys/ptrace.h \
  60. sys/queue.h \
  61. sys/reboot.h \
  62. sys/select.h \
  63. sys/single_threaded.h \
  64. sys/swap.h \
  65. sys/syscall.h \
  66. sys/sysinfo.h \
  67. sys/syslog.h \
  68. sys/sysmacros.h \
  69. sys/uio.h \
  70. sys/xattr.h \
  71. syscall.h \
  72. sysexits.h \
  73. syslog.h \
  74. ttyent.h \
  75. # headers
  76. routines := \
  77. acct \
  78. allocate_once \
  79. atomic_wide_counter \
  80. brk \
  81. chflags \
  82. chroot \
  83. daemon \
  84. dirname \
  85. efgcvt \
  86. efgcvt_r \
  87. err \
  88. error \
  89. fchflags \
  90. fd_to_filename \
  91. fdatasync \
  92. fgetxattr \
  93. flistxattr \
  94. fremovexattr \
  95. fsetxattr \
  96. fstab \
  97. fsync \
  98. ftruncate \
  99. ftruncate64 \
  100. futimes \
  101. futimesat \
  102. getauxval \
  103. getclktck \
  104. getdomain \
  105. getdtsz \
  106. gethostid \
  107. gethostname \
  108. getloadavg \
  109. getpagesize \
  110. getpass \
  111. getsysstats \
  112. getttyent \
  113. getusershell \
  114. getxattr \
  115. gtty \
  116. hsearch \
  117. hsearch_r \
  118. ifunc-impl-list \
  119. insremque \
  120. ioctl \
  121. lgetxattr \
  122. listxattr \
  123. llistxattr \
  124. lremovexattr \
  125. lsearch \
  126. lsetxattr \
  127. lutimes \
  128. madvise \
  129. makedev \
  130. mincore \
  131. mkdtemp \
  132. mkostemp \
  133. mkostemp64 \
  134. mkostemps \
  135. mkostemps64 \
  136. mkstemp \
  137. mkstemp64 \
  138. mkstemps \
  139. mkstemps64 \
  140. mktemp \
  141. mlock \
  142. mlockall \
  143. mmap \
  144. mmap64 \
  145. mntent \
  146. mntent_r \
  147. mprotect \
  148. msync \
  149. munlock \
  150. munlockall \
  151. munmap \
  152. preadv \
  153. preadv2 \
  154. preadv64 \
  155. preadv64v2 \
  156. pselect \
  157. ptrace \
  158. pwritev \
  159. pwritev2 \
  160. pwritev64 \
  161. pwritev64v2 \
  162. qefgcvt \
  163. qefgcvt_r \
  164. readv \
  165. reboot \
  166. regexp \
  167. remap_file_pages \
  168. removexattr \
  169. revoke \
  170. sbrk \
  171. select \
  172. setdomain \
  173. setegid \
  174. seteuid \
  175. sethostid \
  176. sethostname \
  177. setregid \
  178. setreuid \
  179. setxattr \
  180. single_threaded \
  181. sstk \
  182. stty \
  183. swapoff \
  184. swapon \
  185. sync \
  186. syncfs \
  187. syscall \
  188. syslog \
  189. truncate \
  190. truncate64 \
  191. tsearch \
  192. ttyslot \
  193. ualarm \
  194. unwind-link \
  195. usleep \
  196. ustat \
  197. utimes \
  198. vhangup \
  199. writev \
  200. # routines
  201. # Exclude fortified routines from being built with _FORTIFY_SOURCE
  202. routines_no_fortify += \
  203. getdomain \
  204. gethostname \
  205. syslog \
  206. # routines_no_fortify
  207. ifeq ($(run-built-tests),yes)
  208. ifeq (yes,$(build-shared))
  209. ifneq ($(PERL),no)
  210. generated += \
  211. tst-allocate_once-mem.out \
  212. tst-allocate_once.mtrace \
  213. tst-error1-mem.out \
  214. tst-error1.mtrace \
  215. # generated
  216. endif
  217. endif
  218. endif
  219. aux := init-misc
  220. install-lib := libg.a
  221. gpl2lgpl := \
  222. error.c \
  223. error.h \
  224. # gpl2lgpl
  225. tests := \
  226. bug-hsearch1 \
  227. bug18240 \
  228. tst-dbl-efgcvt \
  229. tst-dirname \
  230. tst-empty \
  231. tst-error1 \
  232. tst-fdset \
  233. tst-hsearch \
  234. tst-insremque \
  235. tst-ioctl \
  236. tst-ldbl-efgcvt \
  237. tst-ldbl-error \
  238. tst-ldbl-errorfptr \
  239. tst-ldbl-warn \
  240. tst-makedev \
  241. tst-mntent \
  242. tst-mntent-autofs \
  243. tst-mntent-blank-corrupt \
  244. tst-mntent-blank-passno \
  245. tst-mntent-escape \
  246. tst-mntent2 \
  247. tst-mremap1 \
  248. tst-mremap2 \
  249. tst-preadvwritev \
  250. tst-preadvwritev2 \
  251. tst-preadvwritev64 \
  252. tst-preadvwritev64v2 \
  253. tst-pselect \
  254. tst-select \
  255. tst-syscalls \
  256. tst-tsearch \
  257. tst-warn-wide \
  258. # tests
  259. tests-time64 := \
  260. tst-ioctl-time64 \
  261. tst-pselect-time64 \
  262. tst-select-time64 \
  263. # tests-time64
  264. # Tests which need libdl.
  265. ifeq (yes,$(build-shared))
  266. tests += tst-gethostid
  267. endif
  268. tests-internal := \
  269. tst-allocate_once \
  270. tst-atomic \
  271. tst-atomic-long \
  272. # tests-internal
  273. tests-static := tst-empty
  274. # Test for the internal, non-exported __fd_to_filename function.
  275. tests-internal += tst-fd_to_filename
  276. tests-static += tst-fd_to_filename
  277. # Tests with long run times.
  278. xtests += \
  279. tst-mkstemp-fuse \
  280. tst-mkstemp-fuse-parallel \
  281. # xtests
  282. ifeq ($(run-built-tests),yes)
  283. ifeq (yes,$(build-shared))
  284. ifneq ($(PERL),no)
  285. tests-special += \
  286. $(objpfx)tst-allocate_once-mem.out \
  287. $(objpfx)tst-error1-mem.out \
  288. # tests-special
  289. endif
  290. endif
  291. endif
  292. tests-container := \
  293. tst-syslog \
  294. tst-syslog-long-progname \
  295. # tests-container
  296. CFLAGS-select.c += -fexceptions -fasynchronous-unwind-tables
  297. CFLAGS-tsearch.c += $(uses-callbacks)
  298. CFLAGS-lsearch.c += $(uses-callbacks)
  299. CFLAGS-pselect.c += -fexceptions
  300. CFLAGS-readv.c += -fexceptions -fasynchronous-unwind-tables
  301. CFLAGS-writev.c += -fexceptions -fasynchronous-unwind-tables
  302. CFLAGS-preadv.c += -fexceptions -fasynchronous-unwind-tables
  303. CFLAGS-preadv64.c += -fexceptions -fasynchronous-unwind-tables
  304. CFLAGS-pwritev.c += -fexceptions -fasynchronous-unwind-tables
  305. CFLAGS-pwritev64.c += -fexceptions -fasynchronous-unwind-tables
  306. CFLAGS-preadv2.c += -fexceptions -fasynchronous-unwind-tables
  307. CFLAGS-preadv64v2.c += -fexceptions -fasynchronous-unwind-tables
  308. CFLAGS-pwritev2.c += -fexceptions -fasynchronous-unwind-tables
  309. CFLAGS-pwritev64v2.c += -fexceptions -fasynchronous-unwind-tables
  310. CFLAGS-usleep.c += -fexceptions
  311. CFLAGS-syslog.c += -fexceptions
  312. CFLAGS-error.c += -fexceptions
  313. CFLAGS-getpass.c += -fexceptions
  314. CFLAGS-mkstemp.c += -fexceptions
  315. CFLAGS-mkstemp64.c += -fexceptions
  316. CFLAGS-getsysstats.c += -fexceptions
  317. CFLAGS-getusershell.c += -fexceptions
  318. CFLAGS-err.c += -fexceptions
  319. CFLAGS-tst-tsearch.c += $(stack-align-test-flags)
  320. CFLAGS-msync.c += -fexceptions -fasynchronous-unwind-tables
  321. CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables
  322. CFLAGS-fsync.c += -fexceptions -fasynchronous-unwind-tables
  323. # Called during static library initialization, so turn stack-protection
  324. # off for non-shared builds.
  325. CFLAGS-sbrk.o = $(no-stack-protector)
  326. CFLAGS-sbrk.op = $(no-stack-protector)
  327. CFLAGS-brk.o = $(no-stack-protector)
  328. CFLAGS-brk.op = $(no-stack-protector)
  329. CFLAGS-mmap.o = $(no-stack-protector)
  330. CFLAGS-mmap.op = $(no-stack-protector)
  331. CFLAGS-mmap64.o = $(no-stack-protector)
  332. CFLAGS-mmap64.op = $(no-stack-protector)
  333. include ../Rules
  334. $(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
  335. $(objpfx)tst-tsearch: $(libm)
  336. tst-error1-ENV = MALLOC_TRACE=$(objpfx)tst-error1.mtrace \
  337. LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
  338. tst-error1-ARGS = $(objpfx)tst-error1.out
  339. $(objpfx)tst-error1-mem.out: $(objpfx)tst-error1.out
  340. $(common-objpfx)malloc/mtrace $(objpfx)tst-error1.mtrace > $@; \
  341. $(evaluate-test)
  342. tst-allocate_once-ENV = MALLOC_TRACE=$(objpfx)tst-allocate_once.mtrace \
  343. LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
  344. $(objpfx)tst-allocate_once-mem.out: $(objpfx)tst-allocate_once.out
  345. $(common-objpfx)malloc/mtrace $(objpfx)tst-allocate_once.mtrace > $@; \
  346. $(evaluate-test)
  347. tst-syslog-long-progname-ENV = GLIBC_TUNABLES=glibc.malloc.check=3 \
  348. LD_PRELOAD=libc_malloc_debug.so.0
  349. $(objpfx)tst-select: $(librt)
  350. $(objpfx)tst-select-time64: $(librt)
  351. $(objpfx)tst-pselect: $(librt)
  352. $(objpfx)tst-pselect-time64: $(librt)
  353. $(objpfx)tst-mkstemp-fuse-parallel: $(shared-thread-library)