]> git.ipfire.org Git - thirdparty/glibc.git/blob - Makefile
Update.
[thirdparty/glibc.git] / Makefile
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 # Master Makefile for the GNU C library
21 #
22 ifneq (,)
23 This makefile requires GNU Make.
24 endif
25
26
27 # This is the default target; it makes everything except the tests.
28 .PHONY: all
29 all: lib others
30 \f
31 ifeq ($(with-cvs),yes)
32 define autoconf-it
33 @-rm -f $@.new
34 autoconf $(ACFLAGS) $< > $@.new
35 chmod a-w,a+x $@.new
36 mv -f $@.new $@
37 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
38 endef
39 else
40 define autoconf-it
41 @-rm -f $@.new
42 autoconf $(ACFLAGS) $< > $@.new
43 chmod a-w,a+x $@.new
44 mv -f $@.new $@
45 endef
46 endif
47
48 configure: configure.in aclocal.m4; $(autoconf-it)
49 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
50
51 include Makeconfig
52
53 ifndef avoid-generated
54 -include $(objpfx)sysd-dirs
55 define \n
56
57
58 endef
59 sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
60 endif
61
62 # These are the subdirectories containing the library source.
63 subdirs = csu assert ctype db2 locale intl catgets math setjmp signal stdlib \
64 stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd \
65 posix io termios resource misc socket sysvipc gmon gnulib iconv \
66 iconvdata wctype manual shadow md5-crypt po argp $(add-ons) nss \
67 localedata $(rt) $(sysdep-subdirs) $(binfmt-subdir)
68 export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
69
70 # The mach and hurd subdirectories have many generated header files which
71 # much of the rest of the library depends on, so it is best to build them
72 # first (and mach before hurd, at that). The before-compile additions in
73 # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
74 # not to exist when making in other directories, but it will be slower that
75 # way with more somewhat expensive `make' invocations.
76 subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
77 $(filter-out mach hurd,$(subdirs))
78
79 # All initialization source files.
80 +subdir_inits := $(wildcard $(foreach dir,$(subdirs),$(dir)/init-$(dir).c))
81 # All subdirectories containing initialization source files.
82 +init_subdirs := $(patsubst %/,%,$(dir $(+subdir_inits)))
83
84
85 # These are the targets that are made by making them in each subdirectory.
86 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean \
87 subdir_clean subdir_distclean subdir_realclean \
88 tests subdir_lint.out \
89 subdir_distinfo \
90 subdir_echo-headers subdir_echo-distinfo \
91 subdir_install \
92 $(addprefix install-, no-libc.a bin lib data headers others)
93 \f
94 headers := errno.h sys/errno.h bits/errno.h limits.h values.h \
95 features.h gnu-versions.h bits/libc-lock.h bits/xopen_lim.h
96 aux = sysdep $(libc-init) version
97 before-compile += $(objpfx)version-info.h
98
99 echo-headers: subdir_echo-headers
100
101 # The headers are in the include directory.
102 subdir-dirs = include
103 vpath %.h $(subdir-dirs)
104
105 # What to install.
106 install-others = $(inst_includedir)/gnu/stubs.h
107 install-bin = glibcbug
108
109 ifeq (yes,$(build-shared))
110 install-others += $(inst_includedir)/gnu/lib-names.h
111 endif
112
113 ifeq (yes,$(gnu-ld))
114 libc-init = set-init
115 else
116 libc-init = munch-init
117 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
118 awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
119 mv -f $@-t $@
120 generated := $(generated) munch-init.c
121 endif
122
123
124 include Makerules
125
126 # Install from subdirectories too.
127 install: subdir_install
128
129 # Make sure that the dynamic linker is installed before libc.
130 $(inst_slibdir)/libc-$(version).so: elf/subdir_install
131
132 # Create links for shared libraries using the `ldconfig' program is possible.
133 # Ignore the error if we cannot update /etc/ld.so.cache.
134 ifeq (no,$(cross-compiling))
135 ifeq (yes,$(build-shared))
136 install:
137 -test ! -x $(common-objpfx)elf/ldconfig || \
138 $(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir)
139 ifneq (no,$(PERL))
140 ifeq (/usr,$(prefix))
141 ifeq (,$(install_root))
142 CC="$(CC)" $(PERL) test-installation.pl $(common-objpfx)
143 endif
144 endif
145 endif
146 endif
147 endif
148
149 # Build subdirectory lib objects.
150 lib-noranlib: subdir_lib
151
152 ifeq (yes,$(build-shared))
153 # Build the shared object from the PIC object library.
154 lib: $(common-objpfx)libc.so
155 endif
156
157 all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs)))
158 $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
159 (echo define sysdep-subdirs; \
160 sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \
161 echo endef) > $@-tmp
162 mv -f $@-tmp $@
163 \f
164 all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
165 $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
166 (case $(config-os) in \
167 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
168 | $(CC) -E -P - | \
169 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
170 if [ -z "$$version" ]; then \
171 if [ -r /proc/version ]; then \
172 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
173 < /proc/version`; \
174 else \
175 version=`uname -r`; \
176 fi; \
177 fi; \
178 echo -n "\"Compiled on a Linux $$version system "; \
179 echo "on `date +%Y-%m-%d`.\\n\"" ;; \
180 *) ;; \
181 esac; \
182 files="$(all-Banner-files)"; \
183 if test -n "$$files"; then \
184 echo "\"Available extensions:"; \
185 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
186 echo "\""; \
187 fi) > $@T
188 mv -f $@T $@
189 generated += version-info.h
190
191 version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
192 $(version.c-objects): $(objpfx)version-info.h
193 \f
194 # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
195 # contains `#define __stub_FUNCTION' for each function which is a stub.
196 # Here we paste all of these together into <gnu/stubs.h>.
197
198 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
199
200 # Since stubs.h is never needed when building the library, we simplify the
201 # hairy installation process by producing it in place only as the last part
202 # of the top-level `make install'. It depends on subdir_install, which
203 # iterates over all the subdirs; subdir_install in each subdir depends on
204 # the subdir's stubs file. Having more direct dependencies would result in
205 # extra iterations over the list for subdirs and many recursive makes.
206 $(inst_includedir)/gnu/stubs.h: subdir_install
207 $(make-target-directory)
208 @rm -f $(objpfx)stubs.h
209 (echo '/* This file is automatically generated.';\
210 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
211 echo ' in the C library which is a stub, meaning it will fail';\
212 echo ' every time called, usually setting errno to ENOSYS. */';\
213 sort $(subdir-stubs)) > $(objpfx)stubs.h
214 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
215 then echo 'stubs.h unchanged'; \
216 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
217 rm -f $(objpfx)stubs.h
218 \f
219 ifeq (yes,$(build-shared))
220
221 $(inst_includedir)/gnu/lib-names.h: $(common-objpfx)gnu/lib-names.h
222 $(make-target-directory)
223 if test -r $@ && cmp -s $< $@; \
224 then echo 'gnu/lib-names.h unchanged'; \
225 else $(INSTALL_DATA) $< $@; fi
226 endif
227 \f
228 # The `glibcbug' script contains the version number and it shall be rebuild
229 # whenever this changes or the `glibcbug.in' file.
230 $(objpfx)glibcbug: $(common-objpfx)config.status glibcbug.in
231 cd $(<D); CONFIG_FILES=$(@F) CONFIG_HEADERS= $(SHELL) $(<F)
232 \f
233 # This makes the Info or DVI file of the documentation from the Texinfo source.
234 .PHONY: info dvi
235 info dvi:
236 $(MAKE) $(PARALLELMFLAGS) -C manual $@
237 \f
238 # This makes all the subdirectory targets.
239
240 # For each target, make it depend on DIR/target for each subdirectory DIR.
241 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
242
243 # Compute a list of all those targets.
244 all-subdirs-targets := $(foreach dir,$(subdirs),\
245 $(addprefix $(dir)/,$(+subdir_targets)))
246
247 # The action for each of those is to cd into the directory and make the
248 # target there.
249 $(all-subdirs-targets):
250 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
251
252 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
253 \f
254 # Targets to clean things up to various degrees.
255
256 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
257
258 # Subroutines of all cleaning targets.
259 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
260 -rm -f $(foreach o,$(object-suffixes),\
261 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
262 $(addprefix $(objpfx),$(install-lib))
263 parent-clean: parent-mostlyclean common-clean
264 -rm -f $(addprefix $(common-objpfx),$(common-generated))
265 -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules)
266
267 clean: parent-clean
268 # This is done this way rather than having `subdir_clean' be a
269 # dependency of this target so that libc.a will be removed before the
270 # subdirectories are dealt with and so they won't try to remove object
271 # files from it when it's going to be removed anyway.
272 @$(MAKE) subdir_clean no_deps=t
273 mostlyclean: parent-mostlyclean
274 @$(MAKE) subdir_mostlyclean no_deps=t
275
276 # The realclean target is just like distclean for the parent, but we want
277 # the subdirs to know the difference in case they care.
278 realclean distclean: parent-clean
279 # This is done this way rather than having `subdir_distclean' be a
280 # dependency of this target so that libc.a will be removed before the
281 # subdirectories are dealt with and so they won't try to remove object
282 # files from it when it's going to be removed anyway.
283 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes
284
285 # Subroutine of distclean and realclean.
286 distclean-1: subdir_$(distclean-1)
287 -rm -f $(config-generated)
288 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
289 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
290 -rm -f $(addprefix $(objpfx),glibcbug)
291 ifdef objdir
292 -rm -f $(objpfx)Makefile
293 endif
294 -rm -f $(sysdep-$(distclean-1))
295 \f
296 .PHONY: echo_subdirs
297 echo_subdirs:;@echo '$(subdirs)'
298
299 .PHONY: echo-distinfo parent_echo-distinfo
300 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
301 parent_echo-distinfo:
302 @echo $(addprefix +header+,$(headers)) \
303 $(addprefix +nodist+,$(generated))
304
305 \f
306 .PHONY: parent-tests
307 tests: parent-tests
308
309 # Run a test on the header files we use.
310 parent-tests: $(objpfx)isomac
311 $(dir $<)$(notdir $<) '$(CC)' '-Iinclude $(+sysdep-includes)' > $<.out
312
313 $(objpfx)isomac: isomac.c
314 $(native-compile)
315 \f
316 # Make the distribution tarfile.
317
318 distribute := README INSTALL FAQ NOTES NEWS PROJECTS BUGS \
319 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
320 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
321 extra-lib.mk o-iterator.mk isomac.c \
322 libc.map mkinstalldirs move-if-change install-sh \
323 configure configure.in aclocal.m4 config.sub config.guess\
324 config.h.in config.make.in config-name.in Makefile.in \
325 autolock.sh rellns-sh munch-tmpl.c munch.awk interp.c \
326 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
327 rpm/Makefile rpm/template rpm/rpmrc glibcbug.in abi-tags \
328 stub-tag.h test-installation.pl
329
330 distribute := $(strip $(distribute))
331 generated := $(generated) stubs.h version-info.h
332
333 README: README.template version.h ; # Make-dist should update README.
334
335 define format-me
336 @rm -f $@
337 makeinfo --no-validate --no-warn --no-headers $< -o $@
338 -chmod a-w $@
339 endef
340 INSTALL: manual/maint.texi; $(format-me)
341 NOTES: manual/creature.texi; $(format-me)
342 manual/dir-add.texi manual/dir-add.info: FORCE
343 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
344 FAQ: gen-FAQ.pl FAQ.in
345 $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
346 FORCE:
347
348 rpm/%: subdir_distinfo
349 $(MAKE) $(PARALLELMFLAGS) -C $(@D) subdirs='$(subdirs)' $(@F)
350
351 iconvdata/%:
352 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
353
354 # This is a special goal for people making binary distributions. Normally
355 # everybody uses the DES based crypt library but for the distribution we
356 # need the only-MD5 based one as well.
357 md5-crypt/libmd5crypt:
358 $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)