]> git.ipfire.org Git - thirdparty/glibc.git/blame - Rules
Update.
[thirdparty/glibc.git] / Rules
CommitLineData
c238ecf7 1# Copyright (C) 1991-2000, 2002 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
41bdb6e2
AJ
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
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
41bdb6e2 12# Lesser General Public License for more details.
28f540f4 13
41bdb6e2
AJ
14# You should have received a copy of the GNU Lesser General Public
15# License along with the GNU C Library; if not, write to the Free
16# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17# 02111-1307 USA.
28f540f4
RM
18
19#
20# Rules for making a subdirectory in the GNU C library.
21# Each subdirectory Makefile defines some variables and includes this.
22#
23ifneq (,)
24This makefile requires GNU Make.
25endif
26
27all: # Don't let the default goal come from Makeconfig.
28
29include ../Makeconfig
30
31ifndef subdir
32Each subdirectory makefile must define the `subdir' variable.
33endif
c7562c74 34# This ` unconfuses emacs.
28f540f4
RM
35# This is benign and useless in GNU make before 3.63.
36export subdir := $(subdir)
37\f
38# This is the default target; it makes the library and auxiliary programs.
39.PHONY: all
96f873b9 40all: objs lib others
28f540f4 41
0413b54c 42ifeq ($(build-programs),yes)
a182affd 43others: $(addprefix $(objpfx),$(extra-objs) \
6c3ebebd
UD
44 $(install-lib) \
45 $(install-bin) $(install-bin-script) \
1ef32c3d 46 $(install-rootsbin) $(install-sbin))
0413b54c
UD
47else
48others: $(addprefix $(objpfx),$(extra-objs) \
49 $(install-lib))
50endif
a182affd 51
28f540f4
RM
52ifneq "$(findstring env,$(origin headers))" ""
53headers :=
54endif
55
56ifneq "$(findstring env,$(origin generated))" ""
57generated :=
58endif
59
924840c5
TBB
60ifneq "$(findstring env,$(origin common-generated))" ""
61common-generated :=
62endif
63
28f540f4
RM
64include ../Makerules
65
66.PHONY: subdir_lib
3bbceb12 67subdir_lib: lib-noranlib
28f540f4
RM
68
69# Some subdirs need to install a dummy library.
70# They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
6e953631 71dep-dummy-lib = $(common-objpfx)dummy.o
28f540f4
RM
72define make-dummy-lib
73$(AR) cr$(verbose) $@ $<
74endef
74015205 75
6e953631 76$(common-objpfx)dummy.c:
f0097fa0 77 rm -f $@
27ee0a55
AJ
78 (echo 'extern void __dummy__ (void);'; \
79 echo 'void __dummy__ (void) { }') > $@
464d646f 80common-generated += dummy.o dummy.c
28f540f4 81\f
6d52618b 82# This makes all the auxiliary and test programs.
28f540f4
RM
83
84.PHONY: others tests
0413b54c 85ifeq ($(build-programs),yes)
414fd335 86others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
0413b54c
UD
87else
88others: $(addprefix $(objpfx),$(extra-objs))
89endif
28f540f4 90ifeq ($(cross-compiling),yes)
7cabd57c 91tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
c238ecf7 92xtests: tests
28f540f4 93else
ac556388
GM
94ifeq ($(build-bounded),yes)
95tests-bp.out = $(tests:%=$(objpfx)%-bp.out)
c238ecf7 96xtests-bp.out = $(tests:%=$(objpfx)%-bp.out) $(xtests:%=$(objpfx)%-bp.out)
ac556388
GM
97endif
98tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out)
c238ecf7 99xtests: $(tests:%=$(objpfx)%.out) $(xtests:%=$(objpfx)%.out) $(xtests-bp.out)
786a5421 100endif
28f540f4 101
0413b54c 102ifeq ($(build-programs),yes)
c238ecf7 103binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs)
5afe6c02 104binaries-static = $(others-static) $(tests-static)
0413b54c 105else
c238ecf7 106binaries-all = $(tests) $(xtests) $(test-srcs)
3c5edd4d 107binaries-static =
e1586792
UD
108endif
109
110binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
111
112ifneq "$(strip $(binaries-shared))" ""
113$(addprefix $(objpfx),$(binaries-shared)): %: %.o \
9992e360 114 $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
0413b54c
UD
115 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
116 $(+link)
117endif
e1586792
UD
118
119ifneq "$(strip $(binaries-static))" ""
120$(addprefix $(objpfx),$(binaries-static)): %: %.o \
9992e360 121 $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
e1586792
UD
122 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
123 $(+link-static)
0413b54c 124endif
28f540f4 125
ac556388 126ifeq ($(build-bounded),yes)
c238ecf7 127binaries-bounded = $(addsuffix -bp,$(tests) $(xtests) $(test-srcs))
ac556388
GM
128$(addprefix $(objpfx),$(binaries-bounded)): %-bp: %.ob \
129 $(sort $(filter $(common-objpfx)lib%,$(link-libc-bounded))) \
130 $(addprefix $(csu-objpfx),start.ob) $(+preinit) $(+postinit)
131 $(+link-bounded)
132endif
133
c238ecf7 134ifneq "$(strip $(tests) $(xtests) $(test-srcs))" ""
28f540f4
RM
135# These are the implicit rules for making test outputs
136# from the test programs and whatever input files are present.
41d998a6
GM
137
138make-test-out = GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
139 $($*-ENV) $(built-program-cmd) $($*-ARGS)
140$(objpfx)%-bp.out: %.input $(objpfx)%-bp
141 $(make-test-out) > $@ < $(word 1,$^)
196980f5 142$(objpfx)%.out: %.input $(objpfx)%
41d998a6 143 $(make-test-out) > $@ < $(word 1,$^)
196980f5 144$(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
41d998a6
GM
145 $(make-test-out) > $@
146
28f540f4
RM
147endif # tests
148\f
149.PHONY: distclean realclean subdir_distclean subdir_realclean \
3c5edd4d 150 subdir_clean subdir_mostlyclean subdir_testclean
28f540f4
RM
151subdir_mostlyclean: mostlyclean
152subdir_clean: clean
153subdir_distclean: distclean
154subdir_realclean: realclean
3c5edd4d 155subdir_testclean: do-tests-clean
28f540f4
RM
156realclean: distclean
157distclean: clean
158
159.PHONY: subdir_echo-headers
160subdir_echo-headers: echo-headers
161
162.PHONY: subdir_echo-distinfo
163subdir_echo-distinfo:
d705269e 164 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
924840c5 165 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
28f540f4
RM
166
167# We want to install everything except the library itself, but update all
168# our portions of the library because the parent make will install it later
169# (likewise the stubs file).
170.PHONY: subdir_install
613a76ff 171subdir_install: install-no-libc.a lib-noranlib stubs
28f540f4
RM
172
173.PHONY: subdir_TAGS subdir_dist
174subdir_TAGS: TAGS
175subdir_dist: dist
176
177# Convenient target to update all the generated source files.
178.PHONY: generated
acf51e02
TBB
179generated: $(addprefix $(common-objpfx),$(common-generated)) \
180 $(addprefix $(objpfx),$(generated))
5790c439 181
bd78530f
UD
182# Target required by the Hurd to ensure that all the MiG-generated
183# headers are in place before building a subdirectory.
184.PHONY: before-compile
185before-compile: $(before-compile)
186
3c5edd4d
UD
187$(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
188 $(compile-command.c)
7ef90c15
UD
189
190# There's no good place to put this - here will do.
191# The dependencies are wrong if it's run from the top level.
192ifeq ($(filter %posix, $(sysdirs)),)
193L_tmpnam = 1
194TMP_MAX = 0
195L_ctermid = 1
196L_cuserid = 1
197else
431f91ba 198L_tmpnam = 20
7ef90c15
UD
199TMP_MAX = 238328
200L_ctermid = 9
201L_cuserid = 9
202endif
99e46354 203stdio_lim = $(common-objpfx)bits/stdio_lim.h
7ef90c15 204
99e46354
UD
205$(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
206$(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
207 $(common-objpfx)config.make
7ef90c15
UD
208 $(make-target-directory)
209 echo '#include "$(..)posix/bits/posix1_lim.h"' | \
99e46354
UD
210 SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \
211 $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT)
219aa9e9
UD
212 echo '#include "$(..)misc/sys/uio.h"' | \
213 SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \
58b668a5 214 $(CC) -D_LIBC=1 $(+includes) -E -dM -xc - | cat - >> $(@:st=hT)
99e46354
UD
215ifdef sed-remove-objpfx
216 sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt)
219aa9e9 217 cat $(@:st=dt) >> $(@:st=d)
99e46354 218else
219aa9e9 219 cat $(@:st=dT) >> $(@:st=d)
99e46354 220endif
219aa9e9
UD
221 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
222 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
223 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
7ef90c15
UD
224 fopen_max=$${fopen_max:-16}; \
225 filename_max=$${filename_max:-1024}; \
ab58d620
UD
226 if [ -z $$iov_max ]; then \
227 define_iov_max="# undef IOV_MAX"; \
228 else \
229 define_iov_max="# define IOV_MAX $$iov_max"; \
230 fi; \
7ef90c15
UD
231 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
232 -e "s/@FILENAME_MAX@/$$filename_max/" \
233 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
234 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
235 -e "s/@L_ctermid@/$(L_ctermid)/" \
236 -e "s/@L_cuserid@/$(L_cuserid)/" \
ab58d620 237 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
99e46354
UD
238 $< > $(@:st=h.new)
239 $(move-if-change) $(@:st=h.new) $(@:st=h)
7ef90c15 240# Remove these last so that they can be examined if something went wrong.
219aa9e9 241 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
99e46354 242 touch $@
7ef90c15
UD
243# Get dependencies.
244ifndef no_deps
99e46354 245-include $(stdio_lim:h=d)
7ef90c15 246endif
99e46354 247common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
c238ecf7
UD
248
249# Local Variables:
250# mode: makefile
251# End: