]> git.ipfire.org Git - thirdparty/glibc.git/blob - Rules
Mention 14210 in NEWS.
[thirdparty/glibc.git] / Rules
1 # Copyright (C) 1991-2000,2002,2003,2004,2005,2006,2011
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4
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.
9
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.
14
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <http://www.gnu.org/licenses/>.
18
19 #
20 # Rules for making a subdirectory in the GNU C library.
21 # Each subdirectory Makefile defines some variables and includes this.
22 #
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
26
27 all: # Don't let the default goal come from Makeconfig.
28
29 include $(firstword $(..) ../)Makeconfig
30
31 ifndef subdir
32 Each subdirectory makefile must define the `subdir' variable.
33 endif
34 # This ` unconfuses emacs.
35 # This is benign and useless in GNU make before 3.63.
36 export subdir := $(subdir)
37 \f
38 # This is the default target; it makes the library and auxiliary programs.
39 .PHONY: all
40 all: objs lib others
41
42 ifeq ($(build-programs),yes)
43 others: $(addprefix $(objpfx),$(extra-objs) \
44 $(install-lib) \
45 $(install-bin) $(install-bin-script) \
46 $(install-rootsbin) $(install-sbin))
47 else
48 others: $(addprefix $(objpfx),$(extra-objs) \
49 $(install-lib))
50 endif
51
52 ifneq "$(findstring env,$(origin headers))" ""
53 headers :=
54 endif
55
56 ifneq "$(findstring env,$(origin generated))" ""
57 generated :=
58 endif
59
60 ifneq "$(findstring env,$(origin common-generated))" ""
61 common-generated :=
62 endif
63
64 # See below. This must be set before Makerules processes it.
65 before-compile += $(common-objpfx)bits/stdio_lim.h
66
67 include $(..)Makerules
68
69 .PHONY: subdir_lib
70 subdir_lib: lib-noranlib
71
72 # Some subdirs need to install a dummy library.
73 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
74 dep-dummy-lib = $(common-objpfx)dummy.o
75 define make-dummy-lib
76 $(AR) cr$(verbose) $@ $<
77 endef
78
79 $(common-objpfx)dummy.c:
80 rm -f $@
81 (echo 'extern void __dummy__ (void);'; \
82 echo 'void __dummy__ (void) { }') > $@
83 common-generated += dummy.o dummy.c
84 \f
85 # This makes all the auxiliary and test programs.
86
87 .PHONY: others tests
88 ifeq ($(build-programs),yes)
89 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
90 else
91 others: $(addprefix $(objpfx),$(extra-objs))
92 endif
93 ifeq ($(cross-compiling),yes)
94 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
95 xtests: tests
96 else
97 ifeq ($(build-bounded),yes)
98 tests-bp.out = $(tests:%=$(objpfx)%-bp.out)
99 xtests-bp.out = $(xtests:%=$(objpfx)%-bp.out)
100 endif
101 tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out)
102 xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-bp.out)
103 endif
104
105 ifeq ($(build-programs),yes)
106 binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs)
107 binaries-static = $(others-static) $(tests-static) $(xtests-static)
108 ifeq (yesyes,$(have-fpie)$(build-shared))
109 binaries-pie = $(others-pie) $(tests-pie) $(xtests-pie)
110 else
111 binaries-pie =
112 endif
113 else
114 binaries-all = $(tests) $(xtests) $(test-srcs)
115 binaries-static =
116 binaries-pie =
117 endif
118
119 binaries-shared = $(filter-out $(binaries-pie) $(binaries-static), \
120 $(binaries-all))
121
122 ifneq "$(strip $(binaries-shared))" ""
123 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
124 $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
125 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
126 $(+link)
127 endif
128
129 ifneq "$(strip $(binaries-pie))" ""
130 $(addprefix $(objpfx),$(binaries-pie)): %: %.o \
131 $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
132 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
133 $(+link-pie)
134 endif
135
136 ifneq "$(strip $(binaries-static))" ""
137 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
138 $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
139 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
140 $(+link-static)
141 endif
142
143 ifeq ($(build-bounded),yes)
144 binaries-bounded = $(addsuffix -bp,$(tests) $(xtests) $(test-srcs))
145 $(addprefix $(objpfx),$(binaries-bounded)): %-bp: %.ob \
146 $(sort $(filter $(common-objpfx)lib%,$(link-libc-bounded))) \
147 $(addprefix $(csu-objpfx),start.ob) $(+preinit) $(+postinit)
148 $(+link-bounded)
149 endif
150
151 ifneq "$(strip $(tests) $(xtests) $(test-srcs))" ""
152 # These are the implicit rules for making test outputs
153 # from the test programs and whatever input files are present.
154
155 make-test-out = GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
156 $($*-ENV) $(built-program-cmd) $($*-ARGS)
157 $(objpfx)%-bp.out: %.input $(objpfx)%-bp
158 $(make-test-out) > $@ < $(word 1,$^)
159 $(objpfx)%.out: %.input $(objpfx)%
160 $(make-test-out) > $@ < $(word 1,$^)
161 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
162 $(make-test-out) > $@
163
164 endif # tests
165 \f
166 .PHONY: distclean realclean subdir_distclean subdir_realclean \
167 subdir_clean subdir_mostlyclean subdir_testclean
168 subdir_mostlyclean: mostlyclean
169 subdir_clean: clean
170 subdir_distclean: distclean
171 subdir_realclean: realclean
172 subdir_testclean: do-tests-clean
173 realclean: distclean
174 distclean: clean
175
176 # We want to install everything except the library itself, but update all
177 # our portions of the library because the parent make will install it later
178 # (likewise the stubs file).
179 .PHONY: subdir_install
180 subdir_install: install-no-libc.a lib-noranlib stubs
181
182 .PHONY: subdir_objs subdir_stubs
183 subdir_objs: objs
184 subdir_stubs: stubs
185
186 # Target required by the Hurd to ensure that all the MiG-generated
187 # headers are in place before building a subdirectory.
188 .PHONY: before-compile
189 before-compile: $(before-compile)
190
191 $(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
192 $(compile-command.c)
193
194 # Local Variables:
195 # mode: makefile
196 # End: