]> git.ipfire.org Git - thirdparty/glibc.git/blame - Rules
Update.
[thirdparty/glibc.git] / Rules
CommitLineData
6591c335 1# Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 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
ae1025be
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#
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
34# This is benign and useless in GNU make before 3.63.
35export subdir := $(subdir)
36\f
37# This is the default target; it makes the library and auxiliary programs.
38.PHONY: all
96f873b9 39all: objs lib others
28f540f4 40
0413b54c 41ifeq ($(build-programs),yes)
a182affd 42others: $(addprefix $(objpfx),$(extra-objs) \
1ef32c3d
UD
43 $(install-lib) $(install-bin) \
44 $(install-rootsbin) $(install-sbin))
0413b54c
UD
45else
46others: $(addprefix $(objpfx),$(extra-objs) \
47 $(install-lib))
48endif
a182affd 49
28f540f4
RM
50ifneq "$(findstring env,$(origin headers))" ""
51headers :=
52endif
53
54ifneq "$(findstring env,$(origin generated))" ""
55generated :=
56endif
57
924840c5
TBB
58ifneq "$(findstring env,$(origin common-generated))" ""
59common-generated :=
60endif
61
28f540f4
RM
62include ../Makerules
63
64.PHONY: subdir_lib
3bbceb12 65subdir_lib: lib-noranlib
28f540f4
RM
66
67# Some subdirs need to install a dummy library.
68# They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
6e953631 69dep-dummy-lib = $(common-objpfx)dummy.o
28f540f4
RM
70define make-dummy-lib
71$(AR) cr$(verbose) $@ $<
72endef
74015205 73
6e953631 74$(common-objpfx)dummy.c:
f0097fa0 75 rm -f $@
11336c16 76 echo 'void __dummy__ (void) { }' > $@
6e953631 77$(common-objpfx)empty.c:
f0097fa0 78 cp -f /dev/null $@
af6f3906
UD
79common-generated += dummy.o dummy.c empty.c \
80 $(addprefix empty,$(object-suffixes))
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)
3bbceb12 86others: $(addprefix $(objpfx),$(others) $(extra-objs))
0413b54c
UD
87else
88others: $(addprefix $(objpfx),$(extra-objs))
89endif
28f540f4 90ifeq ($(cross-compiling),yes)
e61abf83 91tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
28f540f4
RM
92else
93tests: $(tests:%=$(objpfx)%.out)
94endif
95
0413b54c 96ifeq ($(build-programs),yes)
e1586792
UD
97binaries-all = $(others) $(tests) $(test-srcs)
98binaries-static = $(others-static) $(tests-static) $(test-srcs-static)
0413b54c 99else
e1586792
UD
100binaries-all = $(tests) $(test-srcs)
101binaries-static = $(tests-static) $(test-srcs-static)
102endif
103
104binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
105
106ifneq "$(strip $(binaries-shared))" ""
107$(addprefix $(objpfx),$(binaries-shared)): %: %.o \
0413b54c
UD
108 $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
109 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
110 $(+link)
111endif
e1586792
UD
112
113ifneq "$(strip $(binaries-static))" ""
114$(addprefix $(objpfx),$(binaries-static)): %: %.o \
115 $(sort $(filter $(common-objpfx)libc%,$(link-libc-static))) \
116 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
117 $(+link-static)
0413b54c 118endif
28f540f4 119
e61abf83 120ifneq "$(strip $(tests) $(test-srcs))" ""
28f540f4
RM
121# These are the implicit rules for making test outputs
122# from the test programs and whatever input files are present.
196980f5 123$(objpfx)%.out: %.args $(objpfx)% %.input
fa0bc87c 124 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
196980f5 125$(objpfx)%.out: %.args $(objpfx)%
fa0bc87c 126 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
196980f5 127$(objpfx)%.out: %.input $(objpfx)%
fa0bc87c 128 $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
196980f5 129$(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
fa0bc87c 130 $($*-ENV) $(built-program-cmd) > $@
28f540f4
RM
131endif # tests
132\f
133.PHONY: distclean realclean subdir_distclean subdir_realclean \
edf5b2d7 134 subdir_clean subdir_mostlyclean
28f540f4
RM
135subdir_mostlyclean: mostlyclean
136subdir_clean: clean
137subdir_distclean: distclean
138subdir_realclean: realclean
139realclean: distclean
140distclean: clean
141
142.PHONY: subdir_echo-headers
143subdir_echo-headers: echo-headers
144
145.PHONY: subdir_echo-distinfo
146subdir_echo-distinfo:
d705269e 147 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
924840c5 148 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
28f540f4
RM
149
150# We want to install everything except the library itself, but update all
151# our portions of the library because the parent make will install it later
152# (likewise the stubs file).
153.PHONY: subdir_install
613a76ff 154subdir_install: install-no-libc.a lib-noranlib stubs
28f540f4
RM
155
156.PHONY: subdir_TAGS subdir_dist
157subdir_TAGS: TAGS
158subdir_dist: dist
159
160# Convenient target to update all the generated source files.
161.PHONY: generated
acf51e02
TBB
162generated: $(addprefix $(common-objpfx),$(common-generated)) \
163 $(addprefix $(objpfx),$(generated))
5790c439 164
af6f3906
UD
165define o-iterator-doit
166$(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
167 $$(compile-command.c)
168endef
169object-suffixes-left := $(object-suffixes)
170include $(o-iterator)
171
6591c335
UD
172define o-iterator-doit
173$(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
174 $$(compile-command.c)
175endef
176object-suffixes-left := $(object-suffixes)
177include $(o-iterator)
178
5790c439
RM
179ifndef libc.so-version
180# Undefine this because it can't work when we libc.so is unversioned.
181static-only-routines =
182endif
183
184ifdef static-only-routines
185# These routines are to be omitted from the shared library object,
186# so we replace the PIC objects for them with the empty object file.
650425ce 187$(static-only-routines:%=$(objpfx)%.os): %.os: $(common-objpfx)empty.os
5790c439
RM
188 rm -f $@
189 ln $< $@
2c8d89e7 190 touch $@
b9b49b44
UD
191
192# Must build the routines as PIC, though, because they can end up in (users')
193# shared objects. We don't want to use CFLAGS-os because users may, for
194# example, make that processor-specific.
195$(static-only-routines:%=$(objpfx)%.o): $(objpfx)%.o: %.c $(before-compile)
196 $(compile.c) $(pic-ccflag) $(OUTPUT_OPTION)
5790c439 197endif
f2ea0f5b
UD
198
199ifdef shared-only-routines
200# If we have versioned code we don't need the old versions in any of the
201# static libraries.
202define o-iterator-doit
af6f3906 203$(shared-only-routines:%=$(objpfx)%$o): %$o: $(common-objpfx)empty$o;
f2ea0f5b
UD
204 rm -f $$@
205 ln $$< $$@
2c8d89e7 206 touch $$@
f2ea0f5b
UD
207endef
208object-suffixes-left := $(filter-out .os,$(object-suffixes))
209include $(o-iterator)
210endif