21b560790e85fd45eb86ac4b018ab802002d7ce2
[platform/upstream/glibc.git] / sysdeps / unix / sysv / linux / Makefile
1 ifeq ($(subdir),csu)
2 sysdep_routines += errno-loc
3 endif
4
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
9
10 ifeq ($(subdir),malloc)
11 CFLAGS-malloc.c += -DMORECORE_CLEARS=2
12 endif
13
14 ifeq ($(subdir),socket)
15 sysdep_routines += internal_accept4 recvmmsg internal_recvmmsg sendmmsg \
16                    internal_sendmmsg
17 endif
18
19 ifeq ($(subdir),misc)
20 include $(firstword $(wildcard $(sysdirs:=/sysctl.mk)))
21
22 sysdep_routines += clone llseek umount umount2 readahead \
23                    setfsuid setfsgid makedev epoll_pwait signalfd \
24                    eventfd eventfd_read eventfd_write prlimit
25
26 CFLAGS-gethostid.c = -fexceptions
27 CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=0x80000000-__getpagesize()"
28
29 sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
30                   sys/klog.h sys/kdaemon.h \
31                   sys/user.h sys/procfs.h sys/prctl.h \
32                   sys/kd.h sys/soundcard.h sys/vt.h \
33                   sys/quota.h sys/fsuid.h \
34                   scsi/sg.h scsi/scsi.h scsi/scsi_ioctl.h sys/pci.h \
35                   sys/ultrasound.h sys/raw.h sys/personality.h sys/epoll.h \
36                   bits/a.out.h sys/inotify.h sys/signalfd.h sys/eventfd.h \
37                   sys/timerfd.h sys/fanotify.h bits/eventfd.h bits/inotify.h \
38                   bits/signalfd.h bits/timerfd.h bits/epoll.h \
39                   bits/socket_type.h bits/syscall.h
40
41 tests += tst-clone
42
43 # Generate the list of SYS_* macros for the system calls (__NR_* macros).
44
45 # If there is more than one syscall list for different architecture
46 # variants, the CPU/Makefile defines abi-variants to be a list of names
47 # for those variants (e.g. 32 64), and, for each variant, defines
48 # abi-$(variant)-options to be compiler options to cause <asm/unistd.h>
49 # to define the desired list of syscalls and abi-$(variant)-condition to
50 # be the condition for those options to use in a C #if condition.
51 # abi-includes may be defined to a list of headers to include
52 # in the generated header, if the default does not suffice.
53
54 $(objpfx)bits/syscall%h $(objpfx)bits/syscall%d: ../sysdeps/unix/sysv/linux/sys/syscall.h
55         $(make-target-directory)
56         { \
57          echo '/* Generated at libc build time from kernel syscall list.  */';\
58          echo ''; \
59          echo '#ifndef _SYSCALL_H'; \
60          echo '# error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."'; \
61          echo '#endif'; \
62          echo ''; \
63          $(foreach h,$(abi-includes), echo '#include <$(h)>';) \
64          echo ''; \
65          $(if $(abi-variants), \
66          $(foreach v,$(abi-variants),\
67          $(CC) -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
68                -x c $(sysincludes) $< $(abi-$(v)-options) \
69                -D_LIBC -dM | \
70          sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
71          LC_ALL=C sort > $(@:.d=.h).new$(v); \
72          $(if $(abi-$(v)-condition),\
73          echo '#if $(abi-$(v)-condition)';) \
74          cat $(@:.d=.h).new$(v); \
75          $(if $(abi-$(v)-condition),echo '#endif';) \
76          rm -f $(@:.d=.h).new$(v); \
77          ), \
78          $(CC) -E -MD -MP -MF $(@:.h=.d)-t$(v) -MT '$(@:.d=.h) $(@:.h=.d)' \
79                -x c $(sysincludes) $< \
80                -D_LIBC -dM | \
81          sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' | \
82          LC_ALL=C sort;) \
83         } > $(@:.d=.h).new
84         mv -f $(@:.d=.h).new $(@:.d=.h)
85 ifdef abi-variants
86 ifneq (,$(objpfx))
87         sed $(sed-remove-objpfx) \
88          $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) > $(@:.h=.d)-t3
89 else
90         cat $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v)) \
91          > $(@:.h=.d)-t3
92 endif
93         rm -f $(foreach v,$(abi-variants),$(@:.h=.d)-t$(v))
94         mv -f $(@:.h=.d)-t3 $(@:.h=.d)
95 else
96         mv -f $(@:.h=.d)-t $(@:.h=.d)
97 endif
98
99 ifndef no_deps
100 # Get the generated list of dependencies (probably /usr/include/asm/unistd.h).
101 -include $(objpfx)bits/syscall.d
102 endif
103 generated += bits/syscall.h bits/syscall.d
104 endif
105
106 ifeq ($(subdir),time)
107 sysdep_headers += sys/timex.h bits/timex.h
108
109 sysdep_routines += ntp_gettime ntp_gettimex
110 endif
111
112 ifeq ($(subdir),socket)
113 sysdep_headers += net/if_ppp.h net/ppp-comp.h \
114                   net/ppp_defs.h net/if_arp.h net/route.h net/ethernet.h \
115                   net/if_slip.h net/if_packet.h net/if_shaper.h
116 sysdep_routines += cmsg_nxthdr sa_len
117 endif
118
119 ifeq ($(subdir),sunrpc)
120 sysdep_headers += nfs/nfs.h
121 endif
122
123 ifeq ($(subdir),termios)
124 sysdep_headers += termio.h
125 endif
126
127 ifeq ($(subdir),posix)
128 sysdep_headers += bits/initspin.h
129
130 sysdep_routines += exit-thread sched_getcpu
131
132 tests += tst-getcpu
133 endif
134
135 ifeq ($(subdir),inet)
136 sysdep_headers += netinet/if_fddi.h netinet/if_tr.h \
137                   netipx/ipx.h netash/ash.h netax25/ax25.h netatalk/at.h \
138                   netrom/netrom.h netpacket/packet.h netrose/rose.h \
139                   neteconet/ec.h netiucv/iucv.h
140 endif
141
142 # Don't compile the ctype glue code, since there is no old non-GNU C library.
143 inhibit-glue = yes
144
145 ifeq ($(subdir),dirent)
146 sysdep_routines += getdirentries getdirentries64
147 endif
148
149 ifeq ($(subdir),nis)
150 CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
151 endif
152
153 ifeq ($(subdir),io)
154 sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
155                    sync_file_range open_2 open64_2 fallocate fallocate64
156 endif
157
158 ifeq ($(subdir),elf)
159 sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64 dl-opendir \
160                         dl-fxstatat64
161
162 CPPFLAGS-lddlibc4 += -DNOT_IN_libc
163 endif
164
165 ifeq ($(subdir),rt)
166 CFLAGS-mq_send.c += -fexceptions
167 CFLAGS-mq_receive.c += -fexceptions
168 endif
169
170 ifeq ($(subdir),nscd)
171 sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_SENDFILE -DHAVE_INOTIFY -DHAVE_NETLINK
172 CFLAGS-gai.c += -DNEED_NETLINK
173 endif