elf: Add #include <sys/param.h> for MAX usage.
[glibc.git] / stdlib / Makefile
blob60fc59c12c4c8aed9092650169340b110d6f7cab
1 # Copyright (C) 1991-2022 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # The GNU C Library 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 GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
19 # Makefile for stdlib routines
21 subdir := stdlib
23 include ../Makeconfig
25 headers := \
26 alloca.h \
27 bits/errno.h \
28 bits/indirect-return.h \
29 bits/monetary-ldbl.h \
30 bits/stdint-intn.h \
31 bits/stdint-uintn.h \
32 bits/stdlib-bsearch.h \
33 bits/stdlib-float.h \
34 bits/stdlib.h \
35 bits/stdlib-ldbl.h \
36 bits/time64.h \
37 bits/timesize.h \
38 bits/types/error_t.h \
39 bits/wordsize.h \
40 errno.h \
41 fmtmsg.h \
42 inttypes.h \
43 monetary.h \
44 stdint.h \
45 stdlib.h \
46 sys/errno.h \
47 sys/random.h \
48 sys/ucontext.h \
49 ucontext.h \
50 # headers
52 routines := \
53 a64l \
54 abort \
55 abs \
56 at_quick_exit \
57 atof \
58 atoi \
59 atol\
60 atoll \
61 bsearch \
62 canonicalize \
63 cxa_at_quick_exit \
64 cxa_atexit \
65 cxa_finalize \
66 cxa_thread_atexit_impl \
67 div \
68 drand48 \
69 drand48-iter \
70 drand48_r \
71 erand48 \
72 erand48_r \
73 exit \
74 fmtmsg \
75 getcontext \
76 getentropy \
77 getenv \
78 getrandom \
79 getsubopt \
80 jrand48 \
81 jrand48_r \
82 l64a \
83 labs \
84 lcong48 \
85 lcong48_r \
86 ldiv \
87 llabs \
88 lldiv \
89 lrand48 \
90 lrand48_r \
91 makecontext \
92 mblen \
93 mbstowcs \
94 mbtowc \
95 mrand48 \
96 mrand48_r \
97 msort \
98 nrand48 \
99 nrand48_r \
100 old_atexit \
101 on_exit atexit \
102 putenv \
103 qsort \
104 quick_exit \
105 rand \
106 rand_r \
107 random \
108 random_r \
109 rpmatch \
110 secure-getenv \
111 seed48 \
112 seed48_r \
113 setcontext \
114 setenv \
115 srand48 \
116 srand48_r \
117 strfmon \
118 strfmon_l \
119 strfromd \
120 strfromf \
121 strfroml \
122 strtod \
123 strtod_l \
124 strtod_nan \
125 strtof \
126 strtof_l \
127 strtof_nan \
128 strtol \
129 strtol_l \
130 strtold \
131 strtold_l \
132 strtold_nan \
133 strtoll \
134 strtoll_l \
135 strtoul \
136 strtoul_l \
137 strtoull \
138 strtoull_l \
139 swapcontext \
140 system \
141 wcstombs \
142 wctomb \
143 xpg_basename \
144 # routines
146 aux = \
147 grouping \
148 groupingwc \
149 tens_in_limb \
150 # aux
152 # These routines will be omitted from the libc shared object.
153 # Instead the static object files will be included in a special archive
154 # linked against when the shared library will be used.
155 static-only-routines = \
156 atexit \
157 at_quick_exit \
158 # static-only-routines
160 test-srcs := \
161 tst-fmtmsg \
162 #test-srcs
164 tests := \
165 bug-fmtmsg1 \
166 bug-getcontext \
167 bug-strtod \
168 bug-strtod2 \
169 test-a64l \
170 test-at_quick_exit-race \
171 test-atexit-race \
172 test-bz22786 \
173 test-canon \
174 test-canon2 \
175 test-cxa_atexit-race \
176 test-cxa_atexit-race2 \
177 test-dlclose-exit-race \
178 test-on_exit-race \
179 testdiv \
180 testmb \
181 testmb2 \
182 testrand \
183 testsort \
184 tst-at_quick_exit \
185 tst-atexit \
186 tst-atof1 \
187 tst-atof2 \
188 tst-bsearch \
189 tst-bz20544 \
190 tst-canon-bz26341 \
191 tst-cxa_atexit \
192 tst-environ \
193 tst-getrandom \
194 tst-limits \
195 tst-makecontext \
196 tst-makecontext-align \
197 tst-makecontext2 \
198 tst-makecontext3 \
199 tst-on_exit \
200 tst-qsort \
201 tst-qsort2 \
202 tst-quick_exit \
203 tst-rand48 \
204 tst-rand48-2 \
205 tst-random \
206 tst-random2 \
207 tst-realpath \
208 tst-realpath-toolong \
209 tst-secure-getenv \
210 tst-setcontext \
211 tst-setcontext2 \
212 tst-setcontext3 \
213 tst-setcontext4 \
214 tst-setcontext5 \
215 tst-setcontext6 \
216 tst-setcontext7 \
217 tst-setcontext8 \
218 tst-setcontext9 \
219 tst-strfmon_l \
220 tst-strfrom \
221 tst-strfrom-locale \
222 tst-strtod \
223 tst-strtod-nan-locale \
224 tst-strtod-nan-sign \
225 tst-strtod-overflow \
226 tst-strtod-round \
227 tst-strtod-underflow \
228 tst-strtod2 \
229 tst-strtod5 \
230 tst-strtod6 \
231 tst-strtol \
232 tst-strtol-locale \
233 tst-strtoll \
234 tst-swapcontext1 \
235 tst-thread-quick_exit \
236 tst-tininess \
237 tst-unsetenv1 \
238 tst-width \
239 tst-width-stdint \
240 tst-xpg-basename \
241 # tests
243 tests-internal := \
244 tst-strtod1i \
245 tst-strtod3 \
246 tst-strtod4 \
247 tst-strtod5i \
248 tst-tls-atexit \
249 tst-tls-atexit-nodelete \
250 # tests-internal
252 tests-static := \
253 tst-secure-getenv \
254 # tests-static
256 tests-container := \
257 tst-system \
258 #tests-container
260 ifeq ($(build-hardcoded-path-in-tests),yes)
261 tests += \
262 tst-empty-env \
263 # tests
264 endif
266 LDLIBS-test-atexit-race = $(shared-thread-library)
267 LDLIBS-test-at_quick_exit-race = $(shared-thread-library)
268 LDLIBS-test-cxa_atexit-race = $(shared-thread-library)
269 LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library)
270 LDLIBS-test-on_exit-race = $(shared-thread-library)
271 LDLIBS-tst-canon-bz26341 = $(shared-thread-library)
273 LDLIBS-test-dlclose-exit-race = $(shared-thread-library)
274 LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic)
275 LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library)
277 ifeq ($(have-cxx-thread_local),yes)
278 CFLAGS-tst-quick_exit.o = -std=c++11
279 LDLIBS-tst-quick_exit = -lstdc++
280 CFLAGS-tst-thread-quick_exit.o = -std=c++11
281 LDLIBS-tst-thread-quick_exit = -lstdc++
282 $(objpfx)tst-thread-quick_exit: $(shared-thread-library)
283 else
284 tests-unsupported += \
285 tst-quick_exit \
286 tst-thread-quick_exit \
287 # tests-unsupported
288 endif
290 modules-names = \
291 test-dlclose-exit-race-helper \
292 tst-tls-atexit-lib \
293 # modules-names
294 extra-test-objs += $(addsuffix .os, $(modules-names))
296 ifeq ($(build-shared),yes)
297 tests += \
298 tst-putenv \
299 # tests
300 endif
302 # Several mpn functions from GNU MP are used by the strtod function.
303 mpn-routines := \
304 add_n \
305 addmul_1 \
306 cmp \
307 divmod_1 \
308 divrem \
309 inlines \
310 lshift \
311 mod_1 \
312 mul \
313 mul_1 \
314 mul_n \
315 rshift \
316 sub_n \
317 submul_1 \
318 udiv_qrnnd \
319 # mpn-routines
320 mpn-headers = \
321 asm-syntax.h \
322 gmp-impl.h \
323 gmp-mparam.h \
324 gmp.h \
325 longlong.h \
326 # mpn-headers
328 routines := \
329 $(strip $(routines) $(mpn-routines)) \
330 dbl2mpn \
331 ldbl2mpn \
332 mpn2dbl \
333 mpn2flt \
334 mpn2ldbl \
335 # routines
336 aux += \
337 fpioconst \
338 mp_clz_tab \
339 # aux
341 tests-extras += \
342 tst-putenvmod \
343 # tests-extras
345 extra-test-objs += \
346 tst-putenvmod.os \
347 # extra-test-objs
349 generated += \
350 isomac \
351 isomac.out \
352 tst-putenvmod.so \
353 # generated
355 CFLAGS-bsearch.c += $(uses-callbacks)
356 CFLAGS-msort.c += $(uses-callbacks)
357 CFLAGS-qsort.c += $(uses-callbacks)
358 CFLAGS-system.c += -fexceptions
359 CFLAGS-system.os = -fomit-frame-pointer
360 CFLAGS-fmtmsg.c += -fexceptions
362 CFLAGS-strfmon.c += $(libio-mtsafe)
363 CFLAGS-strfmon_l.c += $(libio-mtsafe)
365 # The strfrom class of functions call __printf_fp in order to convert the
366 # floating-point value to characters. This requires the value of IO_MTSAFE_IO.
367 CFLAGS-strfromd.c += $(libio-mtsafe)
368 CFLAGS-strfromf.c += $(libio-mtsafe)
369 CFLAGS-strfroml.c += $(libio-mtsafe)
371 CFLAGS-tst-bsearch.c += $(stack-align-test-flags)
372 CFLAGS-tst-qsort.c += $(stack-align-test-flags)
373 CFLAGS-tst-makecontext.c += -funwind-tables
374 CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
376 # Run a test on the header files we use.
377 tests-special += $(objpfx)isomac.out
379 ifeq ($(run-built-tests),yes)
380 tests-special += $(objpfx)tst-fmtmsg.out
381 endif
383 include ../Rules
385 ifeq ($(run-built-tests),yes)
386 LOCALES := \
387 cs_CZ.UTF-8 \
388 de_DE.UTF-8 \
389 el_GR.UTF-8 \
390 en_US.ISO-8859-1 \
391 hi_IN.UTF-8 \
392 hr_HR.UTF-8 \
393 tg_TJ.UTF-8 \
394 tr_TR.ISO-8859-9 \
395 tr_TR.UTF-8 \
396 # LOCALES
397 include ../gen-locales.mk
399 $(objpfx)bug-strtod2.out: $(gen-locales)
400 $(objpfx)testmb2.out: $(gen-locales)
401 $(objpfx)tst-strtod.out: $(gen-locales)
402 $(objpfx)tst-strtod1i.out: $(gen-locales)
403 $(objpfx)tst-strtod3.out: $(gen-locales)
404 $(objpfx)tst-strtod4.out: $(gen-locales)
405 $(objpfx)tst-strtod5.out: $(gen-locales)
406 $(objpfx)tst-strtod5i.out: $(gen-locales)
407 $(objpfx)tst-strtol-locale.out: $(gen-locales)
408 $(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
409 $(objpfx)tst-strfmon_l.out: $(gen-locales)
410 $(objpfx)tst-strfrom.out: $(gen-locales)
411 $(objpfx)tst-strfrom-locale.out: $(gen-locales)
412 $(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so
413 endif
415 # Testdir has to be named stdlib and needs to be writable
416 test-canon-ARGS = --test-dir=${common-objpfx}stdlib
418 bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
420 $(objpfx)isomac.out: $(objpfx)isomac
421 $(dir $<)$(notdir $<) '$(CC)' \
422 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
423 $(evaluate-test)
425 isomac-CFLAGS = -O
426 $(objpfx)isomac: isomac.c
427 $(native-compile)
429 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
430 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
431 '$(run-program-env)' '$(test-program-prefix-after-env)' \
432 $(common-objpfx)stdlib/; \
433 $(evaluate-test)
435 $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
436 LDFLAGS-tst-putenv = -Wl,--no-as-needed
438 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
439 $(build-module)
440 libof-tst-putenvmod = extramodules
442 $(objpfx)bug-getcontext: $(libm)
443 $(objpfx)bug-strtod2: $(libm)
444 $(objpfx)tst-strtod-round: $(libm)
445 $(objpfx)tst-tininess: $(libm)
446 $(objpfx)tst-strtod-underflow: $(libm)
447 $(objpfx)tst-strtod6: $(libm)
448 $(objpfx)tst-strtod-nan-locale: $(libm)
449 $(objpfx)tst-strtod-nan-sign: $(libm)
451 tst-tls-atexit-lib.so-no-z-defs = yes
452 test-dlclose-exit-race-helper.so-no-z-defs = yes
454 $(objpfx)tst-tls-atexit: $(shared-thread-library)
455 $(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so
457 $(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library)
458 $(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so
460 $(objpfx)tst-setcontext3.out: tst-setcontext3.sh $(objpfx)tst-setcontext3
461 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
462 '$(run-program-env)' '$(test-program-prefix-after-env)' \
463 $(common-objpfx)stdlib/; \
464 $(evaluate-test)