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