]>
Commit | Line | Data |
---|---|---|
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 | # | |
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 | |
c7562c74 | 34 | # This ` unconfuses emacs. |
28f540f4 RM |
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 | |
96f873b9 | 40 | all: objs lib others |
28f540f4 | 41 | |
0413b54c | 42 | ifeq ($(build-programs),yes) |
a182affd | 43 | others: $(addprefix $(objpfx),$(extra-objs) \ |
1ef32c3d UD |
44 | $(install-lib) $(install-bin) \ |
45 | $(install-rootsbin) $(install-sbin)) | |
0413b54c UD |
46 | else |
47 | others: $(addprefix $(objpfx),$(extra-objs) \ | |
48 | $(install-lib)) | |
49 | endif | |
a182affd | 50 | |
28f540f4 RM |
51 | ifneq "$(findstring env,$(origin headers))" "" |
52 | headers := | |
53 | endif | |
54 | ||
55 | ifneq "$(findstring env,$(origin generated))" "" | |
56 | generated := | |
57 | endif | |
58 | ||
924840c5 TBB |
59 | ifneq "$(findstring env,$(origin common-generated))" "" |
60 | common-generated := | |
61 | endif | |
62 | ||
28f540f4 RM |
63 | include ../Makerules |
64 | ||
65 | .PHONY: subdir_lib | |
3bbceb12 | 66 | subdir_lib: lib-noranlib |
28f540f4 RM |
67 | |
68 | # Some subdirs need to install a dummy library. | |
69 | # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)". | |
6e953631 | 70 | dep-dummy-lib = $(common-objpfx)dummy.o |
28f540f4 RM |
71 | define make-dummy-lib |
72 | $(AR) cr$(verbose) $@ $< | |
73 | endef | |
74015205 | 74 | |
6e953631 | 75 | $(common-objpfx)dummy.c: |
f0097fa0 | 76 | rm -f $@ |
11336c16 | 77 | echo 'void __dummy__ (void) { }' > $@ |
6e953631 | 78 | $(common-objpfx)empty.c: |
f0097fa0 | 79 | cp -f /dev/null $@ |
af6f3906 UD |
80 | common-generated += dummy.o dummy.c empty.c \ |
81 | $(addprefix empty,$(object-suffixes)) | |
28f540f4 | 82 | \f |
6d52618b | 83 | # This makes all the auxiliary and test programs. |
28f540f4 RM |
84 | |
85 | .PHONY: others tests | |
0413b54c | 86 | ifeq ($(build-programs),yes) |
414fd335 | 87 | others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs)) |
0413b54c UD |
88 | else |
89 | others: $(addprefix $(objpfx),$(extra-objs)) | |
90 | endif | |
28f540f4 | 91 | ifeq ($(cross-compiling),yes) |
a44d2393 | 92 | tests: $(addprefix $(objpfx),$(tests) $(tests-static) $(test-srcs)) |
28f540f4 | 93 | else |
a44d2393 | 94 | tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout) |
28f540f4 RM |
95 | endif |
96 | ||
0413b54c | 97 | ifeq ($(build-programs),yes) |
414fd335 | 98 | binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs) |
e1586792 | 99 | binaries-static = $(others-static) $(tests-static) $(test-srcs-static) |
0413b54c | 100 | else |
e1586792 UD |
101 | binaries-all = $(tests) $(test-srcs) |
102 | binaries-static = $(tests-static) $(test-srcs-static) | |
103 | endif | |
104 | ||
105 | binaries-shared = $(filter-out $(binaries-static), $(binaries-all)) | |
106 | ||
107 | ifneq "$(strip $(binaries-shared))" "" | |
108 | $(addprefix $(objpfx),$(binaries-shared)): %: %.o \ | |
0413b54c UD |
109 | $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \ |
110 | $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) | |
111 | $(+link) | |
112 | endif | |
e1586792 UD |
113 | |
114 | ifneq "$(strip $(binaries-static))" "" | |
115 | $(addprefix $(objpfx),$(binaries-static)): %: %.o \ | |
116 | $(sort $(filter $(common-objpfx)libc%,$(link-libc-static))) \ | |
117 | $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) | |
118 | $(+link-static) | |
0413b54c | 119 | endif |
28f540f4 | 120 | |
e61abf83 | 121 | ifneq "$(strip $(tests) $(test-srcs))" "" |
28f540f4 RM |
122 | # These are the implicit rules for making test outputs |
123 | # from the test programs and whatever input files are present. | |
196980f5 | 124 | $(objpfx)%.out: %.args $(objpfx)% %.input |
fa0bc87c | 125 | $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@ |
196980f5 | 126 | $(objpfx)%.out: %.args $(objpfx)% |
fa0bc87c | 127 | $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@ |
196980f5 | 128 | $(objpfx)%.out: %.input $(objpfx)% |
fa0bc87c | 129 | $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@ |
196980f5 | 130 | $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence. |
fa0bc87c | 131 | $($*-ENV) $(built-program-cmd) > $@ |
28f540f4 | 132 | endif # tests |
a44d2393 UD |
133 | |
134 | ifneq "$(strip $(tests-static) $(test-static-srcs))" "" | |
135 | # These are the implicit rules for making test outputs | |
136 | # from the test programs and whatever input files are present. | |
137 | $(objpfx)%.sout: %.args $(objpfx)% %.input | |
138 | $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@ | |
139 | $(objpfx)%.sout: %.args $(objpfx)% | |
140 | $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@ | |
141 | $(objpfx)%.sout: %.input $(objpfx)% | |
142 | $($*-ENV) $(built-program-file) < $(word 1,$^) > $@ | |
143 | $(objpfx)%.sout: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence. | |
144 | $($*-ENV) $(built-program-file) > $@ | |
145 | endif # tests | |
28f540f4 RM |
146 | \f |
147 | .PHONY: distclean realclean subdir_distclean subdir_realclean \ | |
edf5b2d7 | 148 | subdir_clean subdir_mostlyclean |
28f540f4 RM |
149 | subdir_mostlyclean: mostlyclean |
150 | subdir_clean: clean | |
151 | subdir_distclean: distclean | |
152 | subdir_realclean: realclean | |
153 | realclean: distclean | |
154 | distclean: clean | |
155 | ||
156 | .PHONY: subdir_echo-headers | |
157 | subdir_echo-headers: echo-headers | |
158 | ||
159 | .PHONY: subdir_echo-distinfo | |
160 | subdir_echo-distinfo: | |
d705269e | 161 | @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \ |
924840c5 | 162 | $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute)) |
28f540f4 RM |
163 | |
164 | # We want to install everything except the library itself, but update all | |
165 | # our portions of the library because the parent make will install it later | |
166 | # (likewise the stubs file). | |
167 | .PHONY: subdir_install | |
613a76ff | 168 | subdir_install: install-no-libc.a lib-noranlib stubs |
28f540f4 RM |
169 | |
170 | .PHONY: subdir_TAGS subdir_dist | |
171 | subdir_TAGS: TAGS | |
172 | subdir_dist: dist | |
173 | ||
174 | # Convenient target to update all the generated source files. | |
175 | .PHONY: generated | |
acf51e02 TBB |
176 | generated: $(addprefix $(common-objpfx),$(common-generated)) \ |
177 | $(addprefix $(objpfx),$(generated)) | |
5790c439 | 178 | |
bd78530f UD |
179 | # Target required by the Hurd to ensure that all the MiG-generated |
180 | # headers are in place before building a subdirectory. | |
181 | .PHONY: before-compile | |
182 | before-compile: $(before-compile) | |
183 | ||
af6f3906 UD |
184 | define o-iterator-doit |
185 | $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile); | |
186 | $$(compile-command.c) | |
187 | endef | |
188 | object-suffixes-left := $(object-suffixes) | |
189 | include $(o-iterator) | |
190 | ||
6591c335 UD |
191 | define o-iterator-doit |
192 | $(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile); | |
193 | $$(compile-command.c) | |
194 | endef | |
195 | object-suffixes-left := $(object-suffixes) | |
196 | include $(o-iterator) |