1 # Copyright (C) 1991-2023 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 # Sub-makefile for POSIX portion of the library.
37 bits
/pthreadtypes-arch.h \
41 bits
/thread-shared-types.h \
43 bits
/types
/idtype_t.h \
44 bits
/types
/struct_sched_param.h \
109 glob64-lstat-compat \
149 spawn_faction_addchdir \
150 spawn_faction_addclose \
151 spawn_faction_addclosefrom \
152 spawn_faction_adddup2 \
153 spawn_faction_addfchdir \
154 spawn_faction_addopen \
155 spawn_faction_addtcsetpgrp_np \
156 spawn_faction_destroy \
160 spawnattr_getdefault \
162 spawnattr_getpgroup \
163 spawnattr_getschedparam \
164 spawnattr_getschedpolicy \
165 spawnattr_getsigmask \
167 spawnattr_setdefault \
169 spawnattr_setpgroup \
170 spawnattr_setschedparam \
171 spawnattr_setschedpolicy \
172 spawnattr_setsigmask \
188 # Exclude fortified routines from being built with _FORTIFY_SOURCE
189 routines_no_fortify
+= \
194 # routines_no_fortify
304 tst-posix_fadvise64 \
306 tst-posix_spawn-setsid \
309 tst-regcomp-truncated \
314 tst-rxspencer-no-utf8 \
315 tst-sched_getaffinity \
322 tst-sysconf-empty-chroot \
334 # Test for the glob symbol version that was replaced in glibc 2.27.
335 ifeq ($(have-GLIBC_2.26
)$(build-shared
),yesyes
)
337 tst-glob_lstat_compat
341 # Test for the posix_spawn, posix_spawnp symbol versions replaced in
343 ifeq ($(have-GLIBC_2.14
)$(build-shared
),yesyes
)
364 tst-gnuglob64-time64 \
372 tst-sched_rr_get_interval \
376 tst-sched_rr_get_interval-time64 \
379 ifeq (yes
,$(build-shared
))
392 ifeq (yesyes
,$(build-shared
)$(have-thread-library
))
416 install-others-programs
:= \
417 $(inst_libexecdir
)/getconf \
418 # install-others-programs
421 $(objpfx
)posix-conf-vars-def.h \
424 # So they get cleaned up.
426 $(addprefix wordexp-test-result
, 1 2 3 4 5 6 7 8 9 10) \
433 bug-regex14-mem.out \
437 bug-regex21-mem.out \
439 bug-regex31-mem.out \
447 tst-fnmatch-mem.out \
452 tst-rxspencer-no-utf8-mem.out \
453 tst-rxspencer-no-utf8.mtrace \
459 ifeq ($(run-built-tests
),yes
)
460 ifeq (yes
,$(build-shared
))
462 $(objpfx
)globtest.out \
463 $(objpfx
)wordexp-tst.out \
468 # Run a test on the header files we use.
469 # XXX Please note that for now we ignore the result of this test.
470 tests-special
+= $(objpfx
)annexc.out
471 ifeq ($(run-built-tests
),yes
)
473 $(objpfx
)bug-ga2-mem.out \
474 $(objpfx
)bug-glob2-mem.out \
475 $(objpfx
)bug-regex14-mem.out \
476 $(objpfx
)bug-regex2-mem.out \
477 $(objpfx
)bug-regex21-mem.out \
478 $(objpfx
)bug-regex31-mem.out \
479 $(objpfx
)bug-regex36-mem.out \
480 $(objpfx
)tst-boost-mem.out \
481 $(objpfx
)tst-fnmatch-mem.out \
482 $(objpfx
)tst-getconf.out \
483 $(objpfx
)tst-glob-tilde-mem.out \
484 $(objpfx
)tst-pcre-mem.out \
485 $(objpfx
)tst-rxspencer-no-utf8-mem.out \
486 $(objpfx
)tst-vfork3-mem.out \
492 ifeq ($(run-built-tests
),yes
)
493 # globtest and wordexp-test currently only works with shared libraries
494 ifeq (yes
,$(build-shared
))
495 $(objpfx
)globtest.out
: globtest.sh
$(objpfx
)globtest
496 $(SHELL
) $< $(common-objpfx
) '$(test-via-rtld-prefix)' \
497 '$(test-program-prefix)' '$(test-wrapper-env)'; \
499 $(objpfx
)wordexp-tst.out
: wordexp-tst.sh
$(objpfx
)wordexp-test
500 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix-before-env)' \
501 '$(run-program-env)' '$(test-program-prefix-after-env)'; \
518 include ..
/gen-locales.mk
520 $(objpfx
)bug-regex1.out
: $(gen-locales
)
521 $(objpfx
)bug-regex4.out
: $(gen-locales
)
522 $(objpfx
)bug-regex5.out
: $(gen-locales
)
523 $(objpfx
)bug-regex6.out
: $(gen-locales
)
524 $(objpfx
)bug-regex17.out
: $(gen-locales
)
525 $(objpfx
)bug-regex18.out
: $(gen-locales
)
526 $(objpfx
)bug-regex19.out
: $(gen-locales
)
527 $(objpfx
)bug-regex20.out
: $(gen-locales
)
528 $(objpfx
)bug-regex22.out
: $(gen-locales
)
529 $(objpfx
)bug-regex23.out
: $(gen-locales
)
530 $(objpfx
)bug-regex25.out
: $(gen-locales
)
531 $(objpfx
)bug-regex26.out
: $(gen-locales
)
532 $(objpfx
)bug-regex30.out
: $(gen-locales
)
533 $(objpfx
)bug-regex32.out
: $(gen-locales
)
534 $(objpfx
)bug-regex33.out
: $(gen-locales
)
535 $(objpfx
)bug-regex34.out
: $(gen-locales
)
536 $(objpfx
)bug-regex35.out
: $(gen-locales
)
537 $(objpfx
)tst-fnmatch.out
: $(gen-locales
)
538 $(objpfx
)tst-fnmatch4.out
: $(gen-locales
)
539 $(objpfx
)tst-fnmatch5.out
: $(gen-locales
)
540 $(objpfx
)tst-fnmatch6.out
: $(gen-locales
)
541 $(objpfx
)tst-regex.out
: $(gen-locales
)
542 $(objpfx
)tst-regex2.out
: $(gen-locales
)
543 $(objpfx
)tst-regexloc.out
: $(gen-locales
)
544 $(objpfx
)tst-rxspencer.out
: $(gen-locales
)
545 $(objpfx
)tst-rxspencer-no-utf8.out
: $(gen-locales
)
546 $(objpfx
)tst-regcomp-truncated.out
: $(gen-locales
)
549 # If we will use the generic uname implementation, we must figure out what
550 # it will say by examining the system, and write the results in config-name.h.
551 uname.c
: $(objpfx
)config-name.h
552 $(objpfx
)config-name.h
: $(..
)scripts
/config-uname.sh
$(common-objpfx
)config.make
553 $(make-target-directory
)
554 $< '$(config-os)' '$(config-release)' \
555 '$(config-machine)-$(config-vendor)' > $@.new
558 CFLAGS-getaddrinfo.c
+= -DRESOLVER
-fexceptions
559 CFLAGS-pause.c
+= -fexceptions
-fasynchronous-unwind-tables
560 CFLAGS-pread.c
+= -fexceptions
-fasynchronous-unwind-tables
561 CFLAGS-pread64.c
+= -fexceptions
-fasynchronous-unwind-tables
$(config-cflags-wno-ignored-attributes
)
562 CFLAGS-pwrite.c
+= -fexceptions
-fasynchronous-unwind-tables
563 CFLAGS-pwrite64.c
+= -fexceptions
-fasynchronous-unwind-tables
$(config-cflags-wno-ignored-attributes
)
564 CFLAGS-sleep.c
+= -fexceptions
565 CFLAGS-wait.c
+= -fexceptions
-fasynchronous-unwind-tables
566 CFLAGS-waitid.c
+= -fexceptions
-fasynchronous-unwind-tables
567 CFLAGS-waitpid.c
+= -fexceptions
-fasynchronous-unwind-tables
568 CFLAGS-wait4.c
+= -fexceptions
-fasynchronous-unwind-tables
569 CFLAGS-getopt.c
+= -fexceptions
570 CFLAGS-wordexp.c
+= -fexceptions
571 CFLAGS-wordexp.os
= -fomit-frame-pointer
572 CFLAGS-sysconf.c
+= -fexceptions
-DGETCONF_DIR
='"$(libexecdir)/getconf"'
573 CFLAGS-pathconf.c
+= -fexceptions
574 CFLAGS-fpathconf.c
+= -fexceptions
575 CFLAGS-spawn.c
+= -fexceptions
576 CFLAGS-spawn.os
= -fomit-frame-pointer
577 CFLAGS-spawnp.c
+= -fexceptions
578 CFLAGS-spawnp.os
= -fomit-frame-pointer
579 CFLAGS-spawni.c
+= -fexceptions
580 CFLAGS-spawni.os
= -fomit-frame-pointer
581 CFLAGS-glob.c
+= $(uses-callbacks
) -fexceptions
582 CFLAGS-glob64.c
+= $(uses-callbacks
) -fexceptions
583 CFLAGS-getconf.c
+= -DGETCONF_DIR
='"$(libexecdir)/getconf"'
584 CFLAGS-execve.os
= -fomit-frame-pointer
585 CFLAGS-fexecve.os
= -fomit-frame-pointer
586 CFLAGS-execv.os
= -fomit-frame-pointer
587 CFLAGS-execle.os
= -fomit-frame-pointer
588 CFLAGS-execl.os
= -fomit-frame-pointer
589 CFLAGS-execvp.os
= -fomit-frame-pointer
590 CFLAGS-execlp.os
= -fomit-frame-pointer
591 CFLAGS-nanosleep.c
+= -fexceptions
-fasynchronous-unwind-tables
592 CFLAGS-fork.c
= $(libio-mtsafe
) $(config-cflags-wno-ignored-attributes
)
594 tstgetopt-ARGS
= -a
-b
-cfoobar
--required foobar
--optional
=bazbug \
595 --none random
--col
--color
--colour
597 tst-exec-ARGS
= -- $(host-test-program-cmd
)
598 tst-exec-static-ARGS
= $(tst-exec-ARGS
)
599 tst-execvpe5-ARGS
= -- $(host-test-program-cmd
)
600 tst-spawn-ARGS
= -- $(host-test-program-cmd
)
601 tst-spawn-static-ARGS
= $(tst-spawn-ARGS
)
602 tst-spawn5-ARGS
= -- $(host-test-program-cmd
)
603 tst-spawn6-ARGS
= -- $(host-test-program-cmd
)
604 tst-spawn7-ARGS
= -- $(host-test-program-cmd
)
605 tst-posix_spawn-setsid-ARGS
= -- $(host-test-program-cmd
)
606 tst-dir-ARGS
= `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx
)tst-dir
607 tst-chmod-ARGS
= $(objdir
)
608 tst-vfork3-ARGS
= --test-dir
=$(objpfx
)
610 tst-rxspencer-ARGS
= --utf8 rxspencer
/tests
611 tst-rxspencer-no-utf8-ARGS
= rxspencer
/tests
612 tst-pcre-ARGS
= PCRE.tests
613 tst-boost-ARGS
= BOOST.tests
614 bug-glob1-ARGS
= "$(objpfx)"
615 tst-execvp3-ARGS
= --test-dir
=$(objpfx
)
616 CFLAGS-tst-spawn3.c
+= -DOBJPFX
=\"$(objpfx
)\"
618 # Test voluntarily overflows struct dirent
619 CFLAGS-bug-glob2.c
+= $(no-fortify-source
)
621 $(objpfx
)testcases.h
: TESTS TESTS2C.sed
622 LC_ALL
=C sed
-f TESTS2C.sed
< $< > $@T
624 $(objpfx
)runtests.o
: $(objpfx
)testcases.h
626 $(objpfx
)ptestcases.h
: PTESTS PTESTS2C.sed
627 LC_ALL
=C sed
-f PTESTS2C.sed
< $< > $@T
629 $(objpfx
)runptests.o
: $(objpfx
)ptestcases.h
631 $(objpfx
)tst-getopt-cancel
: $(shared-thread-library
)
632 $(objpfx
)tst-_Fork
: $(shared-thread-library
)
634 test-xfail-annexc
= yes
635 $(objpfx
)annexc.out
: $(objpfx
)annexc
636 $(dir $<)$(notdir $<) '$(CC)' \
637 '$(patsubst %,-I../%,$(sorted-subdirs)) -I../include $(+sysdep-includes) $(sysincludes) -I..' > $@
; \
641 $(objpfx
)annexc
: annexc.c
644 tst-fnmatch-ENV
+= MALLOC_TRACE
=$(objpfx
)tst-fnmatch.mtrace \
645 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
647 $(objpfx
)tst-fnmatch-mem.out
: $(objpfx
)tst-fnmatch.out
648 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-fnmatch.mtrace
> $@
; \
651 bug-regex2-ENV
= MALLOC_TRACE
=$(objpfx
)bug-regex2.mtrace \
652 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
654 $(objpfx
)bug-regex2-mem.out
: $(objpfx
)bug-regex2.out
655 $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-regex2.mtrace
> $@
; \
658 bug-regex14-ENV
= MALLOC_TRACE
=$(objpfx
)bug-regex14.mtrace \
659 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
661 $(objpfx
)bug-regex14-mem.out
: $(objpfx
)bug-regex14.out
662 $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-regex14.mtrace
> $@
; \
665 bug-regex21-ENV
= MALLOC_TRACE
=$(objpfx
)bug-regex21.mtrace \
666 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
668 $(objpfx
)bug-regex21-mem.out
: $(objpfx
)bug-regex21.out
669 $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-regex21.mtrace
> $@
; \
672 bug-regex31-ENV
= MALLOC_TRACE
=$(objpfx
)bug-regex31.mtrace \
673 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
675 $(objpfx
)bug-regex31-mem.out
: $(objpfx
)bug-regex31.out
676 $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-regex31.mtrace
> $@
; \
679 bug-regex36-ENV
= MALLOC_TRACE
=$(objpfx
)bug-regex36.mtrace \
680 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
682 $(objpfx
)bug-regex36-mem.out
: $(objpfx
)bug-regex36.out
683 $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-regex36.mtrace
> $@
; \
686 tst-vfork3-ENV
= MALLOC_TRACE
=$(objpfx
)tst-vfork3.mtrace \
687 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
689 $(objpfx
)tst-vfork3-mem.out
: $(objpfx
)tst-vfork3.out
690 { test -r
$(objpfx
)tst-vfork3.mtrace \
691 ||
( echo
"tst-vfork3.mtrace does not exist"; exit
77; ) \
692 && $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-vfork3.mtrace
; } > $@
; \
695 # tst-rxspencer.mtrace is not generated, only
696 # tst-rxspencer-no-utf8.mtrace, since otherwise the file has almost
697 # 100M and takes very long time to process.
698 tst-rxspencer-no-utf8-ENV
+= \
699 MALLOC_TRACE
=$(objpfx
)tst-rxspencer-no-utf8.mtrace \
700 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
701 $(objpfx
)tst-rxspencer-no-utf8-mem.out
: $(objpfx
)tst-rxspencer-no-utf8.out
702 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-rxspencer-no-utf8.mtrace \
706 tst-pcre-ENV
= MALLOC_TRACE
=$(objpfx
)tst-pcre.mtrace \
707 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
708 $(objpfx
)tst-pcre-mem.out
: $(objpfx
)tst-pcre.out
709 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-pcre.mtrace
> $@
; \
712 tst-boost-ENV
= MALLOC_TRACE
=$(objpfx
)tst-boost.mtrace \
713 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
714 $(objpfx
)tst-boost-mem.out
: $(objpfx
)tst-boost.out
715 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-boost.mtrace
> $@
; \
718 $(objpfx
)tst-getconf.out
: tst-getconf.sh
$(objpfx
)getconf
719 $(SHELL
) $< $(common-objpfx
) '$(built-program-cmd)'; \
722 $(objpfx
)bug-ga2-mem.out
: $(objpfx
)bug-ga2.out
723 { test -r
$(objpfx
)bug-ga2.mtrace \
724 ||
( echo
"bug-ga2.mtrace does not exist"; exit
77; ) \
725 && $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-ga2.mtrace
; } > $@
; \
728 bug-ga2-ENV
= MALLOC_TRACE
=$(objpfx
)bug-ga2.mtrace \
729 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
731 bug-glob2-ENV
= MALLOC_TRACE
=$(objpfx
)bug-glob2.mtrace \
732 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
734 $(objpfx
)bug-glob2-mem.out
: $(objpfx
)bug-glob2.out
735 $(common-objpfx
)malloc
/mtrace
$(objpfx
)bug-glob2.mtrace
> $@
; \
738 tst-glob-tilde-ENV
= MALLOC_TRACE
=$(objpfx
)tst-glob-tilde.mtrace \
739 LD_PRELOAD
=$(common-objpfx
)/malloc
/libc_malloc_debug.so
741 $(objpfx
)tst-glob-tilde-mem.out
: $(objpfx
)tst-glob-tilde.out
742 $(common-objpfx
)malloc
/mtrace
$(objpfx
)tst-glob-tilde.mtrace
> $@
; \
745 $(inst_libexecdir
)/getconf
: $(inst_bindir
)/getconf \
746 $(objpfx
)getconf.speclist FORCE
747 $(addprefix $(..
).
/scripts
/mkinstalldirs
,\
748 $(filter-out $(wildcard $@
),$@
))
749 while read spec
; do \
750 ln
-f
$< $@
/$$spec.new ||
$(INSTALL_PROGRAM
) $< $@
/$$spec.new
; \
751 mv
-f
$@
/$$spec.new
$@
/$$spec; \
752 done
< $(objpfx
)getconf.speclist
754 $(objpfx
)getconf.speclist
: getconf-speclist.c posix-envs.def
755 $(compile.c
) -E
-o
- \
756 | sed
-n
-e
'/@@@PRESENT_/s/@@@PRESENT_//p' > $@.new
759 # This file is only actually needed at install time. But forcing it to
760 # be built both makes it available for eyeball inspection and avoids the
761 # surprise of things that look like compilation being done by 'make install'.
762 others
: $(objpfx
)getconf.speclist
764 $(objpfx
)posix-conf-vars-def.h
: $(..
)scripts
/gen-posix-conf-vars.awk \
765 posix-conf-vars.list Makefile
766 $(make-target-directory
)
767 $(AWK
) -f
$(filter-out Makefile
, $^
) > $@.tmp