configure tweaks, support $libc_add_on_config_subdirs
[platform/upstream/glibc.git] / Makefile
1 # Copyright (C) 1991-2002,2003,2004,2005,2006,2008,2009
2 #       Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 # 02111-1307 USA.
19
20 #
21 #       Master Makefile for the GNU C library
22 #
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
26
27 include Makeconfig
28
29
30 # This is the default target; it makes everything except the tests.
31 .PHONY: all
32 all: lib others
33 \f
34 ifneq ($(AUTOCONF),no)
35
36 ifeq ($(with-cvs),yes)
37 define autoconf-it-cvs
38 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
39 endef
40 else
41 autoconf-it-cvs =
42 endif
43
44 define autoconf-it
45 @-rm -f $@.new
46 $(AUTOCONF) $(ACFLAGS) $< > $@.new
47 chmod a-w$(patsubst %,$(comma)a+x,$(filter .,$(@D))) $@.new
48 mv -f $@.new $@
49 $(autoconf-it-cvs)
50 endef
51
52 configure: configure.in aclocal.m4; $(autoconf-it)
53 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
54 %/preconfigure: %/preconfigure.in aclocal.m4; $(autoconf-it)
55
56 endif # $(AUTOCONF) = no
57
58
59 # We don't want to run anything here in parallel.
60 .NOTPARALLEL:
61
62 # These are the targets that are made by making them in each subdirectory.
63 +subdir_targets := subdir_lib objects objs others subdir_mostlyclean    \
64                    subdir_clean subdir_distclean subdir_realclean       \
65                    tests xtests subdir_lint.out                         \
66                    subdir_update-abi subdir_check-abi                   \
67                    subdir_echo-headers                                  \
68                    subdir_install                                       \
69                    subdir_objs subdir_stubs subdir_testclean            \
70                    $(addprefix install-, no-libc.a bin lib data headers others)
71 \f
72 headers := limits.h values.h features.h gnu-versions.h bits/libc-lock.h \
73            bits/xopen_lim.h gnu/libc-version.h
74
75 echo-headers: subdir_echo-headers
76
77 # The headers are in the include directory.
78 subdir-dirs = include
79 vpath %.h $(subdir-dirs)
80
81 # What to install.
82 install-others = $(inst_includedir)/gnu/stubs.h
83 install-bin-script =
84
85 ifeq (yes,$(build-shared))
86 headers += gnu/lib-names.h
87 endif
88
89 include Makerules
90
91 ifeq ($(build-programs),yes)
92 others: $(addprefix $(objpfx),$(install-bin-script))
93 endif
94
95 # Install from subdirectories too.
96 install: subdir_install
97
98 # Explicit dependency so that `make install-headers' works
99 install-headers: install-headers-nosubdir
100
101 # Make sure that the dynamic linker is installed before libc.
102 $(inst_slibdir)/libc-$(version).so: elf/ldso_install
103
104 .PHONY: elf/ldso_install
105 elf/ldso_install:
106         $(MAKE) -C $(@D) $(@F)
107
108 # Create links for shared libraries using the `ldconfig' program if possible.
109 # Ignore the error if we cannot update /etc/ld.so.cache.
110 ifeq (no,$(cross-compiling))
111 ifeq (yes,$(build-shared))
112 install: install-symbolic-link
113 .PHONY: install-symbolic-link
114 install-symbolic-link: subdir_install
115         $(symbolic-link-prog) $(symbolic-link-list)
116         rm -f $(symbolic-link-list)
117
118 install:
119         -test ! -x $(common-objpfx)elf/ldconfig || LC_ALL=C LANGUAGE=C \
120           $(common-objpfx)elf/ldconfig $(addprefix -r ,$(install_root)) \
121                                        $(slibdir) $(libdir)
122 ifneq (no,$(PERL))
123 ifeq (/usr,$(prefix))
124 ifeq (,$(install_root))
125         CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
126 endif
127 endif
128 endif
129 endif
130 endif
131
132 # Build subdirectory lib objects.
133 lib-noranlib: subdir_lib
134
135 ifeq (yes,$(build-shared))
136 # Build the shared object from the PIC object library.
137 lib: $(common-objpfx)libc.so
138 endif
139
140
141 # This is a handy script for running any dynamically linked program against
142 # the current libc build for testing.
143 $(common-objpfx)testrun.sh: $(common-objpfx)config.make \
144                             $(..)Makeconfig $(..)Makefile
145         (echo '#!/bin/sh'; \
146          echo "GCONV_PATH='$(common-objpfx)iconvdata' \\"; \
147          echo 'exec $(run-program-prefix) $${1+"$$@"}'; \
148         ) > $@T
149         chmod a+x $@T
150         mv -f $@T $@
151 postclean-generated += testrun.sh
152
153 others: $(common-objpfx)testrun.sh
154 \f
155 # Makerules creates a file `stubs' in each subdirectory, which
156 # contains `#define __stub_FUNCTION' for each function defined in that
157 # directory which is a stub.
158 # Here we paste all of these together into <gnu/stubs.h>.
159
160 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
161
162 ifeq ($(biarch),no)
163 installed-stubs = $(inst_includedir)/gnu/stubs.h
164 else
165 installed-stubs = $(inst_includedir)/gnu/stubs-$(biarch).h
166
167 $(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
168         $(make-target-directory)
169         $(INSTALL_DATA) $< $@
170
171 install-others-nosubdir: $(installed-stubs)
172 endif
173
174
175 # Since stubs.h is never needed when building the library, we simplify the
176 # hairy installation process by producing it in place only as the last part
177 # of the top-level `make install'.  It depends on subdir_install, which
178 # iterates over all the subdirs; subdir_install in each subdir depends on
179 # the subdir's stubs file.  Having more direct dependencies would result in
180 # extra iterations over the list for subdirs and many recursive makes.
181 $(installed-stubs): include/stubs-prologue.h subdir_install
182         $(make-target-directory)
183         @rm -f $(objpfx)stubs.h
184         (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
185         if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
186         then echo 'stubs.h unchanged'; \
187         else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
188         rm -f $(objpfx)stubs.h
189 \f
190 # This makes the Info or DVI file of the documentation from the Texinfo source.
191 .PHONY: info dvi pdf html
192 info dvi pdf html:
193         $(MAKE) $(PARALLELMFLAGS) -C manual $@
194 \f
195 # This makes all the subdirectory targets.
196
197 # For each target, make it depend on DIR/target for each subdirectory DIR.
198 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
199
200 # Compute a list of all those targets.
201 all-subdirs-targets := $(foreach dir,$(subdirs),\
202                                  $(addprefix $(dir)/,$(+subdir_targets)))
203
204 # The action for each of those is to cd into the directory and make the
205 # target there.
206 $(all-subdirs-targets):
207         $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F)
208
209 define subdir-target-args
210 subdir=$(@D)$(if $($(@D)-srcdir),\
211 -C $($(@D)-srcdir) ..=`pwd`/,\
212 -C $(@D) ..=../)
213 endef
214
215 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
216 \f
217 # Targets to clean things up to various degrees.
218
219 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
220         tests-clean
221
222 # Subroutines of all cleaning targets.
223 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
224         -rm -f $(foreach o,$(object-suffixes-for-libc),\
225                    $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
226                $(addprefix $(objpfx),$(install-lib))
227 parent-clean: parent-mostlyclean common-clean
228
229 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
230             $(addprefix $(objpfx),sysd-dirs sysd-rules) \
231             $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
232
233 clean: parent-clean
234 # This is done this way rather than having `subdir_clean' be a
235 # dependency of this target so that libc.a will be removed before the
236 # subdirectories are dealt with and so they won't try to remove object
237 # files from it when it's going to be removed anyway.
238         @$(MAKE) subdir_clean no_deps=t
239         -rm -f $(postclean)
240 mostlyclean: parent-mostlyclean
241         @$(MAKE) subdir_mostlyclean no_deps=t
242         -rm -f $(postclean)
243
244 tests-clean:
245         @$(MAKE) subdir_testclean no_deps=t
246
247 tests: $(objpfx)c++-types-check.out $(objpfx)check-local-headers.out
248 ifneq ($(CXX),no)
249 check-data := $(firstword $(wildcard \
250                 $(foreach D,$(add-ons) scripts,\
251                           $(patsubst %,$D/data/c++-types-%.data,\
252                                      $(abi-name) \
253                                      $(addsuffix -$(config-os),\
254                                                  $(config-machine) \
255                                                  $(base-machine))))))
256 ifneq (,$(check-data))
257 $(objpfx)c++-types-check.out: $(check-data) scripts/check-c++-types.sh
258         scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu99 -Wstrict-prototypes,$(CFLAGS)) $(CPPFLAGS) > $@
259 else
260 $(objpfx)c++-types-check.out:
261         @echo 'WARNING C++ tests not run; create a c++-types-XXX file'
262         @echo "not run" > $@
263 endif
264 endif
265
266 $(objpfx)check-local-headers.out: scripts/check-local-headers.sh
267         scripts/check-local-headers.sh "$(includedir)" "$(objpfx)" > $@
268
269 ifneq ($(PERL),no)
270 installed-headers = argp/argp.h assert/assert.h catgets/nl_types.h \
271                     crypt/crypt.h ctype/ctype.h debug/execinfo.h \
272                     dirent/dirent.h dlfcn/dlfcn.h elf/elf.h elf/link.h \
273                     gmon/sys/gmon.h gmon/sys/gmon_out.h gmon/sys/profil.h \
274                     grp/grp.h gshadow/gshadow.h iconv/iconv.h iconv/gconv.h \
275                     $(wildcard inet/netinet/*.h) \
276                     $(wildcard inet/arpa/*.h inet/protocols/*.h) \
277                     inet/aliases.h inet/ifaddrs.h inet/netinet/ip6.h \
278                     inet/netinet/icmp6.h intl/libintl.h io/sys/stat.h \
279                     io/sys/statfs.h io/sys/vfs.h io/sys/statvfs.h \
280                     io/fcntl.h io/sys/fcntl.h io/poll.h io/sys/poll.h \
281                     io/utime.h io/ftw.h io/fts.h io/sys/sendfile.h \
282                     libio/stdio.h libio/libio.h locale/locale.h \
283                     locale/langinfo.h locale/xlocale.h login/utmp.h \
284                     login/lastlog.h login/pty.h malloc/malloc.h \
285                     malloc/obstack.h malloc/mcheck.h math/math.h \
286                     math/complex.h math/fenv.h math/tgmath.h misc/sys/uio.h \
287                     $(wildcard nis/rpcsvc/*.h) nptl_db/thread_db.h \
288                     nptl/sysdeps/pthread/pthread.h nptl/semaphore.h \
289                     nss/nss.h posix/sys/utsname.h posix/sys/times.h \
290                     posix/sys/wait.h posix/sys/types.h posix/unistd.h \
291                     posix/glob.h posix/regex.h posix/wordexp.h posix/fnmatch.h\
292                     posix/getopt.h posix/tar.h posix/sys/unistd.h \
293                     posix/sched.h posix/re_comp.h posix/wait.h \
294                     posix/cpio.h posix/spawn.h pwd/pwd.h resolv/resolv.h \
295                     resolv/netdb.h $(wildcard resolv/arpa/*.h) \
296                     resource/sys/resource.h resource/sys/vlimit.h \
297                     resource/sys/vtimes.h resource/ulimit.h rt/aio.h \
298                     rt/mqueue.h setjmp/setjmp.h shadow/shadow.h \
299                     signal/signal.h signal/sys/signal.h socket/sys/socket.h \
300                     socket/sys/un.h stdio-common/printf.h \
301                     stdio-common/stdio_ext.h stdlib/stdlib.h stdlib/alloca.h \
302                     stdlib/monetary.h stdlib/fmtmsg.h stdlib/ucontext.h \
303                     sysdeps/generic/inttypes.h sysdeps/generic/stdint.h \
304                     stdlib/errno.h stdlib/sys/errno.h string/string.h \
305                     string/strings.h string/memory.h string/endian.h \
306                     string/argz.h string/envz.h string/byteswap.h \
307                     $(wildcard sunrpc/rpc/*.h sunrpc/rpcsvc/*.h) \
308                     sysvipc/sys/ipc.h sysvipc/sys/msg.h sysvipc/sys/sem.h \
309                     sysvipc/sys/shm.h termios/termios.h \
310                     termios/sys/termios.h termios/sys/ttychars.h time/time.h \
311                     time/sys/time.h time/sys/timeb.h wcsmbs/wchar.h \
312                     wctype/wctype.h
313
314 tests: $(objpfx)begin-end-check.out
315 $(objpfx)begin-end-check.out: scripts/begin-end-check.pl
316         $(PERL) scripts/begin-end-check.pl $(installed-headers) > $@
317 endif
318
319 # The realclean target is just like distclean for the parent, but we want
320 # the subdirs to know the difference in case they care.
321 realclean distclean: parent-clean
322 # This is done this way rather than having `subdir_distclean' be a
323 # dependency of this target so that libc.a will be removed before the
324 # subdirectories are dealt with and so they won't try to remove object
325 # files from it when it's going to be removed anyway.
326         @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
327                  sysdep-subdirs="$(sysdep-subdirs)"
328         -rm -f $(postclean)
329
330 # Subroutine of distclean and realclean.
331 distclean-1: subdir_$(distclean-1)
332         -rm -f $(config-generated)
333         -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
334         -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
335 ifdef objdir
336         -rm -f $(objpfx)Makefile
337 endif
338         -rm -f $(sysdep-$(distclean-1))
339 \f
340 # Make the TAGS file for Emacs users.
341
342 .PHONY: TAGS
343 TAGS:
344         scripts/list-sources.sh | sed -n -e '/Makefile/p' \
345           $(foreach S,[chsSyl] cxx sh bash pl,\
346                     $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \
347         | $(ETAGS) -o $@ -
348 \f
349 # Make the distribution tarfile.
350 .PHONY: dist tag-for-dist
351
352 generated := $(generated) stubs.h
353
354 files-for-dist := README FAQ INSTALL NOTES configure
355
356 tag-of-stem = glibc-$(subst .,_,$*)
357 dist-selector = -r $(tag-of-stem)
358
359 # Add-ons in the main repository but distributed in their own tar files.
360 dist-separate = libidn
361
362 glibc-%.tar $(dist-separate:%=glibc-%-%.tar): $(files-for-dist) \
363                                               $(foreach D,$(dist-separate),\
364                                                         $D/configure)
365         @rm -fr glibc-$*
366         $(MAKE) -q `find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
367                          -name configure`
368         cvs $(CVSOPTS) -Q export -d glibc-$* $(dist-selector) libc
369 # Touch all the configure scripts going into the tarball since cvs export
370 # might have delivered configure.in newer than configure.
371         find glibc-$* -name configure -print | xargs touch
372         $(dist-do-separate-dirs)
373         tar cf glibc-$*.tar glibc-$*
374         rm -fr glibc-$*
375 define dist-do-separate-dirs
376 $(foreach dir,$(dist-separate),
377         @rm -fr glibc-$(dir)-$*
378         mv glibc-$*/$(dir) glibc-$(dir)-$*
379         tar cf glibc-$(dir)-$*.tar glibc-$(dir)-$*
380         rm -fr glibc-$(dir)-$*
381 )
382 endef
383
384 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
385 dist-version = $(version)
386
387 dist: $(foreach Z,.bz2 .gz,glibc-$(dist-version).tar$Z \
388                            $(foreach D,$(dist-separate),\
389                                      glibc-$D-$(dist-version).tar$Z))
390         md5sum $^
391
392 tag-for-dist: tag-$(dist-version)
393 tag-%: $(files-for-dist)
394         cvs $(CVSOPTS) -Q tag -c $(tag-of-stem)
395
396 define format-me
397 @rm -f $@
398 makeinfo --no-validate --plaintext --no-number-sections $< -o $@
399 -chmod a-w $@
400 endef
401 INSTALL: manual/install.texi; $(format-me)
402 NOTES: manual/creature.texi; $(format-me)
403 manual/dir-add.texi manual/dir-add.info: FORCE
404         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
405 FAQ: scripts/gen-FAQ.pl FAQ.in
406         $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
407 ifeq ($(with-cvs),yes)
408         test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated:  $(PERL) $^' $@
409 endif
410 FORCE:
411
412 iconvdata/% localedata/% po/% manual/%: FORCE
413         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
414
415 # glibc 2.0 contains some header files which aren't used with glibc 2.1
416 # anymore.
417 # These rules should remove those headers
418 ifeq (,$(install_root))
419 ifeq ($(old-glibc-headers),yes)
420 install: remove-old-headers
421 endif
422 endif
423
424 headers2_0 :=   __math.h bytesex.h confname.h direntry.h elfclass.h     \
425                 errnos.h fcntlbits.h huge_val.h ioctl-types.h           \
426                 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h      \
427                 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h           \
428                 posix2_lim.h posix_opt.h resourcebits.h schedbits.h     \
429                 selectbits.h semaphorebits.h sigaction.h sigcontext.h   \
430                 signum.h sigset.h sockaddrcom.h socketbits.h stab.def   \
431                 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h          \
432                 syscall-list.h termbits.h timebits.h ustatbits.h        \
433                 utmpbits.h utsnamelen.h waitflags.h waitstatus.h        \
434                 xopen_lim.h gnu/types.h sys/ipc_buf.h                   \
435                 sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h        \
436                 sys/shm_buf.h sys/socketcall.h sigstack.h
437
438 .PHONY: remove-old-headers
439 remove-old-headers:
440         rm -f $(addprefix $(inst_includedir)/, $(headers2_0))