]>
Commit | Line | Data |
---|---|---|
5290baf0 | 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 | |
54d79e99 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 | # Common rules for making the GNU C library. This file is included | |
21 | # by the top-level Makefile and by all subdirectory makefiles | |
22 | # (through Rules). | |
23 | # | |
24 | ifneq (,) | |
25 | This makefile requires GNU Make. | |
26 | endif | |
27 | ||
14bab8de | 28 | REQUIRED_MAKE_VERSION = 3.74 |
6952e59e | 29 | REAL_MAKE_VERSION = $(firstword $(MAKE_VERSION)) |
14bab8de UD |
30 | |
31 | ifneq ($(REQUIRED_MAKE_VERSION), \ | |
54d79e99 | 32 | $(firstword $(sort $(REAL_MAKE_VERSION) $(REQUIRED_MAKE_VERSION)))) |
14bab8de UD |
33 | Wrong GNU Make version. See above for the version needed. |
34 | endif | |
35 | ||
28f540f4 RM |
36 | |
37 | ifdef subdir | |
38 | .. := ../ | |
39 | endif # subdir | |
40 | ||
41 | # If `sources' was defined by the parent makefile, undefine it so | |
42 | # we will later get it from wildcard search in this directory. | |
43 | ifneq "$(findstring env,$(origin sources))" "" | |
44 | sources := | |
45 | endif | |
46 | ||
28f540f4 RM |
47 | oPATH := $(PATH) |
48 | PATH := this definition should take precedence over $(oPATH) | |
49 | ifeq ($(PATH),$(oPATH)) | |
50 | You must not use the -e flag when building the GNU C library. | |
51 | else | |
52 | PATH := $(oPATH) | |
53 | endif | |
54 | \f | |
55 | ifndef +included-Makeconfig | |
56 | include $(..)Makeconfig | |
57 | endif | |
58 | ||
59 | # `configure' writes a definition of `config-sysdirs' in `config.make'. | |
57ba7bb4 | 60 | sysdirs = $(strip $(full-config-sysdirs)) |
28f540f4 RM |
61 | |
62 | +sysdir_pfx = $(common-objpfx) | |
63 | ||
64 | export sysdirs := $(sysdirs) | |
65 | ||
57ba7bb4 | 66 | +sysdep_dirs := $(full-config-sysdirs) |
28f540f4 RM |
67 | ifdef objdir |
68 | +sysdep_dirs := $(objdir) $(+sysdep_dirs) | |
69 | endif | |
70 | ||
71 | # Add -I switches to get the right sysdep directories. | |
72 | # `+includes' in Makeconfig references $(+sysdep-includes). | |
73 | +sysdep-includes := $(addprefix -I,$(+sysdep_dirs)) | |
dbdb6189 RM |
74 | |
75 | # The name of the symbol table archive member. The default is suitable for | |
76 | # BSD style archives. It can be overridden in sysdep Makefiles when SYSV | |
77 | # style archive are used. | |
01f3e03b | 78 | ifeq (no,$(elf)) |
dbdb6189 | 79 | ar-symtab-name = __.SYMDEF |
01f3e03b RM |
80 | else |
81 | ar-symtab-name = # The null name is used in ELF archives. | |
82 | endif | |
28f540f4 RM |
83 | \f |
84 | # Include any system-specific makefiles. | |
85 | ||
86 | # This is here so things in sysdep Makefiles can easily depend on foo.h as | |
87 | # appropriate and not worry about where foo.h comes from, which may be | |
88 | # system dependent and not known by that Makefile. | |
6e953631 | 89 | vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \ |
57ba7bb4 | 90 | $(+sysdep_dirs) $(..))) |
28f540f4 | 91 | |
28f540f4 RM |
92 | # Some sysdep makefiles use this to distinguish being included here from |
93 | # being included individually by a subdir makefile (hurd/Makefile needs this). | |
94 | in-Makerules := yes | |
95 | ||
96 | ifndef avoid-generated | |
555f3a39 | 97 | -include $(+sysdir_pfx)sysd-Makefile |
57ba7bb4 | 98 | ifneq ($(sysd-Makefile-sysdirs),$(config-sysdirs)) |
273d56ce RM |
99 | sysd-Makefile-force = FORCE |
100 | FORCE: | |
101 | endif | |
102 | $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)config.make $(..)Makerules \ | |
103 | $(sysd-Makefile-force) | |
28f540f4 | 104 | -@rm -f $@T |
57ba7bb4 UD |
105 | (echo 'sysd-Makefile-sysdirs := $(config-sysdirs)'; \ |
106 | for dir in $(config-sysdirs); do \ | |
107 | file=$$dir/Makefile; \ | |
0d204b0a UD |
108 | case $$dir in \ |
109 | /*) rel= ;; \ | |
110 | *) rel=$(..) ;; \ | |
111 | esac; \ | |
112 | if [ -f $$rel$$file ]; then \ | |
57ba7bb4 UD |
113 | case $$dir in \ |
114 | /*) echo include "$$file" ;; \ | |
115 | *) echo include "\$$(..)$$file" ;; \ | |
116 | esac; \ | |
28f540f4 | 117 | else true; fi; \ |
0d204b0a | 118 | done; \ |
28f540f4 RM |
119 | echo 'sysd-Makefile-done=t') > $@T |
120 | mv -f $@T $@ | |
121 | endif | |
122 | ||
3bbceb12 RM |
123 | ifndef sysd-Makefile-done |
124 | # Don't do deps until this exists, because it might change the sources list. | |
125 | no_deps=t | |
126 | endif | |
127 | ||
128 | ||
28f540f4 RM |
129 | # Reorder before-compile so that mach things come first, and hurd things |
130 | # second, before all else. The mach and hurd subdirectories have many | |
131 | # generated header files which the much of rest of the library depends on, | |
132 | # so it is best to build them first (and mach before hurd, at that). | |
133 | before-compile := $(filter $(common-objpfx)mach% $(common-objpfx)hurd%,\ | |
134 | $(before-compile)) \ | |
135 | $(filter-out $(common-objpfx)mach% $(common-objpfx)hurd%,\ | |
136 | $(before-compile)) | |
137 | ||
138 | # Remove existing files from `before-compile'. Things are added there when | |
139 | # they must exist for dependency generation to work right, but once they | |
140 | # exist there is no further need for every single file to depend on them, | |
141 | # and those gratuitous dependencies result in many gratuitous | |
142 | # recompilations. | |
143 | before-compile := $(filter-out $(wildcard $(before-compile)),$(before-compile)) | |
144 | ||
145 | # Don't let any before-compile file be an intermediate and get removed. | |
146 | ifdef before-compile | |
147 | $(before-compile): | |
148 | endif | |
149 | \f | |
150 | # Generate an ordered list of implicit rules which find the source files in | |
151 | # each sysdep directory. The old method was to use vpath to search all the | |
152 | # sysdep directories. However, that had the problem that a .S file in a | |
153 | # later directory would be chosen over a .c file in an earlier directory, | |
154 | # which does not preserve the desired sysdeps ordering behavior. | |
155 | ||
156 | # When making the list of .d files to include, we can't know which ones | |
157 | # have source in .s files, and thus do not in fact need a .d file. | |
158 | # So we must define rules to make .d files for .s files. | |
159 | define make-dummy-dep | |
6e953631 | 160 | $(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@)) |
28f540f4 | 161 | endef |
6e953631 | 162 | $(common-objpfx)dummy.d: |
28f540f4 RM |
163 | echo '# .s files cannot contain includes, so they need no deps.' > $@ |
164 | ||
165 | # It matters that this set of rules, for compiling from sources in | |
166 | # the current directory (the $srcdir/$subdir) come before the | |
167 | # generated sysdep rules in included from sysd-rules below. When | |
168 | # compiling in the source tree, generated sources go into the current | |
169 | # directory, and those should be chosen before any sources in sysdeps. | |
170 | $(objpfx)%.o: %.S $(before-compile); $(compile-command.S) | |
51f75302 RM |
171 | $(objpfx)%.so: %.S $(before-compile); $(compile-command.S) |
172 | $(objpfx)%.po: %.S $(before-compile); $(compile-command.S) | |
173 | $(objpfx)%.go: %.S $(before-compile); $(compile-command.S) | |
28f540f4 RM |
174 | $(objpfx)%.d: %.S $(before-compile); $(+make-deps) |
175 | $(objpfx)%.o: %.s $(before-compile); $(compile-command.s) | |
51f75302 RM |
176 | $(objpfx)%.so: %.s $(before-compile); $(compile-command.s) |
177 | $(objpfx)%.po: %.s $(before-compile); $(compile-command.s) | |
178 | $(objpfx)%.go: %.s $(before-compile); $(compile-command.s) | |
6e953631 | 179 | $(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep) |
28f540f4 | 180 | $(objpfx)%.o: %.c $(before-compile); $(compile-command.c) |
51f75302 RM |
181 | $(objpfx)%.so: %.c $(before-compile); $(compile-command.c) |
182 | $(objpfx)%.po: %.c $(before-compile); $(compile-command.c) | |
183 | $(objpfx)%.go: %.c $(before-compile); $(compile-command.c) | |
28f540f4 RM |
184 | $(objpfx)%.d: %.c $(before-compile); $(+make-deps) |
185 | ||
186 | # Omit the objpfx rules when building in the source tree, because | |
187 | # objpfx is empty and so these rules just override the ones above. | |
188 | ifdef objpfx | |
189 | # Define first rules to find the source files in $(objpfx). | |
190 | # Generated source files will end up there. | |
191 | $(objpfx)%.o: $(objpfx)%.S $(before-compile); $(compile-command.S) | |
51f75302 RM |
192 | $(objpfx)%.so: $(objpfx)%.S $(before-compile); $(compile-command.S) |
193 | $(objpfx)%.po: $(objpfx)%.S $(before-compile); $(compile-command.S) | |
194 | $(objpfx)%.go: $(objpfx)%.S $(before-compile); $(compile-command.S) | |
28f540f4 RM |
195 | $(objpfx)%.d: $(objpfx)%.S $(before-compile); $(+make-deps) |
196 | $(objpfx)%.o: $(objpfx)%.s $(before-compile); $(compile-command.s) | |
51f75302 RM |
197 | $(objpfx)%.so: $(objpfx)%.s $(before-compile); $(compile-command.s) |
198 | $(objpfx)%.po: $(objpfx)%.s $(before-compile); $(compile-command.s) | |
199 | $(objpfx)%.go: $(objpfx)%.s $(before-compile); $(compile-command.s) | |
6e953631 | 200 | $(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep) |
28f540f4 | 201 | $(objpfx)%.o: $(objpfx)%.c $(before-compile); $(compile-command.c) |
51f75302 RM |
202 | $(objpfx)%.so: $(objpfx)%.c $(before-compile); $(compile-command.c) |
203 | $(objpfx)%.po: $(objpfx)%.c $(before-compile); $(compile-command.c) | |
204 | $(objpfx)%.go: $(objpfx)%.c $(before-compile); $(compile-command.c) | |
28f540f4 RM |
205 | $(objpfx)%.d: $(objpfx)%.c $(before-compile); $(+make-deps) |
206 | endif | |
207 | ||
208 | # System-dependent makefiles can put in `inhibit-sysdep-asm' wildcard | |
209 | # patterns matching sysdep directories whose assembly source files should | |
210 | # be suppressed. | |
211 | ifdef inhibit-sysdep-asm | |
212 | define open-check-inhibit-asm | |
213 | case $$sysdir in $(subst $(empty) ,|,$(inhibit-sysdep-asm))) : ;; *) | |
214 | endef | |
51f75302 | 215 | close-check-inhibit-asm = ;; esac ; |
28f540f4 RM |
216 | endif |
217 | ||
218 | # Don't include sysd-rules until sysd-Makefile is already there and has been | |
219 | # included. It might define inhibit-sysdep-asm, which would affect the | |
220 | # contents of sysd-rules. | |
221 | ifdef sysd-Makefile-done | |
555f3a39 | 222 | -include $(+sysdir_pfx)sysd-rules |
57ba7bb4 UD |
223 | ifneq ($(sysd-rules-sysdirs),$(config-sysdirs)) |
224 | # The value of $(+sysdep_dirs) the sysd-rules was computed for | |
273d56ce RM |
225 | # differs from the one we are using now. So force a rebuild of sysd-rules. |
226 | sysd-rules-force = FORCE | |
227 | FORCE: | |
228 | endif | |
28f540f4 RM |
229 | endif |
230 | $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \ | |
231 | $(wildcard $(foreach dir,$(sysdirs),\ | |
57ba7bb4 | 232 | $(dir)/Makefile))\ |
273d56ce | 233 | $(sysd-rules-force) |
28f540f4 | 234 | -@rm -f $@T |
57ba7bb4 UD |
235 | (echo 'sysd-rules-sysdirs := $(config-sysdirs)'; \ |
236 | for sysdir in $(config-sysdirs); do \ | |
237 | case $$sysdir in \ | |
238 | /*) dir=$$sysdir ;; \ | |
239 | *) dir="\$$(..)$$sysdir" ;; \ | |
240 | esac; \ | |
51f75302 RM |
241 | for o in $(object-suffixes); do \ |
242 | $(open-check-inhibit-asm) \ | |
243 | echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \ | |
244 | \$$(compile-command.S)"; \ | |
245 | echo "\$$(objpfx)%$$o: $$dir/%.s \$$(before-compile); \ | |
246 | \$$(compile-command.s)"; \ | |
247 | $(close-check-inhibit-asm) \ | |
248 | echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \ | |
249 | \$$(compile-command.c)"; \ | |
250 | done; \ | |
28f540f4 | 251 | $(open-check-inhibit-asm) \ |
6e953631 | 252 | echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \ |
51f75302 | 253 | \$$(make-dummy-dep)"; \ |
28f540f4 RM |
254 | echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \ |
255 | \$$(+make-deps)"; \ | |
51f75302 | 256 | $(close-check-inhibit-asm) \ |
28f540f4 RM |
257 | echo "\$$(objpfx)%.d: $$dir/%.c \$$(before-compile); \ |
258 | \$$(+make-deps)"; \ | |
3bbceb12 RM |
259 | done; \ |
260 | echo 'sysd-rules-done = t') > $@T | |
28f540f4 RM |
261 | mv -f $@T $@ |
262 | ||
3bbceb12 RM |
263 | ifndef sysd-rules-done |
264 | # Don't do deps until this exists, because it provides rules to make the deps. | |
265 | no_deps=t | |
266 | endif | |
267 | ||
268 | ||
28f540f4 RM |
269 | ifndef compile-command.S |
270 | compile-command.S = $(compile.S) $(OUTPUT_OPTION) | |
271 | endif | |
272 | ifndef compile-command.s | |
273 | compile-command.s = $(COMPILE.s) $< $(OUTPUT_OPTION) | |
274 | endif | |
275 | ifndef compile-command.c | |
276 | compile-command.c = $(compile.c) $(OUTPUT_OPTION) | |
277 | endif | |
278 | ||
28f540f4 | 279 | # GCC can grok options after the file name, and it looks nicer that way. |
28f540f4 | 280 | compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) |
aeb72b16 RM |
281 | compile.S = $(CC) $< -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) |
282 | COMPILE.S = $(CC) -c $(CPPFLAGS) -DASSEMBLER $(asm-CPPFLAGS) | |
283 | COMPILE.s = $(filter-out -pipe,$(CC)) -c $(ASFLAGS) | |
28f540f4 | 284 | |
28f540f4 RM |
285 | # We need this for the output to go in the right place. It will default to |
286 | # empty if make was configured to work with a cc that can't grok -c and -o | |
287 | # together. You can't compile the C library with such a compiler. | |
288 | OUTPUT_OPTION = -o $@ | |
28f540f4 RM |
289 | |
290 | S-CPPFLAGS = $(asm-CPPFLAGS) | |
291 | define +make-deps | |
6e953631 | 292 | $(make-target-directory) |
28f540f4 RM |
293 | -@rm -f $@ |
294 | $(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \ | |
1177c8ba | 295 | sed -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(object-suffixes),$(@:.d=$o)) $@,' \ |
51f75302 | 296 | $(sed-remove-objpfx) > $(@:.d=.T) |
28f540f4 RM |
297 | mv -f $(@:.d=.T) $@ |
298 | endef | |
299 | ifneq (,$(objpfx)) | |
215dbbb1 RM |
300 | # Continuation lines here are dangerous because they introduce spaces! |
301 | define sed-remove-objpfx | |
6e953631 UD |
302 | -e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \ |
303 | -e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g' | |
215dbbb1 | 304 | endef |
28f540f4 RM |
305 | endif |
306 | \f | |
5f0e6fc7 RM |
307 | # Shared library building. |
308 | ||
309 | ifeq (yes,$(build-shared)) | |
310 | ||
5f0e6fc7 RM |
311 | # Pattern rule to build a shared object from an archive of PIC objects. |
312 | # This must come after the installation rules so Make doesn't try to | |
313 | # build shared libraries in place from the installed *_pic.a files. | |
314 | # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies | |
315 | # on other shared objects. | |
316 | lib%.so: lib%_pic.a; $(build-shlib) | |
317 | ||
318 | ifeq ($(have-no-whole-archive),yes) | |
319 | no-whole-archive = -Wl,--no-whole-archive | |
320 | else | |
321 | no-whole-archive = | |
322 | endif | |
323 | ||
f0f1bf85 UD |
324 | interp-obj = $(common-objpfx)interp.so |
325 | $(interp-obj): $(common-objpfx)%.so: $(..)%.c | |
326 | $(compile-command.c) | |
327 | common-generated += interp.so | |
328 | CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' | |
329 | ||
330 | $(common-objpfx)libc.so: $(interp-obj) | |
331 | $(patsubst %,$(objpfx)%.so,$(extra-libs)): $(interp-obj) | |
332 | ||
5f0e6fc7 RM |
333 | define build-shlib |
334 | $(LINK.o) -shared -o $@ $(sysdep-LDFLAGS) $(config-LDFLAGS) \ | |
e75154a6 | 335 | -B$(csu-objpfx) \ |
5f0e6fc7 RM |
336 | -Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \ |
337 | $(LDFLAGS.so) $(LDFLAGS-$(@F:lib%.so=%).so) \ | |
338 | -L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link) \ | |
339 | -Wl,--whole-archive $^ $(no-whole-archive) \ | |
340 | $(LDLIBS-$(@F:lib%.so=%).so) | |
341 | endef | |
342 | ||
343 | # Don't try to use -lc when making libc.so itself. | |
344 | # Also omits crti.o and crtn.o, which we do not want | |
345 | # since we define our own `.init' section specially. | |
346 | LDFLAGS-c.so = -nostdlib -nostartfiles | |
5290baf0 UD |
347 | # But we still want to link libc.so against -lgcc. |
348 | LDLIBS-c.so = -lgcc | |
5f0e6fc7 RM |
349 | # Give libc.so an entry point and make it directly runnable itself. |
350 | LDFLAGS-c.so += -e __libc_main | |
351 | # Use our own special initializer and finalizer files for libc.so. | |
5f0e6fc7 RM |
352 | $(common-objpfx)libc.so: $(elfobjdir)/soinit.so \ |
353 | $(common-objpfx)libc_pic.a \ | |
354 | $(elfobjdir)/sofini.so $(elfobjdir)/ld.so | |
355 | $(build-shlib) | |
356 | ||
357 | ifdef libc.so-version | |
358 | $(common-objpfx)libc.so$(libc.so-version): $(common-objpfx)libc.so | |
359 | rm -f $@ | |
360 | ln -s $(<F) $@ || ln $< $@ | |
361 | endif | |
362 | endif | |
363 | \f | |
b236e99d UD |
364 | # Some files must not be compiled with the exception handler mechanism |
365 | # enabled (introduced in gcc-2.8). Use $(no-exceptions) in the | |
366 | # appropriate CFLAGS definition. | |
367 | ifeq ($(have-no-exceptions),yes) | |
368 | no-exceptions = -fno-exceptions | |
369 | else | |
370 | no-exceptions = | |
371 | endif | |
372 | \f | |
28f540f4 RM |
373 | # Figure out the source filenames in this directory. |
374 | ||
375 | override sources := $(addsuffix .c,$(filter-out $(elided-routines),\ | |
376 | $(routines) $(aux) \ | |
377 | $(sysdep_routines))) | |
378 | sysdep_routines := $(sysdep_routines) | |
379 | ||
e60062b7 RM |
380 | headers := $(headers) $(sysdep_headers) |
381 | ||
28f540f4 RM |
382 | # This is the list of all object files, gotten by |
383 | # replacing every ".c" in `sources' with a ".o". | |
384 | override objects := $(addprefix $(objpfx),$(sources:.c=.o)) | |
693e7b96 RM |
385 | |
386 | ||
387 | # This variable is used in ``include $(o-iterator)'' after defining | |
388 | # $(o-iterator-doit) to produce some desired rule using $o for the object | |
389 | # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy | |
390 | # is produced for each object suffix in use. | |
dc997231 | 391 | o-iterator = $(patsubst %,$(..)o-iterator.mk,$(object-suffixes-left)) |
693e7b96 RM |
392 | |
393 | # The makefile may define $(extra-libs) with `libfoo libbar' | |
394 | # to build libfoo.a et al from the modules listed in $(libfoo-routines). | |
395 | ifdef extra-libs | |
396 | # extra-lib.mk is included once for each extra lib to define rules | |
397 | # to build it, and to add its objects to the various variables. | |
398 | # During its evaluation, $(lib) is set to the name of the library. | |
399 | extra-libs-left := $(extra-libs) | |
400 | include $(patsubst %,$(..)extra-lib.mk,$(extra-libs)) | |
401 | endif | |
28f540f4 RM |
402 | \f |
403 | +depfiles := $(strip $(sources:.c=.d) \ | |
8c0dc19c | 404 | $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.so=.o))) \ |
28f540f4 RM |
405 | $(addsuffix .d,$(others) $(tests))) |
406 | +depfiles := $(addprefix $(objpfx),\ | |
407 | $(filter-out $(addsuffix .d,$(omit-deps)),\ | |
408 | $(+depfiles))) | |
409 | ||
28f540f4 | 410 | ifdef +depfiles |
28f540f4 | 411 | ifneq ($(no_deps),t) |
555f3a39 | 412 | -include $(+depfiles) |
deab9dea | 413 | endif |
28f540f4 RM |
414 | endif |
415 | \f\f | |
416 | # Maximize efficiency by minimizing the number of rules. | |
417 | .SUFFIXES: # Clear the suffix list. | |
418 | # Add the suffixes we use. | |
51f75302 | 419 | .SUFFIXES: .a $(object-suffixes) .S .s .c .h .d |
28f540f4 RM |
420 | |
421 | # Generic rule for making directories. | |
422 | %/: | |
423 | # mkdir isn't smart enough to strip a trailing /. | |
424 | mkdir $(@:%/=%) | |
425 | \f | |
426 | # Make sure that object files are not removed | |
427 | # when they are intermediates between sources and library members. | |
51f75302 | 428 | .PRECIOUS: $(addprefix $(objpfx)%,$(object-suffixes)) |
28f540f4 RM |
429 | |
430 | # Make sure that the parent library archive is never removed. | |
51f75302 | 431 | .PRECIOUS: $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c)) |
28f540f4 RM |
432 | \f |
433 | # Use the verbose option of ar and tar when not running silently. | |
434 | ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s | |
435 | verbose := v | |
436 | else # -s | |
437 | verbose := | |
438 | endif # not -s | |
439 | ||
440 | ARFLAGS := r$(verbose) | |
441 | \f | |
442 | # This makes all the object files in the parent library archive. | |
443 | ||
444 | .PHONY: lib libobjs lib-noranlib | |
4788ab46 | 445 | lib: lib-noranlib $(foreach l,$(libtypes),$(patsubst %,$(common-objpfx)$l,c)) |
51f75302 RM |
446 | |
447 | # Pattern rule for libraries: depend on the __.SYMDEF member updated by ranlib. | |
dbdb6189 | 448 | lib%.a: lib%.a($(ar-symtab-name)) ; |
51f75302 | 449 | |
564210fe RM |
450 | # For object-suffix $o, the list of objects with that suffix. |
451 | # Makefiles can define `elide-routines.so = foo' to leave foo.so out. | |
452 | o-objects = $(patsubst %.o,%$o,$(filter-out $(patsubst %,$(objpfx)%.o,\ | |
453 | $(elide-routines$o)),\ | |
454 | $(objects))) | |
455 | ||
51f75302 RM |
456 | libobjs: $(foreach o,$(object-suffixes),\ |
457 | $(common-objpfx)$(patsubst %,$(libtype$o),c)(\ | |
564210fe | 458 | $(notdir $(o-objects)))) |
3bbceb12 RM |
459 | lib-noranlib: libobjs |
460 | others: $(addprefix $(objpfx),$(install-lib)) | |
28f540f4 | 461 | |
072ebcef RM |
462 | ifndef objects |
463 | ||
464 | # Create the stamp$o files to keep the parent makefile happy. | |
465 | subdir_lib: $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir)) | |
466 | $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir)): | |
6e953631 | 467 | $(make-target-directory) |
072ebcef RM |
468 | rm -f $@; > $@ |
469 | else | |
51f75302 RM |
470 | |
471 | # Define a pattern rule that will match many targets libc.a(foo.%), for | |
472 | # each foo.o in $(objects) (% will just happen always to match `o'). This is | |
473 | # the only way to define a rule that updates many targets at once with one | |
564210fe RM |
474 | # sequence of commands. |
475 | define o-iterator-doit | |
476 | $(common-objpfx)$(patsubst %,$(libtype$o),c)(\ | |
477 | $(addsuffix .%,$(filter-out $(elide-routines$o),$(notdir $(objects:.o=))))): \ | |
51f75302 | 478 | $(objpfx)stamp.%-$(subdir) ; |
564210fe RM |
479 | endef |
480 | object-suffixes-left := $(object-suffixes) | |
481 | include $(o-iterator) | |
51f75302 RM |
482 | |
483 | # The pattern rule tells Make to remake $(objpfx)stamp.%-$(subdir) as | |
564210fe RM |
484 | # the way to update all the foo.% object files in $(objects). Now we |
485 | # define explicit rules to update each $(objpfx)stamp.SUFFIX-$(subdir) | |
486 | # timestamp file; these rules (one explicit rule is generated for each | |
487 | # object suffix) will update the parent archive with ar. Use a static | |
488 | # pattern rule so $* is set to the object type during the commands. | |
489 | define o-iterator-doit | |
490 | $(objpfx)stamp$o-$(subdir): $(objpfx)stamp%-$(subdir): $(o-objects); $$(do-ar) | |
491 | endef | |
492 | object-suffixes-left := $(object-suffixes) | |
493 | include $(o-iterator) | |
494 | define do-ar | |
706074a5 | 495 | topdir=`cd $(..).; pwd`; \ |
6e953631 | 496 | $(patsubst %/,cd %;,$(objpfx)) \ |
6ed0492f UD |
497 | $(SHELL) $$topdir/autolock.sh ${O%-lib}.lck $(AR) cru$(verbose) ${O%-lib} \ |
498 | $(patsubst $(objpfx)%,%,$^) | |
564210fe RM |
499 | rm -f $@ |
500 | touch $@ | |
501 | endef | |
6e953631 | 502 | O%-lib = $(..)$(patsubst %,$(libtype$*),c) |
28f540f4 | 503 | |
51f75302 | 504 | endif |
28f540f4 | 505 | |
dbdb6189 RM |
506 | # Rules to update the $(ar-symtab-name) member with ranlib, |
507 | # one for each object flavor. | |
508 | define o-iterator-doit | |
509 | $(common-objpfx)$(patsubst %,$(libtype$o),c)($(ar-symtab-name)): \ | |
510 | $(common-objpfx)$(patsubst %,$(libtype$o),c)(\ | |
4d6acc61 | 511 | $(patsubst $(objpfx)%,%,$(o-objects))) $(subdirs-stamp-o); \ |
6ed0492f | 512 | $(SHELL) $$(..)./autolock.sh \ |
706074a5 | 513 | $$(common-objpfx)$$(patsubst %,$$(libtype$o),c).lck \ |
df21c858 | 514 | $$(RANLIB) $$(common-objpfx)$$(patsubst %,$$(libtype$o),c) |
dbdb6189 | 515 | endef |
4d6acc61 | 516 | ifndef subdir |
6e953631 | 517 | subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%-$d) |
4d6acc61 RM |
518 | subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps)) |
519 | $(subdirs-stamps): subdir_lib; | |
520 | endif | |
dbdb6189 RM |
521 | object-suffixes-left = $(object-suffixes) |
522 | include $(o-iterator) | |
523 | ||
28f540f4 RM |
524 | |
525 | # This makes all the object files. | |
526 | .PHONY: objects objs | |
564210fe | 527 | objects objs: $(foreach o,$(object-suffixes),$(o-objects)) \ |
51f75302 | 528 | $(addprefix $(objpfx),$(extra-objs)) |
f0bf9cb9 RM |
529 | |
530 | # Canned sequence for building an extra library archive. | |
531 | define build-extra-lib | |
6e953631 | 532 | $(patsubst %/,cd %;,$(objpfx)) \ |
f0bf9cb9 RM |
533 | $(AR) cru$(verbose) $(@:$(objpfx)%=%) \ |
534 | $(patsubst $(objpfx)%,%,$^) | |
535 | $(RANLIB) $@ | |
536 | endef | |
28f540f4 RM |
537 | \f |
538 | # Installation. | |
539 | ||
540 | # $(install-lib) are installed from the object directory into $(libdir); | |
541 | # files in $(install-lib) matching `lib%.a' are ranlib'd after installation | |
542 | # unless they also appear in $(non-lib.a). $(install-data) are installed | |
543 | # as they are into $(datadir). $(headers) are installed as they are in | |
544 | # $(includedir). $(install-bin) and $(install-sbin) are installed from the | |
545 | # object directory into $(bindir) and $(sbindir), respectively. | |
546 | # $(install-others) are absolute path names of files to install; rules to | |
547 | # install them are defined elsewhere. | |
548 | ||
549 | # The simple library name to install libc.a under. | |
550 | # This could be defined by a sysdep Makefile. | |
551 | ifndef libc-name | |
552 | libc-name := c | |
553 | endif | |
554 | ||
555 | define do-install | |
556 | $(make-target-directory) | |
557 | $(INSTALL_DATA) $< $@ | |
558 | endef | |
559 | ||
a182affd RM |
560 | # Make the target directory if it doesn't exist, using the `mkinstalldirs' |
561 | # script that does `mkdir -p' even if `mkdir' doesn't support that flag. | |
28f540f4 | 562 | define make-target-directory |
dcfb26a7 | 563 | $(addprefix $(..)./mkinstalldirs ,\ |
a182affd | 564 | $(filter-out $(wildcard $(@D:%/=%)),$(@D:%/=%))) |
28f540f4 RM |
565 | endef |
566 | ||
567 | # Any directory (parent or subdir) that has any object files to build | |
568 | # should install libc.a; this way "make install" in a subdir is guaranteed | |
569 | # to install everything it changes. | |
570 | ifdef objects | |
51f75302 | 571 | installed-libcs := $(foreach o,$(object-suffixes),\ |
8d57beea UD |
572 | $(inst_libdir)/$(patsubst %,$(libtype$o),\ |
573 | $(libprefix)$(libc-name))) | |
75914335 | 574 | installed-libcs := $(filter-out %_pic.a,$(installed-libcs)) |
51f75302 | 575 | install: $(installed-libcs) |
8d57beea | 576 | $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib |
28f540f4 | 577 | $(make-target-directory) |
c316b486 | 578 | $(INSTALL_DATA) $(common-objpfx)lib$(*:$(libc-name)%=c%) $@ |
9f2233e8 RM |
579 | # Running ranlib after installing makes the __.SYMDEF time stamp up to |
580 | # date, which avoids messages from some linkers. | |
28f540f4 RM |
581 | $(RANLIB) $@ |
582 | endif | |
583 | ||
273d56ce RM |
584 | define do-install-program |
585 | $(make-target-directory) | |
586 | $(INSTALL_PROGRAM) $< $@.new | |
587 | mv -f $@.new $@ | |
588 | endef | |
589 | ||
5bf62f2d | 590 | install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so)) |
0700dfa1 | 591 | install-lib := $(filter-out %.so %_pic.a,$(install-lib)) |
51f75302 | 592 | ifeq (yes,$(build-shared)) |
5bf62f2d | 593 | |
8d57beea | 594 | install-lib-nosubdir: $(install-lib.so:%=$(inst_libdir)/%) |
0e3426bb RM |
595 | |
596 | # Find which .so's have versions. | |
05d4c982 RM |
597 | versioned := $(strip $(foreach so,$(install-lib.so),\ |
598 | $(patsubst %,$(so),$($(so)-version)))) | |
0e3426bb RM |
599 | |
600 | # Install all the unversioned shared libraries. | |
8d57beea UD |
601 | $(addprefix $(inst_slibdir)/, $(filter-out $(versioned),$(install-lib.so))): \ |
602 | $(inst_slibdir)/%.so: $(objpfx)%.so; $(do-install-program) | |
0e3426bb | 603 | |
8a523922 | 604 | ifneq ($(findstring -s,$(LN_S)),) |
f36f8dcf | 605 | define make-link |
f8b87ef0 UD |
606 | rm -f $@.new |
607 | $(SHELL) $(..)rellns-sh $< $@.new | |
8a523922 UD |
608 | mv -f $@.new $@ |
609 | endef | |
610 | else | |
611 | # If we have no symbolic links don't bother with rellns-sh. | |
612 | define make-link | |
f8b87ef0 UD |
613 | rm -f $@.new |
614 | $(LN_S) $< $@.new | |
8a523922 | 615 | mv -f $@.new $@ |
f36f8dcf | 616 | endef |
8a523922 | 617 | endif |
0e3426bb | 618 | |
1ef32c3d UD |
619 | # XXX The following will have to be changed when `ldconfig' is available. |
620 | ifneq (yes,$(cross-compiling)) | |
621 | ifeq (yes,$(has-ldconfig)) | |
622 | define make-shlib-link | |
623 | @: | |
624 | endef | |
625 | endif | |
626 | endif | |
627 | ifndef make-shlib-link | |
628 | define make-shlib-link | |
629 | $(make-link) | |
630 | endef | |
631 | endif | |
632 | ||
0e3426bb RM |
633 | ifdef libc.so-version |
634 | # For a library specified to be version N, install three files: | |
635 | # libc.so -> libc.so.N (e.g. libc.so.6) | |
636 | # libc.so.6 -> libc-VERSION.so (e.g. libc-1.10.so) | |
637 | ||
8d57beea | 638 | $(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so |
1ef32c3d | 639 | $(make-shlib-link) |
8d57beea UD |
640 | $(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so |
641 | $(do-install-program) | |
642 | install: $(inst_slibdir)/libc.so$(libc.so-version) | |
7c713e28 | 643 | |
aa1075ea | 644 | ifndef subdir |
57ba7bb4 UD |
645 | # What we install as libc.so for programs to link against is in fact a |
646 | # link script. It contains references for the various libraries we need. | |
647 | # The libc.so object is not complete since some functions are only defined | |
648 | # in libc.a and the dynamic linker is an etra object. | |
8d57beea UD |
649 | install: $(inst_libdir)/libc.so |
650 | $(inst_libdir)/libc.so: $(common-objpfx)libc.so$(libc.so-version) \ | |
651 | $(elfobjdir)/$(rtld-installed-name) \ | |
652 | $(inst_libdir)/lib$(libc-name).a | |
47707456 UD |
653 | (echo '/* GNU ld script';\ |
654 | echo ' Use the shared library, but some functions are only in';\ | |
d8c7ef98 RM |
655 | echo ' the static library, so try that secondarily.'; \ |
656 | echo ' The dynamic linker defines some functions used by $(<F),';\ | |
4311b2a6 RM |
657 | echo ' but ld uses definitions from libc.a before examining the';\ |
658 | echo ' dependencies of $(<F) to find $(rtld-installed-name). */';\ | |
0f90ef96 RM |
659 | echo 'GROUP ( $(^F) )') > $@.new |
660 | mv -f $@.new $@ | |
661 | ||
aa1075ea | 662 | endif |
7c713e28 | 663 | |
0e3426bb | 664 | else |
8d57beea UD |
665 | install: $(inst_slibdir)/libc.so |
666 | $(inst_slibdir)/libc.so: $(common-objpfx)libc.so | |
667 | $(do-install-program) | |
0e3426bb RM |
668 | endif |
669 | ||
670 | ||
671 | ifneq (,$(versioned)) | |
672 | # Produce three sets of rules as above for all the smaller versioned libraries. | |
673 | ||
674 | define o-iterator-doit | |
8d57beea | 675 | $(inst_libdir)/$o: $(inst_slibdir)/$o$($o-version); $$(make-link) |
0e3426bb RM |
676 | endef |
677 | object-suffixes-left := $(versioned) | |
dc997231 | 678 | include $(o-iterator) |
0e3426bb | 679 | |
20c81189 RM |
680 | # Make symlinks in the build directory, because the versioned names might |
681 | # be referenced by a DT_NEEDED in another library. | |
682 | define o-iterator-doit | |
683 | $(objpfx)$o$($o-version): $(objpfx)$o; $$(make-link) | |
684 | endef | |
685 | object-suffixes-left := $(versioned) | |
dc997231 | 686 | include $(o-iterator) |
20c81189 RM |
687 | |
688 | ||
499e7464 | 689 | ifeq (,$($(subdir)-version)) |
0e3426bb | 690 | define o-iterator-doit |
8d57beea | 691 | $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so; |
1ef32c3d | 692 | $$(make-shlib-link) |
0e3426bb RM |
693 | endef |
694 | object-suffixes-left := $(versioned) | |
dc997231 | 695 | include $(o-iterator) |
0e3426bb RM |
696 | |
697 | define o-iterator-doit | |
8d57beea | 698 | $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o; $$(do-install-program) |
0e3426bb RM |
699 | endef |
700 | object-suffixes-left := $(versioned) | |
dc997231 | 701 | include $(o-iterator) |
499e7464 UD |
702 | else |
703 | define o-iterator-doit | |
8d57beea UD |
704 | $(inst_slibdir)/$o$($o-version): \ |
705 | $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so; | |
1ef32c3d | 706 | $$(make-shlib-link) |
499e7464 UD |
707 | endef |
708 | object-suffixes-left := $(versioned) | |
709 | include $(o-iterator) | |
710 | ||
711 | define o-iterator-doit | |
8d57beea | 712 | $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o; |
499e7464 UD |
713 | $$(do-install-program) |
714 | endef | |
715 | object-suffixes-left := $(versioned) | |
716 | include $(o-iterator) | |
717 | endif | |
0e3426bb | 718 | endif |
102800e0 RM |
719 | |
720 | define do-install-so | |
721 | $(do-install-program) | |
722 | $(patsubst %,ln -s -f $(@F) $(@D)/$(patsubst %$*.so,%,$(<F))$(libprefix)$*.so,\ | |
723 | $(filter-out %.so,$@)) | |
724 | endef | |
094bacdb | 725 | |
102800e0 RM |
726 | so-versions := $(sort $(foreach so,$(install-lib.so),.so$($(so)-version))) |
727 | $(foreach v,$(so-versions),\ | |
8d57beea | 728 | $(inst_slibdir)/lib$(libprefix)%$v): $(common-objpfx)lib%.so |
102800e0 RM |
729 | $(do-install-so) |
730 | $(foreach v,$(so-versions),\ | |
8d57beea | 731 | $(inst_slibdir)/$(libprefix)%$v): $(common-objpfx)%.so |
102800e0 | 732 | $(do-install-so) |
51f75302 RM |
733 | endif |
734 | ||
28f540f4 | 735 | ifdef install-bin |
8d57beea | 736 | $(addprefix $(inst_bindir)/,$(install-bin)): $(inst_bindir)/%: $(objpfx)% |
273d56ce | 737 | $(do-install-program) |
28f540f4 | 738 | endif |
1ef32c3d | 739 | ifdef install-rootsbin |
8d57beea UD |
740 | $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)): |
741 | $(inst_rootsbindir)/%: $(objpfx)% | |
1ef32c3d UD |
742 | $(do-install-program) |
743 | endif | |
28f540f4 | 744 | ifdef install-sbin |
8d57beea | 745 | $(addprefix $(inst_sbindir)/,$(install-sbin)): $(inst_sbindir)/%: $(objpfx)% |
273d56ce | 746 | $(do-install-program) |
28f540f4 RM |
747 | endif |
748 | ifdef install-lib | |
749 | install-lib.a := $(filter lib%.a,$(install-lib)) | |
750 | install-lib-non.a := $(filter-out lib%.a,$(install-lib)) | |
751 | ifdef install-lib-non.a | |
9d187dd4 UD |
752 | $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \ |
753 | $(inst_libdir)/$(libprefix)%: $(objpfx)% | |
28f540f4 RM |
754 | $(do-install) |
755 | endif | |
756 | ifdef install-lib.a | |
8d57beea UD |
757 | $(install-lib.a:lib%.a=$(inst_libdir)/lib$(libprefix)%.a): \ |
758 | $(inst_libdir)/lib$(libprefix)%.a: $(objpfx)lib%.a | |
28f540f4 RM |
759 | $(do-install) |
760 | $(patsubst %,$(RANLIB) $@,$(filter-out $(non-lib.a),$(<F))) | |
761 | endif | |
762 | endif | |
763 | ifdef install-data | |
8d57beea UD |
764 | $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: %; |
765 | $(do-install) | |
28f540f4 RM |
766 | endif |
767 | headers := $(strip $(headers)) | |
768 | ifdef headers | |
8d57beea UD |
769 | $(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: %; |
770 | $(do-install) | |
28f540f4 RM |
771 | endif # headers |
772 | ||
1ef32c3d UD |
773 | .PHONY: install-bin-nosubdir install-rootsbin-nosubdir install-sbin-nosubdir \ |
774 | install-lib-nosubdir install-data-nosubdir install-headers-nosubdir | |
8d57beea UD |
775 | install-bin-nosubdir: $(addprefix $(inst_bindir)/,$(install-bin)) |
776 | install-rootsbin-nosubdir: \ | |
777 | $(addprefix $(inst_rootsbindir)/,$(install-rootsbin)) | |
778 | install-sbin-nosubdir: $(addprefix $(inst_sbindir)/,$(install-sbin)) | |
779 | install-lib-nosubdir: $(addprefix $(inst_libdir)/,\ | |
28f540f4 RM |
780 | $(patsubst lib%.a,lib$(libprefix)%.a,$(install-lib.a)) \ |
781 | $(addprefix $(libprefix),$(install-lib-non.a))) | |
8d57beea UD |
782 | install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data)) |
783 | install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers)) | |
28f540f4 RM |
784 | install-others-nosubdir: $(install-others) |
785 | ||
786 | # We need all the `-nosubdir' targets so that `install' in the parent | |
787 | # doesn't depend on several things which each iterate over the subdirs. | |
788 | # This rule makes `install-FOO' always use `install-FOO-nosubdir' as a | |
789 | # subroutine. Then in the parent `install-FOO' also causes subdir makes. | |
790 | install-%:: install-%-nosubdir ; | |
791 | ||
792 | .PHONY: install install-no-libc.a-nosubdir | |
793 | install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\ | |
794 | install-bin-nosubdir install-lib-nosubdir \ | |
1ef32c3d UD |
795 | install-others-nosubdir install-rootsbin-nosubdir \ |
796 | install-sbin-nosubdir | |
28f540f4 RM |
797 | install: install-no-libc.a-nosubdir |
798 | \f | |
799 | # Command to compile $< in $(objdir) using the native libraries. | |
800 | define native-compile | |
801 | cwd=`pwd`; cd $(@D); $(BUILD_CC) $(BUILD_CFLAGS) \ | |
802 | $(addprefix $$cwd/,$^) -o $(@F) | |
803 | endef | |
804 | ||
805 | # Command to compile $< in $(common-objdir) using the native libraries. | |
0d204b0a | 806 | # We must cd to $(objdir) anyway so that $(..)config.h is valid. |
28f540f4 | 807 | define common-objdir-compile |
0d204b0a UD |
808 | cd $(objpfx).; \ |
809 | $(BUILD_CC) $(BUILD_CFLAGS) $(<:$(common-objpfx)%=$(..)%) -o $(..)$(@F) | |
28f540f4 RM |
810 | endef |
811 | ||
812 | # We always want to use configuration definitions. | |
7cc27f44 | 813 | BUILD_CFLAGS = -include $(common-objpfx)config.h |
28f540f4 RM |
814 | |
815 | # Support the GNU standard name for this target. | |
816 | .PHONY: check | |
817 | check: tests | |
818 | \f | |
819 | .PHONY: TAGS | |
36dbcbc9 | 820 | TAGS: $(common-objpfx)distinfo-$(subdir) $(..)MakeTAGS |
dbdb6189 | 821 | $(MAKE) $(addprefix -f ,$^) $@ |
28f540f4 | 822 | |
36dbcbc9 | 823 | $(..)po/%.pot: $(common-objpfx)distinfo-$(subdir) $(..)MakeTAGS FORCE |
ce563359 RM |
824 | $(MAKE) $(addprefix -f ,$(filter-out FORCE,$^)) $@ |
825 | FORCE: | |
a182affd RM |
826 | |
827 | ||
28f540f4 RM |
828 | .PHONY: echo-headers |
829 | echo-headers: | |
830 | @echo $(headers) | |
831 | ||
832 | \f | |
833 | # Common cleaning targets. | |
834 | ||
835 | .PHONY: common-mostlyclean common-clean mostlyclean clean | |
836 | clean: common-clean | |
837 | mostlyclean: common-mostlyclean | |
838 | ||
839 | # Remove the object files. | |
840 | common-mostlyclean: | |
841 | -rm -f $(addprefix $(objpfx),$(tests) $(others) \ | |
842 | $(addsuffix .o,$(tests) $(others)) \ | |
843 | $(addsuffix .out,$(tests))) | |
4788ab46 | 844 | -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib)) |
6e953631 | 845 | -rm -f core $(common-objpfx)stub-$(subdir) |
51f75302 RM |
846 | $(rmobjs) |
847 | define rmobjs | |
848 | $(foreach o,$(object-suffixes), | |
564210fe | 849 | -rm -f $(addprefix $(objpfx),stamp$o-$(subdir)) $(o-objects)) |
51f75302 | 850 | endef |
28f540f4 RM |
851 | |
852 | # Also remove the dependencies and generated source files. | |
853 | common-clean: common-mostlyclean | |
deab9dea | 854 | -rm -f $(addprefix $(objpfx),$(generated)) $(+depfiles) |
5290baf0 | 855 | -rm -fr $(addprefix $(objpfx),$(generated-dirs)) |
924840c5 | 856 | -rm -f $(addprefix $(common-objpfx),$(common-generated)) |
36dbcbc9 | 857 | -rm -f $(common-objpfx)distinfo-$(subdir) |
28f540f4 RM |
858 | \f |
859 | # Produce a file `stub-$(subdir)' which contains `#define __stub_FUNCTION' | |
860 | # for each function which is a stub. We grovel over all the .d files | |
861 | # looking for references to source files in sysdeps/stub. Then we grovel | |
862 | # over each referenced source file to see what stub function it defines. | |
863 | ||
864 | .PHONY: stubs # The parent Makefile calls this target. | |
865 | stubs: $(common-objpfx)stub-$(subdir) | |
866 | s = $(sysdep_dir)/stub | |
867 | $(common-objpfx)stub-$(subdir): $(+depfiles) | |
868 | # Use /dev/null since `...` might expand to empty. | |
c4cc693d | 869 | (s=`cd $s; /bin/pwd`; \ |
6e953631 | 870 | $(patsubst %/,cd %;,$(objpfx)) \ |
c4cc693d RM |
871 | sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \ |
872 | `sed -n 's@^.*$s/\([a-z0-9_-]*\.c\).*$$@'"$$s"/'\1@p' \ | |
873 | $(patsubst $(objpfx)%,%,$^) /dev/null` \ | |
874 | /dev/null) > $@T | |
28f540f4 RM |
875 | mv -f $@T $@ |
876 | \f | |
877 | # Make the distribution tar file. | |
878 | ||
879 | .PHONY: dist | |
36dbcbc9 | 880 | dist: $(common-objpfx)distinfo-$(subdir) $(..)Make-dist |
28f540f4 RM |
881 | $(MAKE) -f $< -f $(word 2,$^) $(Make-dist-args) |
882 | ||
10ceac89 RM |
883 | # Avoid depending on source files found in sysdeps dirs, |
884 | # because the references affect implicit rule selection. | |
885 | dist: $(filter-out %.c %.S %.s,$(distribute)) | |
28f540f4 RM |
886 | |
887 | # We used to simply export all these variables, but that frequently made the | |
888 | # environment get too large. Instead, we write all the information into | |
889 | # a generated makefile fragment `distinfo', and then include it with -f in | |
890 | # the sub-make that makes the distribution (above). | |
36dbcbc9 | 891 | $(common-objpfx)distinfo-$(subdir): Makefile $(..)Makerules |
28f540f4 RM |
892 | $(distinfo-vars) |
893 | mv -f $@.new $@ | |
36dbcbc9 | 894 | .PHONY: subdir_distinfo distinfo |
6a441471 | 895 | subdir_distinfo: distinfo |
36dbcbc9 | 896 | distinfo: $(common-objpfx)distinfo-$(subdir) |
28f540f4 RM |
897 | |
898 | define distinfo-vars | |
899 | rm -f $@.new | |
a4242e25 RM |
900 | echo > $@.new 'subdir := $(subdir)' |
901 | $(foreach var,subdir-dirs sources elided-routines sysdep_routines \ | |
dfe1754a | 902 | headers sysdep_headers distribute dont_distribute generated \ |
4d6acc61 | 903 | others tests extra-libs $(extra-libs:%=%-routines) \ |
6a441471 RM |
904 | versioned \ |
905 | $(addprefix install-,lib lib.so data bin sbin others), | |
4d6acc61 RM |
906 | echo >> $@.new '$(subdir)-$(var) := $($(var))' |
907 | echo >> $@.new '$(var) = $$($(subdir)-$(var))') | |
28f540f4 RM |
908 | endef |
909 | \f | |
910 | ifneq (,$(strip $(gpl2lgpl))) | |
911 | ifneq (,$(wildcard $(..)gpl2lgpl.sed)) | |
912 | # Snarf from the master source and frob the copying notice. | |
913 | $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/% | |
914 | sed -f $^ > $@-tmp | |
915 | # So I don't edit them by mistake. | |
916 | chmod a-w $@-tmp | |
917 | mv -f $@-tmp $@ | |
a2fe9c76 | 918 | test ! -d CVS || cvs commit -m'Updated from $^' $@ |
28f540f4 RM |
919 | endif |
920 | endif |