]> sourceware.org Git - glibc.git/blame - sysdeps/unix/Makefile
Update.
[glibc.git] / sysdeps / unix / Makefile
CommitLineData
df4ef2ab 1# Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
28f540f4
RM
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
5# modify it under the terms of the GNU Library General Public License as
6# published by the Free Software Foundation; either version 2 of the
7# License, or (at your option) any later version.
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12# Library General Public License for more details.
13
14# You should have received a copy of the GNU Library General Public
df4ef2ab
UD
15# License along with the GNU C Library; see the file COPYING.LIB. If not,
16# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17# Boston, MA 02111-1307, USA.
28f540f4
RM
18
19# The unix-specific configure fragment writes `unix-generated' in config.make.
20config-generated := $(config-generated) $(unix-generated)
21\f
f2ea0f5b 22ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
5107cf1d 23 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/local_lim.h))))))
28f540f4
RM
24
25ifneq (,$(wildcard $(sysincludedir)/sys/param.h))
377a515b 26mk-local_lim-CFLAGS += -DHAVE_SYS_PARAM_H
28f540f4
RM
27endif
28ifneq (,$(wildcard $(sysincludedir)/sys/limits.h))
377a515b 29mk-local_lim-CFLAGS += -DHAVE_SYS_LIMITS_H
28f540f4
RM
30endif
31ifneq (,$(wildcard $(sysincludedir)/limits.h))
377a515b 32mk-local_lim-CFLAGS += -DHAVE_LIMITS_H
28f540f4
RM
33endif
34
5107cf1d 35$(common-objpfx)bits/local_lim.h: $(common-objpfx)mk-local_lim
377a515b
UD
36 $(dir $<)$(notdir $<) > $@-t
37 mv -f $@-t $@
28f540f4 38$(common-objpfx)mk-local_lim: $(sysdep_dir)/unix/mk-local_lim.c
377a515b 39 $(common-objdir-compile)
28f540f4 40
5107cf1d 41before-compile := $(before-compile) $(common-objpfx)bits/local_lim.h
28f540f4
RM
42common-generated := $(common-generated) local_lim.h mk-local_lim
43
44endif
45\f
f2ea0f5b 46ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
28f540f4
RM
47 $(patsubst %/sys/param.h,%/,\
48 $(firstword $(wildcard $(+sysdep_dirs:%=%/sys/param.h))))))
49
50before-compile := $(before-compile) $(common-objpfx)sys/param.h
51
52$(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
377a515b 53 $(make-target-directory)
5107cf1d
UD
54 (echo '#ifndef _SYS_PARAM_H'; \
55 echo '#define _SYS_PARAM_H 1'; \
28f540f4
RM
56 echo '#include <endian.h>'; \
57 awk < $< \
58 '/^#define[ ]*NULL/ { print "#ifndef NULL"; \
59 print $$0; \
60 print "#endif"; \
61 was_null = 1 } \
62 { if (!was_null) print $$0; \
63 was_null = 0 }'; \
64 echo '#ifndef MAXHOSTNAMELEN'; \
65 echo '#define MAXHOSTNAMELEN 64 /* XXX */'; \
66 echo '#endif /* No MAXHOSTNAMELEN. */'; \
67 echo '#endif /* sys/param.h */') > $@-tmp
68 mv $@-tmp $@
69
70$(common-objpfx)param.h.c: $(sysincludedir)/sys/param.h
71 rm -f $@
72 cp $< $@
73$(common-objpfx)param.h.dep: $(common-objpfx)param.h.c \
74 $(sysdep_dir)/unix/Makefile
75 $(+mkdep) -I$(sysincludedir) $< \
377a515b 76 | sed > $@-t \
28f540f4
RM
77 -e 's@^.*:@@' \
78 -e 's@$<@@g' \
79 -e 's@$(sysincludedir)/*@@g' \
80 -e 's@\\$$@@' \
81 -e 's@^@sys/param.h-includes := $$(sys/param.h-includes) @'
377a515b 82 mv $@-t $@
28f540f4
RM
83
84# Get the generated definition of sys/param.h-includes.
85ifndef no_deps
377a515b 86-include $(common-objpfx)param.h.dep
28f540f4
RM
87endif
88
aeb72b16 89# Don't preempt our own headers.
28f540f4
RM
90sys/param.h-includes := \
91 $(filter-out $(patsubst $(..)%,%,\
92 $(wildcard $(addprefix $(..),\
93 $(sys/param.h-includes)))),\
94 $(sys/param.h-includes))
95
96
97.PHONY: sys/param.h-includes
98sys/param.h-includes: $(addprefix $(common-objpfx),$(sys/param.h-includes))
99
100ifdef sys/param.h-includes
101# Copy the system files to $(common-objdir).
102$(addprefix $(common-objpfx),$(sys/param.h-includes)): $(common-objpfx)%: \
103 $(sysincludedir)/%
377a515b 104 $(make-target-directory)
28f540f4
RM
105# Some of these files sometimes contain conflicting declarations for htons,
106# ntohs, etc. They also often contain definitions of *_ENDIAN and
107# BYTE_ORDER, which we define ourselves in <endian.h>.
108 sed -e '/[ ]*[hn]to[nh][sl][ (]*/d' \
109 -e '/^#define[ ]*[A-Z]*_ENDIAN/d' \
110 -e '/^#define[ ]*BYTE_ORDER/d' \
111 $< > $@-t
112 mv $@-t $@
113endif
114
115common-generated := $(common-generated) \
116 sys/param.h $(sys/param.h-includes) param.h.c param.h.dep
117
118
119ifeq ($(subdir),misc)
120
121# Install system headers the system sys/param.h uses.
122
123sysdep_headers := $(sysdep_headers) $(sys/param.h-includes)
124
125endif # misc
126
127endif # No sysdep sys/param.h.
128\f
f2ea0f5b 129ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
5107cf1d 130 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/errno.h))))))
28f540f4
RM
131
132# These need to exist before any compiling is done,
f2ea0f5b 133# so cpp doesn't instead find the generic versions.
5107cf1d 134before-compile := $(before-compile) $(common-objpfx)bits/errno.h
28f540f4 135
5107cf1d 136$(common-objpfx)bits/errno.h: $(common-objpfx)make-errnos
28f540f4
RM
137 $(dir $<)$(notdir $<) > $@-tmp
138 mv $@-tmp $@
139
140$(common-objpfx)make-errnos: $(common-objpfx)make-errnos.c
141 $(common-objdir-compile)
142
143$(common-objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \
144 $(sysdep_dir)/unix/errnos.awk $(common-objpfx)errnos
145 awk -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
146 mv $@T $@
147
148$(common-objpfx)errnos: $(wildcard $(sysincludedir)/errno.h \
149 $(sysincludedir)/sys/errno.h)
377a515b
UD
150 sed -n 's/^#define[ ]*\(E[A-Z0-9][A-Z0-9]*\)[ ].*$$/\1/p' \
151 $^ > $@-tmp
28f540f4
RM
152 mv $@-tmp $@
153
154common-generated := $(common-generated) \
155 errnos.h errnos make-errnos make-errnos.c
156endif
157\f
f2ea0f5b 158ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
5107cf1d 159 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/ioctls.h))))))
28f540f4 160
5107cf1d 161before-compile := $(before-compile) $(common-objpfx)bits/ioctls.h
28f540f4 162
5107cf1d 163$(common-objpfx)bits/ioctls.h: $(common-objpfx)make-ioctls
28f540f4
RM
164 $(dir $<)$(notdir $<) > $@-tmp
165 mv $@-tmp $@
166
167ioctl-includes := sys/termios.h net/nit.h
168ioctl-includes := $(wildcard $(addprefix $(sysincludedir)/,$(ioctl-includes)))
169make-ioctls-CFLAGS := $(subst /,_,$(subst .,_,\
170 $(patsubst $(sysincludedir)/%,-DHAVE_%,\
171 $(ioctl-includes))))
172
173$(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c
377a515b 174 $(common-objdir-compile)
28f540f4
RM
175
176$(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
177 $(sysdep_dir)/unix/ioctls.awk \
178 $(common-objpfx)ioctls
179 awk -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
180 mv $@T $@
181
182
5107cf1d
UD
183bits_termios.h := $(firstword $(wildcard $(+sysdep_dirs:%=%/bits/termios.h)))
184ifeq ($(bits_termios.h),$(sysdep_dir)/generic/bits/termios.h)
185bits_termios.h := # Ignore the generic version.
28f540f4
RM
186endif
187
5107cf1d
UD
188# If there is a system-specific <bits/termios.h> file, we want to omit
189# all the symbols it defines from ioctls. Otherwise, both
190# <bits/ioctls.h> and <bits/termios.h> would define them. The
191# system-specific <bits/termios.h> file presumably defines them with
192# the same values as we find from the system's headers. We also want
193# to omit from ioctls the symbols defined in our own
28f540f4 194# <sys/ttydefaults.h>, to avoid multiple definition conflicts. We use
5107cf1d
UD
195# snarf-ioctls on these files to find what symbols we want to omit.
196# fgrep -xv gives all lines which do not match in their entirety;
197# without -x, CSTOP's presence elided TIOCSTOP.
28f540f4
RM
198
199$(common-objpfx)ioctls: $(sysdep_dir)/unix/snarf-ioctls \
200 $(sysincludedir)/sys/ioctl.h $(ioctl-includes)
201 $(dir $<)$(notdir $<) $(filter-out $<,$^) \
5107cf1d 202 | fgrep -xv "`($(dir $<)$(notdir $<) $(bits_termios.h) \
76b87c03 203 $(..)sysdeps/generic/sys/ttydefaults.h; \
57aefafe 204 echo NULL) \
28f540f4
RM
205 | sort | uniq`" \
206 | sort | uniq | tr '\012' ' ' > $@-tmp
207 mv $@-tmp $@
208
209common-generated := $(common-generated) \
5107cf1d 210 bits/ioctls.h ioctls make-ioctls make-ioctls.c
28f540f4
RM
211endif
212\f
10fd03c6 213ifeq ($(subdir),stdio-common)
f2ea0f5b 214ifeq (,$(filter-out $(sysdep_dir)/generic/ $(objpfx),\
28f540f4
RM
215 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/errlist.c))))))
216
217before-compile: $(objpfx)errlist.c
218$(objpfx)errlist.c: $(objpfx)make_errlist
219 @rm -f $@
220 $(dir $<)$(notdir $<) > $@-tmp
221 mv $@-tmp $@
222
223$(objpfx)make_errlist: $(sysdep_dir)/unix/make_errlist.c
224 $(native-compile)
225
226generated := $(generated) make_errlist errlist.c
227
228endif
10fd03c6 229endif # stdio-common
28f540f4 230\f
f2ea0f5b 231ifeq (,$(filter-out $(sysdep_dir)/generic/ $(common-objpfx),\
df4ef2ab 232 $(dir $(firstword $(wildcard $(+sysdep_dirs:%=%/sys/syscall.h))))))
28f540f4 233
df4ef2ab 234# The syscall code assumes a file <sys/syscall.h> that defines macros
28f540f4
RM
235# `SYS_call' for syscall `call'. Variations on this I have seen include:
236# it's in <sys/syscall.h>;
237# it's in <sys.s>;
238# it defines `CALL' instead of `SYS_call'.
239# Irix has a <syscall.h> which is not what we want, so check for <sys.s> first.
240
241# Find a file that might have these. NOTE: This list of possibilities is
242# repeated in sysdeps/unix/configure and the two should be kept in sync.
243syscall.h := $(firstword $(wildcard $(addprefix $(sysincludedir)/, \
244 sys.s sys/sys.s \
245 sys.S sys/sys.S \
246 syscall.h sys/syscall.h \
247 )))
248ifdef syscall.h
249
250# Transmogrify any of several formats of the file into the one we want.
df4ef2ab 251$(common-objpfx)sys/syscall.h: $(syscall.h)
377a515b 252 $(make-target-directory)
28f540f4
RM
253 tr '[A-Z]' '[a-z]' < $< | \
254 sed -e 's/[ ]sys_/ /' \
255 -e 's/^#define[ ]*\([a-z0-9_]*\)[ ]*/#define SYS_\1 /' \
256 -e 's/[ ]sys_/ SYS_/' \
257 -e 's/SYS_syscall_basenum/syscall_basenum/g' \
258 -e 's/SYS_kerncall_basenum/kerncall_basenum/g' \
259 -e 's/SYS_sysvoffset/sysvoffset/g' \
260 -e '/^#/!d' \
261 -e '/^#ident/d' \
262 -e 's-\(/\*[^*]*\)$$-\1\*/-' \
263 > $@-tmp
264 mv $@-tmp $@
265
266before-compile := $(before-compile) $(common-objpfx)syscall.h
267common-generated := $(common-generated) syscall.h
268
269endif
270
271endif
aeb72b16
RM
272\f
273ifndef inhibit-unix-syscalls
274
275# Sysdep dirs unix/... can contain a file syscalls.list,
276# which specifies objects to be compiled as simple Unix system calls.
277
45086082 278-include $(common-objpfx)sysd-syscalls
aeb72b16
RM
279omit-deps += $(unix-syscalls)
280
281ifeq (misc,$(subdir))
282sysdep_routines += $(unix-extra-syscalls)
283endif
284
285export sysdirs
286export asm_CPP := $(COMPILE.S) -E -x assembler-with-cpp
287
45086082
RM
288$(common-objpfx)sysd-syscalls: $(..)sysdeps/unix/make-syscalls.sh \
289 $(wildcard $(+sysdep_dirs:%=%/syscalls.list))
57ba7bb4
UD
290 for dir in $(+sysdep_dirs); do \
291 test -f $$dir/syscalls.list && \
795fbc9a 292 { $(SHELL) $(dir $<)$(notdir $<) $$dir || exit 1; }; \
5290baf0 293 test $$dir = $(..)sysdeps/unix && break; \
aeb72b16
RM
294 done > $@T
295 mv -f $@T $@
296
dbdb6189
RM
297# This syscall objects depend on s-proto.d, which is generated to
298# specify dependencies generated syscalls with have on headers.
299ifdef subdir
bfc04a9f 300ifndef no_deps
dbdb6189
RM
301# These deps use file names relative to a subdir, so don't
302# include them in the parent directory.
45086082 303-include $(common-objpfx)s-proto.d
dbdb6189 304endif
bfc04a9f 305endif
dbdb6189 306
26761c28 307$(common-objpfx)s-proto.d: $(common-objpfx)%.d: $(..)sysdeps/unix/%.S
6e953631
UD
308 $(+make-deps)
309
aeb72b16 310endif
This page took 0.102483 seconds and 5 git commands to generate.