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