]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/Makefile
d7b020154af89038a531289d58a6add2eb3ea7c1
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / Makefile
1 # Option to pass to Python scripts to set the C compiler. Rewriting
2 # MODULE_NAME is required to enable the _ISOMAC verbatim header
3 # environment.
4 sysdeps-linux-python-cc = \
5 --cc="$(CC) $(patsubst -DMODULE_NAME=%,-DMODULE_NAME=testsuite,$(CPPFLAGS))"
6
7 # Additional dependencies for Python scripts.
8 sysdeps-linux-python-deps = \
9 $(..)scripts/glibcextract.py \
10 $(..)sysdeps/unix/sysv/linux/glibcsyscalls.py \
11 # sysdeps-linux-python-deps
12
13 # Invocation of the Python interpreter with the Python search path.
14 sysdeps-linux-python = \
15 PYTHONPATH=$(..)scripts:$(..)sysdeps/unix/sysv/linux $(PYTHON)
16
17 ifndef subdir
18 # This target performs two actions:
19 #
20 # Replace <arch-syscall.h> with a file generated from kernel headers
21 # and <fixup-asm-unistd.h>. Both files are located via the sysdeps
22 # override search path.
23 #
24 # Update sysdeps/unix/sysv/linux/syscall-names.list with additional
25 # names found in the generated <arch-syscall.h> file, so that the
26 # global system call names list is a superset of the
27 # architecture-specific system call names.
28 #
29 # To bootstrap a new architecture, create an empty file in the right
30 # place and run `make update-syscall-lists' from the top-level of a
31 # configured, but not-yet-built glibc tree.
32 #
33 # --lock points to a file not replaced during the update operation, so
34 # that mutual exclusion is achieved.
35 .PHONY: update-syscall-lists
36 update-syscall-lists: arch-syscall.h
37 $(sysdeps-linux-python) \
38 sysdeps/unix/sysv/linux/update-syscall-lists.py \
39 $(sysdeps-linux-python-cc) \
40 --lock=sysdeps/unix/sysv/linux/update-syscall-lists.py $< \
41 sysdeps/unix/sysv/linux/syscall-names.list
42 endif
43
44 ifeq ($(subdir),csu)
45 sysdep_routines += \
46 errno-loc \
47 # sysdep_routines
48 endif
49
50 ifeq ($(subdir),assert)
51 CFLAGS-assert.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
52 CFLAGS-assert-perr.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
53 endif
54
55 ifeq ($(subdir),malloc)
56 CFLAGS-malloc.c += -DMORECORE_CLEARS=2
57 endif
58
59 ifeq ($(subdir),misc)
60 sysdep_routines += \
61 adjtimex \
62 clock_adjtime \
63 clone \
64 clone-internal \
65 clone3 \
66 closefrom_fallback \
67 convert_scm_timestamps \
68 epoll_create \
69 epoll_pwait \
70 epoll_pwait2 \
71 epoll_wait \
72 eventfd \
73 eventfd_read \
74 eventfd_write \
75 fanotify_mark \
76 fxstat \
77 fxstat64 \
78 fxstatat \
79 fxstatat64 \
80 inotify_init \
81 lxstat \
82 lxstat64 \
83 mlock2 \
84 mremap \
85 open_by_handle_at \
86 personality \
87 pkey_get \
88 pkey_mprotect \
89 pkey_set \
90 prctl \
91 prlimit \
92 prlimit64 \
93 process_vm_readv \
94 process_vm_writev \
95 pselect32 \
96 readahead \
97 setfsgid \
98 setfsuid \
99 signalfd \
100 splice \
101 sysctl \
102 tee \
103 timerfd_gettime \
104 timerfd_settime \
105 umount \
106 umount2 \
107 vmsplice \
108 xmknod \
109 xmknodat \
110 xstat \
111 xstat64 \
112 # sysdep_routines
113
114 CFLAGS-gethostid.c = -fexceptions
115 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
116 CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
117 CFLAGS-splice.c = -fexceptions -fasynchronous-unwind-tables
118 CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables
119 CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables
120 CFLAGS-pselect32.c = -fexceptions -fasynchronous-unwind-tables
121 CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
122
123 # The test triggers FORTIFY abortion due to purposely wrong parameters
124 CFLAGS-test-errno-linux.c += $(no-fortify-source)
125
126 sysdep_headers += \
127 bits/a.out.h \
128 bits/epoll.h \
129 bits/eventfd.h \
130 bits/inotify.h \
131 bits/mman-linux.h \
132 bits/mman-map-flags-generic.h \
133 bits/mman-shared.h \
134 bits/procfs-extra.h \
135 bits/procfs-id.h \
136 bits/procfs-prregset.h \
137 bits/procfs.h \
138 bits/pthread_stack_min-dynamic.h \
139 bits/pthread_stack_min.h \
140 bits/ptrace-shared.h \
141 bits/rseq.h \
142 bits/shmlba.h \
143 bits/siginfo-arch.h \
144 bits/siginfo-consts-arch.h \
145 bits/signalfd.h \
146 bits/socket_type.h \
147 bits/struct_stat.h \
148 bits/struct_stat_time64_helper.h \
149 bits/syscall.h \
150 bits/termios-baud.h \
151 bits/termios-c_cc.h \
152 bits/termios-c_cflag.h \
153 bits/termios-c_iflag.h \
154 bits/termios-c_lflag.h \
155 bits/termios-c_oflag.h \
156 bits/termios-misc.h \
157 bits/termios-struct.h \
158 bits/termios-tcflow.h \
159 bits/timerfd.h \
160 bits/types/struct_msqid64_ds.h \
161 bits/types/struct_msqid64_ds_helper.h \
162 bits/types/struct_semid64_ds.h \
163 bits/types/struct_semid64_ds_helper.h \
164 bits/types/struct_semid_ds.h \
165 bits/types/struct_shmid64_ds.h \
166 bits/types/struct_shmid64_ds_helper.h \
167 scsi/scsi.h \
168 scsi/scsi_ioctl.h \
169 scsi/sg.h \
170 sys/acct.h \
171 sys/epoll.h \
172 sys/eventfd.h \
173 sys/fanotify.h \
174 sys/fsuid.h \
175 sys/inotify.h \
176 sys/kd.h \
177 sys/klog.h \
178 sys/mount.h \
179 sys/pci.h \
180 sys/personality.h \
181 sys/pidfd.h \
182 sys/prctl.h \
183 sys/quota.h \
184 sys/raw.h \
185 sys/rseq.h \
186 sys/signalfd.h \
187 sys/soundcard.h \
188 sys/timerfd.h \
189 sys/user.h \
190 sys/vt.h \
191 # sysdep_headers
192
193 tests += \
194 test-errno-linux \
195 tst-adjtimex \
196 tst-clock_adjtime \
197 tst-clone \
198 tst-clone2 \
199 tst-clone3 \
200 tst-epoll \
201 tst-fanotify \
202 tst-getauxval \
203 tst-gettid \
204 tst-gettid-kill \
205 tst-memfd_create \
206 tst-misalign-clone \
207 tst-mlock2 \
208 tst-mount \
209 tst-ntp_adjtime \
210 tst-ntp_gettime \
211 tst-ntp_gettimex \
212 tst-ofdlocks \
213 tst-personality \
214 tst-pidfd \
215 tst-pkey \
216 tst-ppoll \
217 tst-prctl \
218 tst-process_mrelease \
219 tst-quota \
220 tst-rlimit-infinity \
221 tst-scm_rights \
222 tst-sigtimedwait \
223 tst-sync_file_range \
224 tst-sysconf-iov_max \
225 tst-sysvmsg-linux \
226 tst-sysvsem-linux \
227 tst-sysvshm-linux \
228 tst-tgkill \
229 tst-timerfd \
230 tst-ttyname-direct \
231 tst-ttyname-namespace \
232 # tests
233
234 # process_madvise requires CAP_SYS_ADMIN.
235 xtests += \
236 tst-process_madvise \
237 # xtests
238
239 # For +depfiles in Makerules.
240 extra-test-objs += \
241 tst-sysconf-iov_max-uapi.o \
242 # extra-test-objs
243
244 # Test for the symbol version of fcntl that was replaced in glibc 2.28.
245 ifeq ($(have-GLIBC_2.27)$(build-shared),yesyes)
246 tests += \
247 tst-ofdlocks-compat \
248 # tests
249 endif
250
251 tests-internal += \
252 tst-rseq \
253 tst-sigcontext-get_pc \
254 # tests-internal
255
256 tests-internal += \
257 tst-rseq-disable \
258 # tests-internal
259
260 tests-time64 += \
261 tst-adjtimex-time64 \
262 tst-clock_adjtime-time64 \
263 tst-epoll-time64 \
264 tst-ntp_adjtime-time64 \
265 tst-ntp_gettime-time64 \
266 tst-ntp_gettimex-time64 \
267 tst-ppoll-time64 \
268 tst-prctl-time64 \
269 tst-scm_rights-time64 \
270 tst-sigtimedwait-time64 \
271 tst-timerfd-time64 \
272 # tests-time64
273
274 tests-clone-internal = \
275 tst-align-clone-internal \
276 tst-clone2-internal \
277 tst-clone3-internal \
278 tst-getpid1-internal
279 # tests-clone-internal
280 tests-internal += \
281 $(tests-clone-internal) \
282 # tests-internal
283 tests-static += \
284 $(tests-clone-internal) \
285 # tests-static
286
287 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
288
289 # Generate the list of SYS_* macros for the system calls (__NR_*
290 # macros). The file syscall-names.list contains all possible system
291 # call names, and the generated header file produces SYS_* macros for
292 # the __NR_* macros which are actually defined.
293
294 generated += bits/syscall.h
295 $(objpfx)bits/syscall.h: \
296 ../sysdeps/unix/sysv/linux/gen-syscall-h.awk \
297 ../sysdeps/unix/sysv/linux/syscall-names.list
298 $(make-target-directory)
299 LC_ALL=C $(AWK) -f $^ > $@-tmp
300 $(move-if-change) $@-tmp $@
301 before-compile += $(objpfx)bits/syscall.h
302
303 # All macros defined by <sys/syscall.h>. Include <bits/syscall.h>
304 # explicitly because <sys/sycall.h> skips it if _LIBC is defined.
305 $(objpfx)tst-syscall-list-macros.list: \
306 $(objpfx)bits/syscall.h ../sysdeps/unix/sysv/linux/sys/syscall.h
307 printf '#include <linux/version.h>\n\
308 #include <sys/syscall.h>\n#include <bits/syscall.h>\n' | \
309 $(CC) -E -o $@-tmp $(CFLAGS) $(CPPFLAGS) -x c - -dM
310 $(move-if-change) $@-tmp $@
311
312 # __NR_* system call names. Used by the test below.
313 $(objpfx)tst-syscall-list-nr.list: \
314 ../sysdeps/unix/sysv/linux/filter-nr-syscalls.awk \
315 $(objpfx)tst-syscall-list-macros.list
316 LC_ALL=C $(AWK) -f $^ > $@-tmp
317 $(move-if-change) $@-tmp $@
318
319 # SYS_* system call names. Used by the test below.
320 $(objpfx)tst-syscall-list-sys.list: $(objpfx)tst-syscall-list-macros.list
321 LC_ALL=C $(AWK) '/^#define SYS_/ { print substr($$2, 5) }' $< > $@-tmp
322 $(move-if-change) $@-tmp $@
323
324 tests-special += \
325 $(objpfx)tst-syscall-list.out
326 # tests-special
327 $(objpfx)tst-syscall-list.out: \
328 ../sysdeps/unix/sysv/linux/tst-syscall-list.sh \
329 $(objpfx)tst-syscall-list-macros.list \
330 $(objpfx)tst-syscall-list-nr.list \
331 $(objpfx)tst-syscall-list-sys.list
332 $(BASH) $^ $(AWK) > $@; $(evaluate-test)
333
334 tests-special += \
335 $(objpfx)tst-glibcsyscalls.out
336 # tests-special
337 # arch-syscall.h is located via the sysdeps override search path.
338 $(objpfx)tst-glibcsyscalls.out: arch-syscall.h \
339 ../sysdeps/unix/sysv/linux/syscall-names.list
340 $(sysdeps-linux-python) \
341 ../sysdeps/unix/sysv/linux/tst-glibcsyscalls.py \
342 $(sysdeps-linux-python-cc) $< \
343 ../sysdeps/unix/sysv/linux/syscall-names.list \
344 < /dev/null > $@ 2>&1; $(evaluate-test)
345 $(objpfx)tst-glibcsyscalls.out: \
346 ../sysdeps/unix/sysv/linux/tst-glibcsyscalls.py \
347 $(sysdeps-linux-python-deps)
348
349 # Separate object file for access to the constant from the UAPI header.
350 $(objpfx)tst-sysconf-iov_max: $(objpfx)tst-sysconf-iov_max-uapi.o
351
352 tests-special += \
353 $(objpfx)tst-mman-consts.out \
354 # tests-special
355 $(objpfx)tst-mman-consts.out: ../sysdeps/unix/sysv/linux/tst-mman-consts.py
356 $(sysdeps-linux-python) \
357 ../sysdeps/unix/sysv/linux/tst-mman-consts.py \
358 $(sysdeps-linux-python-cc) \
359 < /dev/null > $@ 2>&1; $(evaluate-test)
360 $(objpfx)tst-mman-consts.out: $(sysdeps-linux-python-deps)
361
362 tests-special += \
363 $(objpfx)tst-pidfd-consts.out \
364 # tests-special
365 $(objpfx)tst-pidfd-consts.out: ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py
366 $(sysdeps-linux-python) \
367 ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py \
368 $(sysdeps-linux-python-cc) \
369 < /dev/null > $@ 2>&1; $(evaluate-test)
370 $(objpfx)tst-pidfd-consts.out: $(sysdeps-linux-python-deps)
371
372 tests-special += \
373 $(objpfx)tst-mount-consts.out \
374 # tests-special
375 $(objpfx)tst-mount-consts.out: ../sysdeps/unix/sysv/linux/tst-mount-consts.py
376 $(sysdeps-linux-python) \
377 ../sysdeps/unix/sysv/linux/tst-mount-consts.py \
378 $(sysdeps-linux-python-cc) \
379 < /dev/null > $@ 2>&1; $(evaluate-test)
380 $(objpfx)tst-mount-consts.out: $(sysdeps-linux-python-deps)
381
382 tests-special += \
383 $(objpfx)tst-mount-compile.out \
384 # tests-special
385 $(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py
386 $(sysdeps-linux-python) \
387 ../sysdeps/unix/sysv/linux/tst-mount-compile.py \
388 $(sysdeps-linux-python-cc) \
389 < /dev/null > $@ 2>&1; $(evaluate-test)
390 $(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps)
391
392 tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
393
394 endif # $(subdir) == misc
395
396 ifeq ($(subdir),time)
397 sysdep_headers += \
398 bits/timex.h \
399 sys/timex.h \
400 # sysdep_headers
401
402 sysdep_routines += \
403 ntp_gettime \
404 ntp_gettimex \
405 # sysdep_routines
406
407 tests += \
408 tst-clock_gettime-clobber \
409 tst-gettimeofday-clobber \
410 tst-time-clobber \
411 # tests
412 endif
413
414 ifeq ($(subdir),signal)
415 tests-special += \
416 $(objpfx)tst-signal-numbers.out \
417 # tests-special
418
419 # Depending on signal.o* is a hack. What we actually want is a dependency
420 # on signal.h and everything it includes. That's impractical to write
421 # in this context, but signal.c includes signal.h and not much else so it'll
422 # be conservatively correct.
423 $(objpfx)tst-signal-numbers.out: \
424 ../sysdeps/unix/sysv/linux/tst-signal-numbers.py \
425 $(objpfx)signal.o*
426 $(sysdeps-linux-python) \
427 ../sysdeps/unix/sysv/linux/tst-signal-numbers.py \
428 $(sysdeps-linux-python-cc) \
429 < /dev/null > $@ 2>&1; $(evaluate-test)
430 $(objpfx)tst-signal-numbers.out: $(sysdeps-linux-python-deps)
431 endif
432
433 ifeq ($(subdir),socket)
434 sysdep_headers += \
435 bits/socket-constants.h \
436 net/ethernet.h \
437 net/if_arp.h \
438 net/if_packet.h \
439 net/if_ppp.h \
440 net/if_shaper.h \
441 net/if_slip.h \
442 net/ppp-comp.h \
443 net/ppp_defs.h \
444 net/route.h \
445 # sysdep_headers
446
447 sysdep_routines += \
448 cmsg_nxthdr \
449 # sysdep_routines
450
451 CFLAGS-recvmmsg.c = -fexceptions -fasynchronous-unwind-tables
452 CFLAGS-sendmmsg.c = -fexceptions -fasynchronous-unwind-tables
453
454 tests += \
455 tst-socket-timestamp \
456 tst-socket-timestamp-compat \
457 # tests
458 tests-time64 += \
459 tst-socket-timestamp-compat-time64 \
460 tst-socket-timestamp-time64 \
461 # tests-time64
462
463 tests-special += \
464 $(objpfx)tst-socket-consts.out \
465 # tests-special
466 $(objpfx)tst-socket-consts.out: ../sysdeps/unix/sysv/linux/tst-socket-consts.py
467 PYTHONPATH=../scripts \
468 $(PYTHON) ../sysdeps/unix/sysv/linux/tst-socket-consts.py \
469 --cc="$(CC) $(patsubst -DMODULE_NAME=%, \
470 -DMODULE_NAME=testsuite, \
471 $(CPPFLAGS)) -D_ISOMAC" \
472 < /dev/null > $@ 2>&1; $(evaluate-test)
473 endif # $(subdir) == socket
474
475 ifeq ($(subdir),sunrpc)
476 sysdep_headers += \
477 nfs/nfs.h \
478 # sysdep_headers
479 endif
480
481 ifeq ($(subdir),termios)
482 sysdep_headers += \
483 termio.h \
484 # sysdep_headers
485 endif
486
487 ifeq ($(subdir),posix)
488 sysdep_headers += \
489 bits/initspin.h \
490 # sysdep_headers
491
492 sysdep_routines += \
493 getcpu \
494 oldglob \
495 sched_getcpu \
496 spawnattr_getcgroup_np \
497 spawnattr_setcgroup_np \
498 # sysdep_routines
499
500 tests += \
501 tst-affinity \
502 tst-affinity-pid \
503 tst-spawn-cgroup \
504 # tests
505
506 tests-static += \
507 tst-affinity-static \
508 # tests-static
509
510 tests += \
511 $(tests-static) \
512 # tests
513
514 CFLAGS-fork.c = $(libio-mtsafe)
515 CFLAGS-getpid.o = -fomit-frame-pointer
516 CFLAGS-getpid.os = -fomit-frame-pointer
517
518 tst-spawn-cgroup-ARGS = -- $(host-test-program-cmd)
519 endif
520
521 ifeq ($(subdir),inet)
522 sysdep_headers += \
523 netash/ash.h \
524 netatalk/at.h \
525 netax25/ax25.h \
526 neteconet/ec.h \
527 netinet/if_fddi.h \
528 netinet/if_tr.h \
529 netipx/ipx.h \
530 netiucv/iucv.h \
531 netpacket/packet.h \
532 netrom/netrom.h \
533 netrose/rose.h \
534 # sysdep_headers
535
536 sysdep_routines += \
537 netlink_assert_response \
538 # sysdep_routines
539
540 CFLAGS-check_pf.c += -fexceptions
541 endif
542
543 # Don't compile the ctype glue code, since there is no old non-GNU C library.
544 inhibit-glue = yes
545
546 ifeq ($(subdir),dirent)
547 sysdep_routines += \
548 getdirentries \
549 getdirentries64 \
550 # sysdep_routines
551
552 tests += \
553 tst-getdents64 \
554 tst-readdir64-compat \
555 # tests
556 endif # $(subdir) == dirent
557
558 ifeq ($(subdir),nis)
559 CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
560 endif
561
562 ifeq ($(subdir),io)
563 sysdep_routines += \
564 close_nocancel \
565 fallocate \
566 fallocate64 \
567 fcntl_nocancel \
568 internal_statvfs \
569 open64_nocancel \
570 open_nocancel \
571 openat64_nocancel \
572 openat_nocancel \
573 pread64_nocancel \
574 read_nocancel \
575 stat_t64_cp \
576 statx_cp \
577 sync_file_range \
578 write_nocancel \
579 xstatconv \
580 # sysdep_routines
581
582 sysdep_headers += \
583 bits/fcntl-linux.h \
584 # sysdep_headers
585
586 tests += \
587 tst-fallocate \
588 tst-fallocate64 \
589 tst-getcwd-smallbuff \
590 tst-o_path-locks \
591 # tests
592 endif
593
594 ifeq ($(subdir),elf)
595 sysdep-rtld-routines += \
596 dl-brk \
597 dl-getcwd \
598 dl-openat64 \
599 dl-opendir \
600 dl-sbrk \
601 # sysdep-rtld-routines
602
603 others += \
604 pldd \
605 # others
606
607 install-bin += \
608 pldd \
609 # install-bin
610
611 $(objpfx)pldd: $(objpfx)xmalloc.o
612 endif
613
614 ifeq ($(subdir),rt)
615 CFLAGS-mq_send.c += -fexceptions
616 CFLAGS-mq_receive.c += -fexceptions
617 endif
618
619 ifeq ($(subdir),nscd)
620 sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_INOTIFY -DHAVE_NETLINK
621 CFLAGS-gai.c += -DNEED_NETLINK
622 endif
623
624 ifeq ($(subdir),nptl)
625 tests += \
626 tst-align-clone \
627 tst-getpid1 \
628 # tests
629
630 # tst-rseq-nptl is an internal test because it requires a definition of
631 # __NR_rseq from the internal system call list.
632 tests-internal += \
633 tst-rseq-nptl \
634 # tests-internal
635 endif