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