1 # Copyright (C) 1991,1992,1993,1994,1995,1996,1997,1998,1999,2003,2006,2008,2009
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
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
29 ifneq (,$(wildcard $(sysincludedir
)/sys
/limits.h
))
30 mk-local_lim-CFLAGS
+= -DHAVE_SYS_LIMITS_H
32 ifneq (,$(wildcard $(sysincludedir
)/limits.h
))
33 mk-local_lim-CFLAGS
+= -DHAVE_LIMITS_H
36 $(common-objpfx
)bits
/local_lim.h
: $(common-objpfx
)mk-local_lim
37 $(dir $<)$(notdir $<) > $@
-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
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>'; \
59 '/^#define[ ]*NULL/ { print "#ifndef NULL"; \
63 { if (!was_null) print $$0; \
65 echo
'#ifndef MAXHOSTNAMELEN'; \
66 echo
'#define MAXHOSTNAMELEN 64 /* XXX */'; \
67 echo
'#endif /* No MAXHOSTNAMELEN. */'; \
68 echo
'#endif /* sys/param.h */') > $@
-tmp
71 $(common-objpfx
)param.h.c
: $(sysincludedir
)/sys
/param.h
74 $(common-objpfx
)param.h.dep
: $(common-objpfx
)param.h.c \
75 $(sysdep_dir
)/unix
/Makefile
76 $(+mkdep
) -I
$(sysincludedir
) $< \
78 -e
's@$(sysincludedir)/sys/param.h@@' \
81 -e
's@$(sysincludedir)/*@@g' \
83 -e
's@^@sys/param.h-includes := $$(sys/param.h-includes) @'
86 # Get the generated definition of sys/param.h-includes.
88 -include $(common-objpfx
)param.h.dep
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
)%: \
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' \
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
)
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
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
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' \
156 common-generated
:= $(common-generated
) \
157 errnos.h errnos make-errnos make-errnos.c
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
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_
%,\
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
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.
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; \
208 |
sort | uniq | tr
'\012' ' ' > $@
-tmp
211 common-generated
:= $(common-generated
) \
212 bits
/ioctls.h ioctls make-ioctls make-ioctls.c
215 ifeq (,$(filter-out $(sysdep_dir
)/generic
/ $(common-objpfx
),\
216 $(dir $(firstword $(wildcard $(+sysdep_dirs
:%=%/sys
/syscall.h
))))))
218 # The syscall code assumes a file <sys/syscall.h> that defines macros
219 # `SYS_call' for syscall `call'. Variations on this I have seen include:
220 # it's in <sys/syscall.h>;
222 # it defines `CALL' instead of `SYS_call'.
223 # Irix has a <syscall.h> which is not what we want, so check for <sys.s> first.
225 # Find a file that might have these. NOTE: This list of possibilities is
226 # repeated in sysdeps/unix/configure and the two should be kept in sync.
227 syscall.h
:= $(firstword $(wildcard $(addprefix $(sysincludedir
)/, \
230 syscall.h sys
/syscall.h \
234 # Transmogrify any of several formats of the file into the one we want.
235 $(common-objpfx
)sys
/syscall.h
: $(syscall.h
)
236 $(make-target-directory
)
237 tr
'[A-Z]' '[a-z]' < $< | \
238 sed
-e
's/[ ]sys_/ /' \
239 -e
's/^#define[ ]*\([a-z0-9_]*\)[ ]*/#define SYS_\1 /' \
240 -e
's/[ ]sys_/ SYS_/' \
241 -e
's/SYS_syscall_basenum/syscall_basenum/g' \
242 -e
's/SYS_kerncall_basenum/kerncall_basenum/g' \
243 -e
's/SYS_sysvoffset/sysvoffset/g' \
246 -e
's-\(/\*[^*]*\)$$-\1\*/-' \
250 before-compile
+= $(common-objpfx
)sys
/syscall.h
251 common-generated
+= sys
/syscall.h
257 ifndef inhibit-unix-syscalls
259 # Sysdep dirs unix/... can contain a file syscalls.list,
260 # which specifies objects to be compiled as simple Unix system calls.
262 -include $(common-objpfx
)sysd-syscalls
264 ifeq (misc
,$(subdir
))
265 sysdep_routines
+= $(unix-extra-syscalls
)
267 ifdef unix-stub-syscalls
268 # The system call entry points in this list are supposed to be additional
269 # functions not overriding any other sysdeps/.../call.c implementation, but
270 # their system call numbers are unavailable in the kernel headers we're
271 # using. Instead of a system call stub, these get a function that fails
272 # with ENOSYS. We just generate a single module defining one function and
273 # making all these entry point names aliases for it.
274 sysdep_routines
+= stub-syscalls
275 $(objpfx
)stub-syscalls.c
: $(common-objpfx
)sysd-syscalls \
276 $(..
)sysdeps
/unix
/Makefile
277 $(make-target-directory
)
278 (for call in
$(unix-stub-syscalls
); do \
279 echo
"#define $$call RENAMED_$$call"; \
281 echo
'#include <errno.h>'; \
282 for call in
$(unix-stub-syscalls
); do \
283 echo
"#undef $$call"; \
285 echo
'long int _no_syscall (void)'; \
286 echo
'{ __set_errno (ENOSYS); return -1L; }'; \
287 for call in
$(unix-stub-syscalls
); do \
289 *@@
*) ver
=$${call
##*@}; call=$${call%%*@}; \
290 echo
"strong_alias (_no_syscall, $${call}_$${ver})"; \
291 echo
"default_symbol_version \
292 ($${call}_$${ver}, $$call, $$ver);" ;; \
293 *@@
*) ver
=$${call
##*@}; call=$${call%%*@}; \
294 echo
"strong_alias (_no_syscall, $${call}_$${ver})"; \
295 echo
"symbol_version ($${call}_$${ver}, $$call, $$ver);" ;; \
296 *) echo
"weak_alias (_no_syscall, $$call)"; \
297 echo
"stub_warning ($$call)"; \
298 echo
"weak_alias (_no_syscall, __GI_$$call)" ;; \
300 echo
'#include <stub-tag.h>'; \
303 generated
+= stub-syscalls.c
307 # This is the end of the pipeline for compiling the syscall stubs.
308 # The stdin is assembler with cpp using sysdep.h macros.
309 compile-syscall
= $(COMPILE.S
) -o
$@
-x assembler-with-cpp
- \
310 $(compile-mkdep-flags
)
312 ifndef avoid-generated
313 $(common-objpfx
)sysd-syscalls
: $(..
)sysdeps
/unix
/make-syscalls.sh \
314 $(wildcard $(+sysdep_dirs
:%=%/syscalls.list
))
315 for
dir in
$(+sysdep_dirs
); do \
316 test -f
$$dir/syscalls.list
&& \
317 { sysdirs
='$(sysdirs)' \
318 asm_CPP
='$(COMPILE.S) -E -x assembler-with-cpp' \
319 $(SHELL
) $(dir $<)$(notdir $<) $$dir || exit
1; }; \
320 test $$dir = $(..
)sysdeps
/unix
&& break
; \
325 # The $(bppfx)syscall.ob objects depend on s-proto-bp.d, which are
326 # generated to specify dependencies generated BP stubs have on headers.
327 # These deps use file names relative to a subdir, so don't
328 # include them in the parent directory.
329 ifneq (,$(filter $(unix-syscalls
),$(routines
) $(sysdep_routines
) $(aux
)))
331 -include $(common-objpfx
)s-proto-bp.d
335 $(common-objpfx
)s-
%.d
: $(..
)sysdeps
/unix
/s-
%.S \
336 $(wildcard $(+sysdep_dirs
:%=%/syscalls.list
))
339 common-generated
+= s-proto-bp.d
340 postclean-generated
+= sysd-syscalls