* sysdeps/unix/sysv/linux/bits/sched.h: Declare unshare.
[glibc.git] / sysdeps / unix / Makefile
blobc1da42f953e3ba539668a1f143db4c56e754ee3a
1 # Copyright (C) 1991,1992,1993,1994,1995,1996,1997,1998,1999,2003, 2006
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
20 # The unix-specific configure fragment writes `unix-generated' in config.make.
21 config-generated := $(config-generated) $(unix-generated)
23 ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
24 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/local_lim.h))))))
26 ifneq (,$(wildcard $(sysincludedir)/sys/param.h))
27 mk-local_lim-CFLAGS += -DHAVE_SYS_PARAM_H
28 endif
29 ifneq (,$(wildcard $(sysincludedir)/sys/limits.h))
30 mk-local_lim-CFLAGS += -DHAVE_SYS_LIMITS_H
31 endif
32 ifneq (,$(wildcard $(sysincludedir)/limits.h))
33 mk-local_lim-CFLAGS += -DHAVE_LIMITS_H
34 endif
36 $(common-objpfx)bits/local_lim.h: $(common-objpfx)mk-local_lim
37 $(dir $<)$(notdir $<) > $@-t
38 mv -f $@-t $@
39 $(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c
40 $(common-objdir-compile)
42 before-compile += $(common-objpfx)bits/local_lim.h
43 common-generated += bits/local_lim.h mk-local_lim
45 endif
47 ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
48 $(patsubst %/sys/param.h,%/,\
49 $(firstword $(wildcard $(+sysdep_dirs:%=%/sys/param.h))))))
51 before-compile := $(before-compile) $(common-objpfx)sys/param.h
53 $(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
54 $(make-target-directory)
55 (echo '#ifndef _SYS_PARAM_H'; \
56 echo '#define _SYS_PARAM_H 1'; \
57 echo '#include <endian.h>'; \
58 $(AWK) < $< \
59 '/^#define[ ]*NULL/ { print "#ifndef NULL"; \
60 print $$0; \
61 print "#endif"; \
62 was_null = 1 } \
63 { if (!was_null) print $$0; \
64 was_null = 0 }'; \
65 echo '#ifndef MAXHOSTNAMELEN'; \
66 echo '#define MAXHOSTNAMELEN 64 /* XXX */'; \
67 echo '#endif /* No MAXHOSTNAMELEN. */'; \
68 echo '#endif /* sys/param.h */') > $@-tmp
69 mv $@-tmp $@
71 $(common-objpfx)param.h.c: $(sysincludedir)/sys/param.h
72 rm -f $@
73 cp $< $@
74 $(common-objpfx)param.h.dep: $(common-objpfx)param.h.c \
75 $(sysdep_dir)/unix/Makefile
76 $(+mkdep) -I$(sysincludedir) $< \
77 | sed > $@-t \
78 -e 's@$(sysincludedir)/sys/param.h@@' \
79 -e 's@^.*:@@' \
80 -e 's@$<@@g' \
81 -e 's@$(sysincludedir)/*@@g' \
82 -e 's@\\$$@@' \
83 -e 's@^@sys/param.h-includes := $$(sys/param.h-includes) @'
84 mv $@-t $@
86 # Get the generated definition of sys/param.h-includes.
87 ifndef no_deps
88 -include $(common-objpfx)param.h.dep
89 endif
91 # Don't preempt our own headers.
92 sys/param.h-includes := \
93 $(filter-out $(patsubst $(..)%,%,\
94 $(wildcard $(addprefix $(..),\
95 $(sys/param.h-includes)))),\
96 $(sys/param.h-includes))
99 .PHONY: sys/param.h-includes
100 sys/param.h-includes: $(addprefix $(common-objpfx),$(sys/param.h-includes))
102 ifdef sys/param.h-includes
103 # Copy the system files to $(common-objdir).
104 $(addprefix $(common-objpfx),$(sys/param.h-includes)): $(common-objpfx)%: \
105 $(sysincludedir)/%
106 $(make-target-directory)
107 # Some of these files sometimes contain conflicting declarations for htons,
108 # ntohs, etc. They also often contain definitions of *_ENDIAN and
109 # BYTE_ORDER, which we define ourselves in <endian.h>.
110 sed -e '/[ ]*[hn]to[nh][sl][ (]*/d' \
111 -e '/^#define[ ]*[A-Z]*_ENDIAN/d' \
112 -e '/^#define[ ]*BYTE_ORDER/d' \
113 $< > $@-t
114 mv $@-t $@
115 endif
117 common-generated := $(common-generated) \
118 sys/param.h $(sys/param.h-includes) param.h.c param.h.dep
121 ifeq ($(subdir),misc)
123 # Install system headers the system sys/param.h uses.
125 sysdep_headers := $(sysdep_headers) $(sys/param.h-includes)
127 endif # misc
129 endif # No sysdep sys/param.h.
131 ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
132 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/errno.h))))))
134 # These need to exist before any compiling is done,
135 # so cpp doesn't instead find the generic versions.
136 before-compile := $(before-compile) $(common-objpfx)bits/errno.h
138 $(common-objpfx)bits/errno.h: $(common-objpfx)make-errnos
139 $(dir $<)$(notdir $<) > $@-tmp
140 mv $@-tmp $@
142 $(common-objpfx)make-errnos: $(common-objpfx)make-errnos.c
143 $(common-objdir-compile)
145 $(common-objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \
146 $(sysdep_dir)/unix/errnos.awk $(common-objpfx)errnos
147 $(AWK) -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
148 mv $@T $@
150 $(common-objpfx)errnos: $(wildcard $(sysincludedir)/errno.h \
151 $(sysincludedir)/sys/errno.h)
152 sed -n 's/^#define[ ]*\(E[A-Z0-9][A-Z0-9]*\)[ ].*$$/\1/p' \
153 $^ > $@-tmp
154 mv $@-tmp $@
156 common-generated := $(common-generated) \
157 errnos.h errnos make-errnos make-errnos.c
158 endif
160 ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
161 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/ioctls.h))))))
163 before-compile := $(before-compile) $(common-objpfx)bits/ioctls.h
165 $(common-objpfx)bits/ioctls.h: $(common-objpfx)make-ioctls
166 $(dir $<)$(notdir $<) > $@-tmp
167 mv $@-tmp $@
169 ioctl-includes := sys/termios.h net/nit.h
170 ioctl-includes := $(wildcard $(addprefix $(sysincludedir)/,$(ioctl-includes)))
171 make-ioctls-CFLAGS := $(subst /,_,$(subst .,_,\
172 $(patsubst $(sysincludedir)/%,-DHAVE_%,\
173 $(ioctl-includes))))
175 $(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c
176 $(common-objdir-compile)
178 $(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
179 $(sysdep_dir)/unix/ioctls.awk \
180 $(common-objpfx)ioctls
181 $(AWK) -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
182 mv $@T $@
185 bits_termios.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/termios.h)))
186 ifeq ($(bits_termios.h),$(sysdep_dir)/generic/bits/termios.h)
187 bits_termios.h := # Ignore the generic version.
188 endif
190 # If there is a system-specific <bits/termios.h> file, we want to omit
191 # all the symbols it defines from ioctls. Otherwise, both
192 # <bits/ioctls.h> and <bits/termios.h> would define them. The
193 # system-specific <bits/termios.h> file presumably defines them with
194 # the same values as we find from the system's headers. We also want
195 # to omit from ioctls the symbols defined in our own
196 # <sys/ttydefaults.h>, to avoid multiple definition conflicts. We use
197 # snarf-ioctls on these files to find what symbols we want to omit.
198 # fgrep -xv gives all lines which do not match in their entirety;
199 # without -x, CSTOP's presence elided TIOCSTOP.
201 $(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
202 $(sysincludedir)/sys/ioctl.h $(ioctl-includes)
203 $(dir $<)$(notdir $<) $(filter-out $<,$^) \
204 | fgrep -xv "`($(dir $<)$(notdir $<) $(bits_termios.h) \
205 $(..)sysdeps/generic/sys/ttydefaults.h; \
206 echo NULL) \
207 | sort | uniq`" \
208 | sort | uniq | tr '\012' ' ' > $@-tmp
209 mv $@-tmp $@
211 common-generated := $(common-generated) \
212 bits/ioctls.h ioctls make-ioctls make-ioctls.c
213 endif
215 ifeq ($(subdir),stdio-common)
216 ifeq (,$(filter-out $(sysdep_dir)/generic/ $(objpfx),\
217 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errlist.c))))))
219 before-compile: $(objpfx)errlist.c
220 $(objpfx)errlist.c: $(objpfx)make_errlist
221 @rm -f $@
222 $(dir $<)$(notdir $<) > $@-tmp
223 mv $@-tmp $@
225 $(objpfx)make_errlist: $(sysdep_dir)/unix/make_errlist.c
226 $(native-compile)
228 generated := $(generated) make_errlist errlist.c
230 endif
231 endif # stdio-common
233 ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
234 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/sys/syscall.h))))))
236 # The syscall code assumes a file <sys/syscall.h> that defines macros
237 # `SYS_call' for syscall `call'. Variations on this I have seen include:
238 # it's in <sys/syscall.h>;
239 # it's in <sys.s>;
240 # it defines `CALL' instead of `SYS_call'.
241 # Irix has a <syscall.h> which is not what we want, so check for <sys.s> first.
243 # Find a file that might have these. NOTE: This list of possibilities is
244 # repeated in sysdeps/unix/configure and the two should be kept in sync.
245 syscall.h := $(firstword $(wildcard $(addprefix $(sysincludedir)/, \
246 sys.s sys/sys.s \
247 sys.S sys/sys.S \
248 syscall.h sys/syscall.h \
250 ifdef syscall.h
252 # Transmogrify any of several formats of the file into the one we want.
253 $(common-objpfx)sys/syscall.h: $(syscall.h)
254 $(make-target-directory)
255 tr '[A-Z]' '[a-z]' < $< | \
256 sed -e 's/[ ]sys_/ /' \
257 -e 's/^#define[ ]*\([a-z0-9_]*\)[ ]*/#define SYS_\1 /' \
258 -e 's/[ ]sys_/ SYS_/' \
259 -e 's/SYS_syscall_basenum/syscall_basenum/g' \
260 -e 's/SYS_kerncall_basenum/kerncall_basenum/g' \
261 -e 's/SYS_sysvoffset/sysvoffset/g' \
262 -e '/^#/!d' \
263 -e '/^#ident/d' \
264 -e 's-\(/\*[^*]*\)$$-\1\*/-' \
265 > $@-tmp
266 mv $@-tmp $@
268 before-compile += $(common-objpfx)sys/syscall.h
269 common-generated += sys/syscall.h
271 endif
273 endif
275 ifndef inhibit-unix-syscalls
277 # Sysdep dirs unix/... can contain a file syscalls.list,
278 # which specifies objects to be compiled as simple Unix system calls.
280 -include $(common-objpfx)sysd-syscalls
281 omit-deps += $(unix-syscalls)
283 ifeq (misc,$(subdir))
284 sysdep_routines += $(unix-extra-syscalls)
286 ifdef unix-stub-syscalls
287 # The system call entry points in this list are supposed to be additional
288 # functions not overriding any other sysdeps/.../call.c implementation, but
289 # their system call numbers are unavailable in the kernel headers we're
290 # using. Instead of a system call stub, these get a function that fails
291 # with ENOSYS. We just generate a single module defining one function and
292 # making all these entry point names aliases for it.
293 sysdep_routines += stub-syscalls
294 $(objpfx)stub-syscalls.c: $(common-objpfx)sysd-syscalls \
295 $(..)sysdeps/unix/Makefile
296 $(make-target-directory)
297 (for call in $(unix-stub-syscalls); do \
298 echo "#define $$call RENAMED_$$call"; \
299 done; \
300 echo '#include <errno.h>'; \
301 for call in $(unix-stub-syscalls); do \
302 echo "#undef $$call"; \
303 done; \
304 echo 'long int _no_syscall (void)'; \
305 echo '{ __set_errno (ENOSYS); return -1L; }'; \
306 for call in $(unix-stub-syscalls); do \
307 case $$call in \
308 *@@*) ver=$${call##*@}; call=$${call%%*@}; \
309 echo "strong_alias (_no_syscall, $${call}_$${ver})"; \
310 echo "default_symbol_version \
311 ($${call}_$${ver}, $$call, $$ver);" ;; \
312 *@@*) ver=$${call##*@}; call=$${call%%*@}; \
313 echo "strong_alias (_no_syscall, $${call}_$${ver})"; \
314 echo "symbol_version ($${call}_$${ver}, $$call, $$ver);" ;; \
315 *) echo "weak_alias (_no_syscall, $$call)"; \
316 echo "stub_warning ($$call)"; \
317 echo "weak_alias (_no_syscall, __GI_$$call)" ;; \
318 esac; \
319 echo '#include <stub-tag.h>'; \
320 done) > $@T
321 mv -f $@T $@
322 generated += stub-syscalls.c
323 endif
324 endif
326 export sysdirs
327 export asm_CPP := $(COMPILE.S) -E -x assembler-with-cpp
329 # This is the end of the pipeline for compiling the syscall stubs.
330 # The stdin in assembler with cpp using sysdep.h macros.
331 # Be sure to disable debugging info since it would all just say "<stdin>".
332 compile-syscall = $(filter-out -g%,$(COMPILE.S)) -x assembler-with-cpp -o $@ -
334 ifndef avoid-generated
335 $(common-objpfx)sysd-syscalls: $(..)sysdeps/unix/make-syscalls.sh \
336 $(wildcard $(+sysdep_dirs:%=%/syscalls.list))
337 for dir in $(+sysdep_dirs); do \
338 test -f $$dir/syscalls.list && \
339 { $(SHELL) $(dir $<)$(notdir $<) $$dir || exit 1; }; \
340 test $$dir = $(..)sysdeps/unix && break; \
341 done > $@T
342 mv -f $@T $@
343 endif
345 # The syscall objects depend on s-proto.d or s-proto-cancel.d, which
346 # are generated to specify dependencies generated syscalls have on
347 # headers.
348 # These deps use file names relative to a subdir, so don't
349 # include them in the parent directory.
350 ifneq (,$(filter $(unix-syscalls),$(routines) $(sysdep_routines) $(aux)))
351 ifndef no_deps
352 -include $(common-objpfx)s-proto.d
353 -include $(common-objpfx)s-proto-bp.d
354 -include $(common-objpfx)s-proto-cancel.d
355 endif
356 endif
358 $(common-objpfx)s-%.d: $(..)sysdeps/unix/s-%.S \
359 $(wildcard $(+sysdep_dirs:%=%/syscalls.list))
360 $(+make-deps)
362 common-generated += s-proto.d s-proto-bp.d s-proto-cancel.d
363 postclean-generated += sysd-syscalls
365 endif