]> git.ipfire.org Git - thirdparty/glibc.git/blob - Rules
5f45413aa7a3cb4119a9690e84e06c2622f3e3bf
[thirdparty/glibc.git] / Rules
1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
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
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.
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 ` 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) $(install-bin) \
45 $(install-rootsbin) $(install-sbin))
46 else
47 others: $(addprefix $(objpfx),$(extra-objs) \
48 $(install-lib))
49 endif
50
51 ifneq "$(findstring env,$(origin headers))" ""
52 headers :=
53 endif
54
55 ifneq "$(findstring env,$(origin generated))" ""
56 generated :=
57 endif
58
59 ifneq "$(findstring env,$(origin common-generated))" ""
60 common-generated :=
61 endif
62
63 include ../Makerules
64
65 .PHONY: subdir_lib
66 subdir_lib: lib-noranlib
67
68 # Some subdirs need to install a dummy library.
69 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
70 dep-dummy-lib = $(common-objpfx)dummy.o
71 define make-dummy-lib
72 $(AR) cr$(verbose) $@ $<
73 endef
74
75 $(common-objpfx)dummy.c:
76 rm -f $@
77 echo 'void __dummy__ (void) { }' > $@
78 $(common-objpfx)empty.c:
79 cp -f /dev/null $@
80 common-generated += dummy.o dummy.c empty.c \
81 $(addprefix empty,$(object-suffixes))
82 \f
83 # This makes all the auxiliary and test programs.
84
85 .PHONY: others tests
86 ifeq ($(build-programs),yes)
87 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
88 else
89 others: $(addprefix $(objpfx),$(extra-objs))
90 endif
91 ifeq ($(cross-compiling),yes)
92 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
93 ifeq ($(build-static),yes)
94 tests: $(addprefix $(objpfx),$(tests-static))
95 endif
96 else
97 tests: $(tests:%=$(objpfx)%.out)
98 ifeq ($(build-static),yes)
99 tests: $(tests-static:%=$(objpfx)%.sout)
100 endif
101 endif
102
103 ifeq ($(build-programs),yes)
104 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
105 binaries-static = $(others-static) $(tests-static) $(test-srcs-static)
106 else
107 binaries-all = $(tests) $(test-srcs)
108 binaries-static = $(tests-static) $(test-srcs-static)
109 endif
110
111 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
112
113 ifneq "$(strip $(binaries-shared))" ""
114 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
115 $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
116 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
117 $(+link)
118 endif
119
120 ifneq "$(strip $(binaries-static))" ""
121 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
122 $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
123 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
124 $(+link-static)
125 endif
126
127 ifneq "$(strip $(tests) $(test-srcs))" ""
128 # These are the implicit rules for making test outputs
129 # from the test programs and whatever input files are present.
130 $(objpfx)%.out: %.args $(objpfx)% %.input
131 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
132 $(objpfx)%.out: %.args $(objpfx)%
133 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
134 $(objpfx)%.out: %.input $(objpfx)%
135 $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
136 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
137 $($*-ENV) $(built-program-cmd) > $@
138 endif # tests
139
140 ifneq "$(strip $(tests-static) $(test-static-srcs))" ""
141 # These are the implicit rules for making test outputs
142 # from the test programs and whatever input files are present.
143 $(objpfx)%.sout: %.args $(objpfx)% %.input
144 $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@
145 $(objpfx)%.sout: %.args $(objpfx)%
146 $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@
147 $(objpfx)%.sout: %.input $(objpfx)%
148 $($*-ENV) $(built-program-file) < $(word 1,$^) > $@
149 $(objpfx)%.sout: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
150 $($*-ENV) $(built-program-file) > $@
151 endif # tests
152 \f
153 .PHONY: distclean realclean subdir_distclean subdir_realclean \
154 subdir_clean subdir_mostlyclean
155 subdir_mostlyclean: mostlyclean
156 subdir_clean: clean
157 subdir_distclean: distclean
158 subdir_realclean: realclean
159 realclean: distclean
160 distclean: clean
161
162 .PHONY: subdir_echo-headers
163 subdir_echo-headers: echo-headers
164
165 .PHONY: subdir_echo-distinfo
166 subdir_echo-distinfo:
167 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
168 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
169
170 # We want to install everything except the library itself, but update all
171 # our portions of the library because the parent make will install it later
172 # (likewise the stubs file).
173 .PHONY: subdir_install
174 subdir_install: install-no-libc.a lib-noranlib stubs
175
176 .PHONY: subdir_TAGS subdir_dist
177 subdir_TAGS: TAGS
178 subdir_dist: dist
179
180 # Convenient target to update all the generated source files.
181 .PHONY: generated
182 generated: $(addprefix $(common-objpfx),$(common-generated)) \
183 $(addprefix $(objpfx),$(generated))
184
185 # Target required by the Hurd to ensure that all the MiG-generated
186 # headers are in place before building a subdirectory.
187 .PHONY: before-compile
188 before-compile: $(before-compile)
189
190 define o-iterator-doit
191 $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
192 $$(compile-command.c)
193 endef
194 object-suffixes-left := $(object-suffixes)
195 include $(o-iterator)
196
197 define o-iterator-doit
198 $(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
199 $$(compile-command.c)
200 endef
201 object-suffixes-left := $(object-suffixes)
202 include $(o-iterator)
203
204 # There's no good place to put this - here will do.
205 # The dependencies are wrong if it's run from the top level.
206 ifeq ($(filter %posix, $(sysdirs)),)
207 L_tmpnam = 1
208 TMP_MAX = 0
209 L_ctermid = 1
210 L_cuserid = 1
211 else
212 L_tmpnam = 20
213 TMP_MAX = 238328
214 L_ctermid = 9
215 L_cuserid = 9
216 endif
217 stdio_lim = $(common-objpfx)bits/stdio_lim.h
218
219 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
220 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
221 $(common-objpfx)config.make
222 $(make-target-directory)
223 echo '#include "$(..)posix/bits/posix1_lim.h"' | \
224 SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \
225 $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT)
226 ifdef sed-remove-objpfx
227 sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt)
228 mv -f $(@:st=dt) $(@:st=d)
229 else
230 mv -f $(@:st=dT) $(@:st=d)
231 endif
232 fopen_max=`sed -n 's/^#define OPEN_MAX //p' $(@:st=hT)`; \
233 filename_max=`sed -n 's/^#define PATH_MAX //p' $(@:st=hT)`; \
234 fopen_max=$${fopen_max:-16}; \
235 filename_max=$${filename_max:-1024}; \
236 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
237 -e "s/@FILENAME_MAX@/$$filename_max/" \
238 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
239 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
240 -e "s/@L_ctermid@/$(L_ctermid)/" \
241 -e "s/@L_cuserid@/$(L_cuserid)/" \
242 $< > $(@:st=h.new)
243 $(move-if-change) $(@:st=h.new) $(@:st=h)
244 # Remove these last so that they can be examined if something went wrong.
245 rm -f $(@:st=hT) $(@:st=dT)
246 touch $@
247 # Get dependencies.
248 ifndef no_deps
249 -include $(stdio_lim:h=d)
250 endif
251 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st