Factor out shared definitions from bits/signum.h.
[glibc.git] / sysdeps / unix / sysv / linux / Makefile
blob8b340d49889fc1a659bda9529bd6840a577ab4eb
1 ifeq ($(subdir),csu)
2 sysdep_routines += errno-loc
3 endif
5 ifeq ($(subdir),assert)
6 CFLAGS-assert.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
7 CFLAGS-assert-perr.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
8 endif
10 ifeq ($(subdir),malloc)
11 CFLAGS-malloc.c += -DMORECORE_CLEARS=2
12 endif
14 ifeq ($(subdir),misc)
15 include $(firstword $(wildcard $(sysdirs:=/sysctl.mk)))
17 sysdep_routines += clone umount umount2 readahead \
18 setfsuid setfsgid epoll_pwait signalfd \
19 eventfd eventfd_read eventfd_write prlimit \
20 personality epoll_wait tee vmsplice splice \
21 open_by_handle_at
23 CFLAGS-gethostid.c = -fexceptions
24 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
25 CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
26 CFLAGS-splice.c = -fexceptions -fasynchronous-unwind-tables
27 CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables
28 CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables
29 CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
31 # Note that bits/mman-linux.h is listed here though the file lives in the
32 # top-level bits/ subdirectory instead of here in sysdeps/.../linux/bits/.
33 # That is just so that other (non-Linux) configurations for whom the
34 # bits/mman-linux.h definitions work well do not have to duplicate the
35 # contents of the file. The file must still be listed in sysdep_headers
36 # here and in any non-Linux configuration that uses it; other
37 # configurations will not install the file.
38 sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
39 sys/klog.h \
40 sys/user.h sys/prctl.h \
41 sys/kd.h sys/soundcard.h sys/vt.h \
42 sys/quota.h sys/fsuid.h \
43 scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
44 sys/raw.h sys/personality.h sys/epoll.h \
45 bits/a.out.h sys/inotify.h sys/signalfd.h sys/eventfd.h \
46 sys/timerfd.h sys/fanotify.h bits/eventfd.h bits/inotify.h \
47 bits/signalfd.h bits/timerfd.h bits/epoll.h \
48 bits/socket_type.h bits/syscall.h bits/sysctl.h \
49 bits/mman-linux.h \
50 bits/siginfo-arch.h bits/siginfo-consts-arch.h
52 tests += tst-clone tst-clone2 tst-fanotify tst-personality tst-quota \
53 tst-sync_file_range test-errno-linux
55 # Generate the list of SYS_* macros for the system calls (__NR_* macros).
57 # If there is more than one syscall list for different architecture
58 # variants, the CPU/Makefile defines abi-variants to be a list of names
59 # for those variants (e.g. 32 64), and, for each variant, defines
60 # abi-$(variant)-options to be compiler options to cause <asm/unistd.h>
61 # to define the desired list of syscalls and abi-$(variant)-condition to
62 # be the condition for those options to use in a C #if condition.
63 # abi-includes may be defined to a list of headers to include
64 # in the generated header, if the default does not suffice.
66 # The generated header is compiled with `-ffreestanding' to avoid any
67 # circular dependencies against the installed implementation headers.
68 # Such a dependency would require the implementation header to be
69 # installed before the generated header could be built (See bug 15711).
70 # In current practice the generated header dependencies do not include
71 # any of the implementation headers removed by the use of `-ffreestanding'.
73 $(objpfx)bits/syscall%h $(objpfx)bits/syscall%d: ../sysdeps/unix/sysv/linux/sys/syscall.h
74 $(make-target-directory)
75 { \
76 echo '/* Generated at libc build time from kernel syscall list. */';\
77 echo ''; \
78 echo '#ifndef _SYSCALL_H'; \
79 echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
80 echo '#endif'; \
81 echo ''; \
82 $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
83 echo ''; \
84 $(if $(abi-variants), \
85 $(foreach v,$(abi-variants),\
86 $(CC) -ffreestanding -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
87 -x c $(sysincludes) $< $(abi-$(v)-options) \
88 -D_LIBC -dM | \
89 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
90 LC_ALL=C sort > $(@:.d=.h).new$(v); \
91 $(if $(abi-$(v)-condition),\
92 echo '#if $(abi-$(v)-condition)';) \
93 cat $(@:.d=.h).new$(v); \
94 $(if $(abi-$(v)-condition),echo '#endif';) \
95 rm -f $(@:.d=.h).new$(v); \
96 ), \
97 $(CC) -ffreestanding -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
98 -x c $(sysincludes) $< \
99 -D_LIBC -dM | \
100 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
101 LC_ALL=C sort;) \
102 } > $(@:.d=.h).new
103 mv -f $(@:.d=.h).new $(@:.d=.h)
104 ifdef abi-variants
105 ifneq (,$(objpfx))
106 sed $(sed-remove-objpfx) \
107 $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) > $(@:.h=.d)-t3
108 else
109 cat $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) \
110 > $(@:.h=.d)-t3
111 endif
112 rm -f $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v))
113 mv -f $(@:.h=.d)-t3 $(@:.h=.d)
114 else
115 mv -f $(@:.h=.d)-t $(@:.h=.d)
116 endif
118 ifndef no_deps
119 # Get the generated list of dependencies (probably /usr/include/asm/unistd.h).
120 -include $(objpfx)bits/syscall.d
121 endif
122 generated += bits/syscall.h bits/syscall.d
123 endif
125 ifeq ($(subdir),time)
126 sysdep_headers += sys/timex.h bits/timex.h
128 sysdep_routines += ntp_gettime ntp_gettimex
129 endif
131 ifeq ($(subdir),signal)
132 tests-special += $(objpfx)tst-signal-numbers.out
133 # Depending on signal.o* is a hack. What we actually want is a dependency
134 # on signal.h and everything it includes. That's impractical to write
135 # in this context, but signal.c includes signal.h and not much else so it'll
136 # be conservatively correct.
137 $(objpfx)tst-signal-numbers.out: \
138 ../sysdeps/unix/sysv/linux/tst-signal-numbers.sh \
139 $(objpfx)signal.o*
140 AWK=$(AWK) $(SHELL) ../sysdeps/unix/sysv/linux/tst-signal-numbers.sh \
141 $(CC) $(patsubst -DMODULE_NAME=%,-DMODULE_NAME=testsuite,$(CPPFLAGS)) \
142 < /dev/null > $@; $(evaluate-test)
143 endif
145 ifeq ($(subdir),socket)
146 sysdep_headers += net/if_ppp.h net/ppp-comp.h \
147 net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
148 net/if_slip.h net/if_packet.h net/if_shaper.h
149 sysdep_routines += cmsg_nxthdr
150 CFLAGS-recvmmsg.c = -fexceptions -fasynchronous-unwind-tables
151 CFLAGS-sendmmsg.c = -fexceptions -fasynchronous-unwind-tables
152 endif
154 ifeq ($(subdir),sunrpc)
155 sysdep_headers += nfs/nfs.h
156 endif
158 ifeq ($(subdir),termios)
159 sysdep_headers += termio.h
160 endif
162 ifeq ($(subdir),posix)
163 sysdep_headers += bits/initspin.h
165 sysdep_routines += sched_getcpu
167 tests += tst-affinity tst-affinity-pid
169 CFLAGS-fork.c = $(libio-mtsafe)
170 CFLAGS-getpid.o = -fomit-frame-pointer
171 CFLAGS-getpid.os = -fomit-frame-pointer
172 endif
174 ifeq ($(subdir),inet)
175 sysdep_headers += netinet/if_fddi.h netinet/if_tr.h \
176 netipx/ipx.h netash/ash.h netax25/ax25.h netatalk/at.h \
177 netrom/netrom.h netpacket/packet.h netrose/rose.h \
178 neteconet/ec.h netiucv/iucv.h
179 sysdep_routines += netlink_assert_response
180 endif
182 # Don't compile the ctype glue code, since there is no old non-GNU C library.
183 inhibit-glue = yes
185 ifeq ($(subdir),dirent)
186 sysdep_routines += getdirentries getdirentries64
187 endif
189 ifeq ($(subdir),nis)
190 CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
191 endif
193 ifeq ($(subdir),io)
194 sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
195 sync_file_range fallocate fallocate64
196 sysdep_headers += bits/fcntl-linux.h
198 tests += tst-fallocate tst-fallocate64
199 endif
201 ifeq ($(subdir),elf)
202 sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir \
203 dl-fxstatat64
205 libof-lddlibc4 = lddlibc4
207 others += pldd
208 install-bin += pldd
209 $(objpfx)pldd: $(objpfx)xmalloc.o
210 endif
212 ifeq ($(subdir),rt)
213 CFLAGS-mq_send.c += -fexceptions
214 CFLAGS-mq_receive.c += -fexceptions
215 endif
217 ifeq ($(subdir),nscd)
218 sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_SENDFILE -DHAVE_INOTIFY -DHAVE_NETLINK
219 CFLAGS-gai.c += -DNEED_NETLINK
220 endif
222 ifeq ($(subdir),nptl)
223 tests += tst-align-clone tst-getpid1 \
224 tst-thread-affinity-pthread tst-thread-affinity-pthread2 \
225 tst-thread-affinity-sched
226 tests-internal += tst-setgetname
227 endif