[versioning=yes]: Build the mapfiles with a pattern rule that lists all of them as...
[platform/upstream/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 include Makeconfig
27
28
29 # This is the default target; it makes everything except the tests.
30 .PHONY: all
31 all: lib others
32 \f
33 ifeq ($(with-cvs),yes)
34 define autoconf-it
35 @-rm -f $@.new
36 autoconf $(ACFLAGS) $< > $@.new
37 chmod a-w,a+x $@.new
38 mv -f $@.new $@
39 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
40 endef
41 else
42 define autoconf-it
43 @-rm -f $@.new
44 autoconf $(ACFLAGS) $< > $@.new
45 chmod a-w,a+x $@.new
46 mv -f $@.new $@
47 endef
48 endif
49
50 configure: configure.in aclocal.m4; $(autoconf-it)
51 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
52
53 # These are the targets that are made by making them in each subdirectory.
54 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean    \
55                    subdir_clean subdir_distclean subdir_realclean       \
56                    tests subdir_lint.out                                \
57                    subdir_distinfo                                      \
58                    subdir_echo-headers subdir_echo-distinfo             \
59                    subdir_install                                       \
60                    $(addprefix install-, no-libc.a bin lib data headers others)
61 \f
62 headers := errno.h sys/errno.h bits/errno.h limits.h values.h   \
63            features.h gnu-versions.h bits/libc-lock.h bits/xopen_lim.h  \
64            gnu/libc-version.h
65
66 echo-headers: subdir_echo-headers
67
68 # The headers are in the include directory.
69 subdir-dirs = include
70 vpath %.h $(subdir-dirs)
71
72 # What to install.
73 install-others = $(inst_includedir)/gnu/stubs.h
74 install-bin = glibcbug
75
76 ifeq (yes,$(build-shared))
77 install-others += $(inst_includedir)/gnu/lib-names.h
78 endif
79
80 ifeq ($(versioning),yes)
81 lib-noranlib: lib-mapfiles
82 endif
83
84 include Makerules
85
86 ifeq ($(build-programs),yes)
87 others: $(addprefix $(objpfx),$(install-bin))
88 endif
89
90 # Install from subdirectories too.
91 install: subdir_install
92
93 # Make sure that the dynamic linker is installed before libc.
94 $(inst_slibdir)/libc-$(version).so: elf/ldso_install
95
96 .PHONY: elf/ldso_install
97 elf/ldso_install:
98         $(MAKE) -C $(@D) $(@F)
99
100 # Create links for shared libraries using the `ldconfig' program is possible.
101 # Ignore the error if we cannot update /etc/ld.so.cache.
102 ifeq (no,$(cross-compiling))
103 ifeq (yes,$(build-shared))
104 install:
105         -test ! -x $(common-objpfx)elf/ldconfig || \
106           $(common-objpfx)elf/ldconfig -d $(inst_slibdir) $(inst_libdir)
107 ifneq (no,$(PERL))
108 ifeq (/usr,$(prefix))
109 ifeq (,$(install_root))
110         CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
111 endif
112 endif
113 endif
114 endif
115 endif
116
117 # Build subdirectory lib objects.
118 lib-noranlib: subdir_lib
119
120 ifeq (yes,$(build-shared))
121 # Build the shared object from the PIC object library.
122 lib: $(common-objpfx)libc.so
123 endif
124 \f
125 # Makerules creates a file `stubs' in each subdirectory, which
126 # contains `#define __stub_FUNCTION' for each function defined in that
127 # directory which is a stub.
128 # Here we paste all of these together into <gnu/stubs.h>.
129
130 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
131
132 # Since stubs.h is never needed when building the library, we simplify the
133 # hairy installation process by producing it in place only as the last part
134 # of the top-level `make install'.  It depends on subdir_install, which
135 # iterates over all the subdirs; subdir_install in each subdir depends on
136 # the subdir's stubs file.  Having more direct dependencies would result in
137 # extra iterations over the list for subdirs and many recursive makes.
138 $(inst_includedir)/gnu/stubs.h: subdir_install
139         $(make-target-directory)
140         @rm -f $(objpfx)stubs.h
141         (echo '/* This file is automatically generated.';\
142          echo '   It defines a symbol `__stub_FUNCTION'\'' for each function';\
143          echo '   in the C library which is a stub, meaning it will fail';\
144          echo '   every time called, usually setting errno to ENOSYS.  */';\
145          sort $(subdir-stubs)) > $(objpfx)stubs.h
146         if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
147         then echo 'stubs.h unchanged'; \
148         else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
149         rm -f $(objpfx)stubs.h
150 \f
151 ifeq (yes,$(build-shared))
152
153 $(inst_includedir)/gnu/lib-names.h: $(common-objpfx)gnu/lib-names.h $(+force)
154         $(make-target-directory)
155         if test -r $@ && cmp -s $< $@; \
156         then echo 'gnu/lib-names.h unchanged'; \
157         else $(INSTALL_DATA) $< $@; fi
158 endif
159 \f
160 # The `glibcbug' script contains the version number and it shall be rebuild
161 # whenever this changes or the `glibcbug.in' file.
162 $(objpfx)glibcbug: $(common-objpfx)config.status glibcbug.in
163         cd $(<D) && CONFIG_FILES=$(@F) CONFIG_HEADERS= $(SHELL) $(<F)
164 \f
165 # This makes the Info or DVI file of the documentation from the Texinfo source.
166 .PHONY: info dvi
167 info dvi:
168         $(MAKE) $(PARALLELMFLAGS) -C manual $@
169 \f
170 # This makes all the subdirectory targets.
171
172 # For each target, make it depend on DIR/target for each subdirectory DIR.
173 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
174
175 # Compute a list of all those targets.
176 all-subdirs-targets := $(foreach dir,$(subdirs),\
177                                  $(addprefix $(dir)/,$(+subdir_targets)))
178
179 # The action for each of those is to cd into the directory and make the
180 # target there.
181 $(all-subdirs-targets):
182         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
183
184 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
185 \f
186 # Targets to clean things up to various degrees.
187
188 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
189
190 # Subroutines of all cleaning targets.
191 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
192         -rm -f $(foreach o,$(object-suffixes-for-libc),\
193                    $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
194                $(addprefix $(objpfx),$(install-lib))
195 parent-clean: parent-mostlyclean common-clean
196
197 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
198             $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules) \
199             $(objpfx)soversions.mk
200
201 clean: parent-clean
202 # This is done this way rather than having `subdir_clean' be a
203 # dependency of this target so that libc.a will be removed before the
204 # subdirectories are dealt with and so they won't try to remove object
205 # files from it when it's going to be removed anyway.
206         @$(MAKE) subdir_clean no_deps=t
207 mostlyclean: parent-mostlyclean
208         @$(MAKE) subdir_mostlyclean no_deps=t
209         -rm -f $(postclean)
210
211 # The realclean target is just like distclean for the parent, but we want
212 # the subdirs to know the difference in case they care.
213 realclean distclean: parent-clean
214 # This is done this way rather than having `subdir_distclean' be a
215 # dependency of this target so that libc.a will be removed before the
216 # subdirectories are dealt with and so they won't try to remove object
217 # files from it when it's going to be removed anyway.
218         @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
219                  sysdep-subdirs="$(sysdep-subdirs)"
220         -rm -f $(postclean)
221
222 # Subroutine of distclean and realclean.
223 distclean-1: subdir_$(distclean-1)
224         -rm -f $(config-generated)
225         -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
226         -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
227         -rm -f $(addprefix $(objpfx),glibcbug)
228 ifdef objdir
229         -rm -f $(objpfx)Makefile
230 endif
231         -rm -f $(sysdep-$(distclean-1))
232 \f
233 .PHONY: echo_subdirs
234 echo_subdirs:;@echo '$(subdirs)'
235
236 .PHONY: echo-distinfo parent_echo-distinfo
237 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
238 parent_echo-distinfo:
239         @echo $(addprefix +header+,$(headers)) \
240               $(addprefix +nodist+,$(generated))
241
242 \f
243 # Make the distribution tarfile.
244
245 distribute  :=  README README.libm INSTALL FAQ FAQ.in NOTES NEWS BUGS   \
246                 PROJECTS COPYING.LIB COPYING ChangeLog ChangeLog.[0-9]  \
247                 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS  \
248                 extra-lib.mk o-iterator.mk configure configure.in       \
249                 aclocal.m4 config.h.in config.make.in config-name.in    \
250                 Makefile.in sysdep.h set-hooks.h libc-symbols.h         \
251                 version.h shlib-versions rpm/Makefile rpm/template      \
252                 rpm/rpmrc glibcbug.in abi-tags stub-tag.h               \
253                 test-skeleton.c include/des.h Versions.def versions.awk \
254                 $(addprefix scripts/,                                   \
255                             rellns-sh config.sub config.guess           \
256                             mkinstalldirs move-if-change install-sh     \
257                             test-installation.pl gen-FAQ.pl)
258
259 distribute := $(strip $(distribute))
260 generated := $(generated) stubs.h
261
262 README: README.template version.h ; # Make-dist should update README.
263
264 define format-me
265 @rm -f $@
266 makeinfo --no-validate --no-warn --no-headers $< -o $@
267 -chmod a-w $@
268 endef
269 INSTALL: manual/install.texi; $(format-me)
270 NOTES: manual/creature.texi; $(format-me)
271 manual/dir-add.texi manual/dir-add.info: FORCE
272         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
273 FAQ: scripts/gen-FAQ.pl FAQ.in
274         $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
275 ifeq ($(with-cvs),yes)
276         test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated:  $(PERL) $^' $@
277 endif
278 FORCE:
279
280 rpm/%: subdir_distinfo
281         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
282
283 iconvdata/%:
284         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
285
286 # This is a special goal for people making binary distributions.  Normally
287 # everybody uses the DES based crypt library but for the distribution we
288 # need the only-MD5 based one as well.
289 md5-crypt/libmd5crypt:
290         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
291
292 # glibc 2.0 contains some header files which aren't used with glibc 2.1
293 # anymore.
294 # These rules should remove those headers
295 ifeq (,$(install_root))
296 ifeq ($(old-glibc-headers),yes)
297 install: remove-old-headers
298 endif
299 endif
300
301 headers2_0 :=   __math.h bytesex.h confname.h direntry.h elfclass.h     \
302                 errnos.h fcntlbits.h huge_val.h ioctl-types.h           \
303                 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h      \
304                 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h           \
305                 posix2_lim.h posix_opt.h resourcebits.h schedbits.h     \
306                 selectbits.h semaphorebits.h sigaction.h sigcontext.h   \
307                 signum.h sigset.h sockaddrcom.h socketbits.h stab.def   \
308                 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h          \
309                 syscall-list.h termbits.h timebits.h ustatbits.h        \
310                 utmpbits.h utsnamelen.h waitflags.h waitstatus.h        \
311                 xopen_lim.h gnu/types.h sys/ipc_buf.h                   \
312                 sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h        \
313                 sys/shm_buf.h sys/socketcall.h
314
315 .PHONY: remove-old-headers
316 remove-old-headers:
317         rm -f $(addprefix $(inst_includedir)/, $(headers2_0))
318
319 # Generate version maps.
320 ifeq ($(versioning),yes)
321 ifndef avoid-generated
322 $(common-objpfx)sysd-versions: Versions.def
323         (echo define vers-libs; \
324         sed -n 's/\(lib[a-zA-Z0-9_][a-zA-Z0-9_]*\) {/$$(common-objpfx)\1%map/p' $<; \
325         echo endef) > $@T
326         mv -f $@T $@
327 -include $(common-objpfx)sysd-versions
328 vers-libs := $(subst $(\n), ,$(vers-libs))
329
330 $(vers-libs): versions.awk \
331                $(wildcard $(subdirs:%=%/Versions)) \
332                $(wildcard $(+sysdep_dirs:%=%/Versions))
333         $(AWK) -v 'buildroot=$(common-objpfx)' -f $^
334
335 lib-mapfiles: $(common-objpfx)sysd-versions $(subst %,.,$(vers-libs))
336 else
337 lib-mapfiles:
338 endif
339 endif