Upload Tizen:Base source
[external/eglibc.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 bits/predefs.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-bin-script =
83
84 # If we're bootstrapping, install a dummy gnu/stubs.h along with the
85 # other headers, so 'make install-headers' produces a useable include
86 # tree.  Otherwise, install gnu/stubs.h later, after the rest of the
87 # build is done.
88 ifeq ($(install-bootstrap-headers),yes)
89 install-headers: $(inst_includedir)/gnu/stubs.h
90 else
91 install-others = $(inst_includedir)/gnu/stubs.h
92 endif
93
94 ifeq (yes,$(build-shared))
95 headers += gnu/lib-names.h
96 endif
97
98 include Makerules
99
100 ifeq ($(build-programs),yes)
101 others: $(addprefix $(objpfx),$(install-bin-script))
102 endif
103
104 # Install from subdirectories too.
105 install: subdir_install
106
107 # Explicit dependency so that `make install-headers' works
108 install-headers: install-headers-nosubdir
109
110 # Make sure that the dynamic linker is installed before libc.
111 $(inst_slibdir)/libc-$(version).so: elf/ldso_install
112
113 .PHONY: elf/ldso_install
114 elf/ldso_install:
115         $(MAKE) -C $(@D) $(@F)
116
117 # Create links for shared libraries using the `ldconfig' program if possible.
118 # Ignore the error if we cannot update /etc/ld.so.cache.
119 ifeq (no,$(cross-compiling))
120 ifeq (yes,$(build-shared))
121 install: install-symbolic-link
122 .PHONY: install-symbolic-link
123 install-symbolic-link: subdir_install
124         $(symbolic-link-prog) $(symbolic-link-list)
125         rm -f $(symbolic-link-list)
126
127 install:
128         -test ! -x $(common-objpfx)elf/ldconfig || LC_ALL=C LANGUAGE=C \
129           $(common-objpfx)elf/ldconfig $(addprefix -r ,$(install_root)) \
130                                        $(slibdir) $(libdir)
131 ifneq (no,$(PERL))
132 ifeq (/usr,$(prefix))
133 ifeq (,$(install_root))
134         CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)
135 endif
136 endif
137 endif
138 endif
139 endif
140
141 # Build subdirectory lib objects.
142 lib-noranlib: subdir_lib
143
144 ifeq (yes,$(build-shared))
145 # Build the shared object from the PIC object library.
146 lib: $(common-objpfx)libc.so
147 endif
148
149
150 # This is a handy script for running any dynamically linked program against
151 # the current libc build for testing.
152 $(common-objpfx)testrun.sh: $(common-objpfx)config.make \
153                             $(..)Makeconfig $(..)Makefile
154         (echo '#!/bin/sh'; \
155          echo "GCONV_PATH='$(common-objpfx)iconvdata' \\"; \
156          echo 'exec $(run-program-prefix) $${1+"$$@"}'; \
157         ) > $@T
158         chmod a+x $@T
159         mv -f $@T $@
160 postclean-generated += testrun.sh
161
162 others: $(common-objpfx)testrun.sh
163 \f
164 # Makerules creates a file `stubs' in each subdirectory, which
165 # contains `#define __stub_FUNCTION' for each function defined in that
166 # directory which is a stub.
167 # Here we paste all of these together into <gnu/stubs.h>.
168
169 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
170
171 # gnu/stubs.h depends (via the subdir 'stubs' targets) on all the .o
172 # files in EGLIBC.  For bootstrapping a GCC/EGLIBC pair, an empty
173 # gnu/stubs.h is good enough.
174 ifeq ($(install-bootstrap-headers),yes)
175 $(inst_includedir)/gnu/stubs.h: include/stubs-bootstrap.h $(+force)
176         $(make-target-directory)
177         $(INSTALL_DATA) $< $@
178
179 installed-stubs = 
180 else 
181 ifeq ($(biarch),no)
182 installed-stubs = $(inst_includedir)/gnu/stubs.h
183 else
184 installed-stubs = $(inst_includedir)/gnu/stubs-$(biarch).h
185
186 $(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
187         $(make-target-directory)
188         $(INSTALL_DATA) $< $@
189
190 install-others-nosubdir: $(installed-stubs)
191 endif
192 endif
193
194
195 # Since stubs.h is never needed when building the library, we simplify the
196 # hairy installation process by producing it in place only as the last part
197 # of the top-level `make install'.  It depends on subdir_install, which
198 # iterates over all the subdirs; subdir_install in each subdir depends on
199 # the subdir's stubs file.  Having more direct dependencies would result in
200 # extra iterations over the list for subdirs and many recursive makes.
201 $(installed-stubs): include/stubs-prologue.h subdir_install
202         $(make-target-directory)
203         @rm -f $(objpfx)stubs.h
204         (sed '/^@/d' $<; LC_ALL=C sort $(subdir-stubs)) > $(objpfx)stubs.h
205         if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
206         then echo 'stubs.h unchanged'; \
207         else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
208         rm -f $(objpfx)stubs.h
209 \f
210 # This makes the Info or DVI file of the documentation from the Texinfo source.
211 .PHONY: info dvi pdf html
212 info dvi pdf html:
213         $(MAKE) $(PARALLELMFLAGS) -C manual $@
214 \f
215 # This makes all the subdirectory targets.
216
217 # For each target, make it depend on DIR/target for each subdirectory DIR.
218 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
219
220 # Compute a list of all those targets.
221 all-subdirs-targets := $(foreach dir,$(subdirs),\
222                                  $(addprefix $(dir)/,$(+subdir_targets)))
223
224 # The action for each of those is to cd into the directory and make the
225 # target there.
226 $(all-subdirs-targets):
227         $(MAKE) $(PARALLELMFLAGS) $(subdir-target-args) $(@F)
228
229 define subdir-target-args
230 subdir=$(@D)$(if $($(@D)-srcdir),\
231 -C $($(@D)-srcdir) ..=`pwd`/,\
232 -C $(@D) ..=../)
233 endef
234
235 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
236 \f
237 # Targets to clean things up to various degrees.
238
239 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean \
240         tests-clean
241
242 # Subroutines of all cleaning targets.
243 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
244         -rm -f $(foreach o,$(object-suffixes-for-libc),\
245                    $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
246                $(addprefix $(objpfx),$(install-lib))
247 parent-clean: parent-mostlyclean common-clean
248
249 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
250             $(addprefix $(objpfx),sysd-dirs sysd-rules) \
251             $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
252
253 clean: parent-clean
254 # This is done this way rather than having `subdir_clean' be a
255 # dependency of this target so that libc.a will be removed before the
256 # subdirectories are dealt with and so they won't try to remove object
257 # files from it when it's going to be removed anyway.
258         @$(MAKE) subdir_clean no_deps=t
259         -rm -f $(postclean)
260 mostlyclean: parent-mostlyclean
261         @$(MAKE) subdir_mostlyclean no_deps=t
262         -rm -f $(postclean)
263
264 tests-clean:
265         @$(MAKE) subdir_testclean no_deps=t
266
267 tests: $(objpfx)c++-types-check.out $(objpfx)check-local-headers.out
268 ifneq ($(CXX),no)
269 check-data := $(firstword $(wildcard \
270                 $(foreach D,$(add-ons) scripts,\
271                           $(patsubst %,$D/data/c++-types-%.data,\
272                                      $(abi-name) \
273                                      $(addsuffix -$(config-os),\
274                                                  $(config-machine) \
275                                                  $(base-machine))))))
276 ifneq (,$(check-data))
277 $(objpfx)c++-types-check.out: $(check-data) scripts/check-c++-types.sh
278         scripts/check-c++-types.sh $< $(CXX) $(filter-out -std=gnu99 -Wstrict-prototypes,$(CFLAGS)) $(CPPFLAGS) > $@
279 else
280 $(objpfx)c++-types-check.out:
281         @echo 'WARNING C++ tests not run; create a c++-types-XXX file'
282         @echo "not run" > $@
283 endif
284 endif
285
286 $(objpfx)check-local-headers.out: scripts/check-local-headers.sh
287         scripts/check-local-headers.sh "$(includedir)" "$(objpfx)" > $@
288
289 ifneq ($(PERL),no)
290 installed-headers = argp/argp.h assert/assert.h catgets/nl_types.h \
291                     crypt/crypt.h ctype/ctype.h debug/execinfo.h \
292                     dirent/dirent.h dlfcn/dlfcn.h elf/elf.h elf/link.h \
293                     gmon/sys/gmon.h gmon/sys/gmon_out.h gmon/sys/profil.h \
294                     grp/grp.h gshadow/gshadow.h iconv/iconv.h iconv/gconv.h \
295                     $(wildcard inet/netinet/*.h) \
296                     $(wildcard inet/arpa/*.h inet/protocols/*.h) \
297                     inet/aliases.h inet/ifaddrs.h inet/netinet/ip6.h \
298                     inet/netinet/icmp6.h intl/libintl.h io/sys/stat.h \
299                     io/sys/statfs.h io/sys/vfs.h io/sys/statvfs.h \
300                     io/fcntl.h io/sys/fcntl.h io/poll.h io/sys/poll.h \
301                     io/utime.h io/ftw.h io/fts.h io/sys/sendfile.h \
302                     libio/stdio.h libio/libio.h locale/locale.h \
303                     locale/langinfo.h locale/xlocale.h login/utmp.h \
304                     login/lastlog.h login/pty.h malloc/malloc.h \
305                     malloc/obstack.h malloc/mcheck.h math/math.h \
306                     math/complex.h math/fenv.h math/tgmath.h misc/sys/uio.h \
307                     $(wildcard nis/rpcsvc/*.h) nptl_db/thread_db.h \
308                     nptl/sysdeps/pthread/pthread.h nptl/semaphore.h \
309                     nss/nss.h posix/sys/utsname.h posix/sys/times.h \
310                     posix/sys/wait.h posix/sys/types.h posix/unistd.h \
311                     posix/glob.h posix/regex.h posix/wordexp.h posix/fnmatch.h\
312                     posix/getopt.h posix/tar.h posix/sys/unistd.h \
313                     posix/sched.h posix/re_comp.h posix/wait.h \
314                     posix/cpio.h posix/spawn.h pwd/pwd.h resolv/resolv.h \
315                     resolv/netdb.h $(wildcard resolv/arpa/*.h) \
316                     resource/sys/resource.h resource/sys/vlimit.h \
317                     resource/sys/vtimes.h resource/ulimit.h rt/aio.h \
318                     rt/mqueue.h setjmp/setjmp.h shadow/shadow.h \
319                     signal/signal.h signal/sys/signal.h socket/sys/socket.h \
320                     socket/sys/un.h stdio-common/printf.h \
321                     stdio-common/stdio_ext.h stdlib/stdlib.h stdlib/alloca.h \
322                     stdlib/monetary.h stdlib/fmtmsg.h stdlib/ucontext.h \
323                     sysdeps/generic/inttypes.h sysdeps/generic/stdint.h \
324                     stdlib/errno.h stdlib/sys/errno.h string/string.h \
325                     string/strings.h string/memory.h string/endian.h \
326                     string/argz.h string/envz.h string/byteswap.h \
327                     $(wildcard sunrpc/rpc/*.h sunrpc/rpcsvc/*.h) \
328                     sysvipc/sys/ipc.h sysvipc/sys/msg.h sysvipc/sys/sem.h \
329                     sysvipc/sys/shm.h termios/termios.h \
330                     termios/sys/termios.h termios/sys/ttychars.h time/time.h \
331                     time/sys/time.h time/sys/timeb.h wcsmbs/wchar.h \
332                     wctype/wctype.h
333
334 tests: $(objpfx)begin-end-check.out
335 $(objpfx)begin-end-check.out: scripts/begin-end-check.pl
336         $(PERL) scripts/begin-end-check.pl $(installed-headers) > $@
337 endif
338
339 # The realclean target is just like distclean for the parent, but we want
340 # the subdirs to know the difference in case they care.
341 realclean distclean: parent-clean
342 # This is done this way rather than having `subdir_distclean' be a
343 # dependency of this target so that libc.a will be removed before the
344 # subdirectories are dealt with and so they won't try to remove object
345 # files from it when it's going to be removed anyway.
346         @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes \
347                  sysdep-subdirs="$(sysdep-subdirs)"
348         -rm -f $(postclean)
349
350 # Subroutine of distclean and realclean.
351 distclean-1: subdir_$(distclean-1)
352         -rm -f $(config-generated)
353         -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
354         -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
355 ifdef objdir
356         -rm -f $(objpfx)Makefile
357 endif
358         -rm -f $(sysdep-$(distclean-1))
359 \f
360 # Make the TAGS file for Emacs users.
361
362 .PHONY: TAGS
363 TAGS:
364         scripts/list-sources.sh | sed -n -e '/Makefile/p' \
365           $(foreach S,[chsSyl] cxx sh bash pl,\
366                     $(subst .,\.,-e '/.$S\(.in\)*$$/p')) \
367         | $(ETAGS) -o $@ -
368 \f
369 # Make the distribution tarfile.
370 .PHONY: dist dist-prepare
371
372 generated := $(generated) stubs.h
373
374 files-for-dist := README FAQ INSTALL NOTES configure ChangeLog NEWS
375
376 # Regenerate stuff, then error if these things are not committed yet.
377 dist-prepare: $(files-for-dist)
378         conf=`find sysdeps $(addsuffix /sysdeps,$(sysdeps-add-ons)) \
379                    -name configure`; \
380         $(MAKE) $$conf && \
381         git diff --stat HEAD -- $^ $$conf \
382         | $(AWK) '{ print; rc=1 } END { exit rc }'
383
384 %.tar: FORCE
385         git archive --prefix=$*/ $* > $@.new
386         mv -f $@.new $@
387
388 # Do `make dist dist-version=X.Y.Z' to make tar files of an older version.
389
390 ifneq (,$(strip $(dist-version)))
391 dist: $(foreach Z,.bz2 .gz .xz,$(dist-version).tar$Z)
392         md5sum $^
393 else
394 dist: dist-prepare
395         @if v=`git describe`; then \
396           echo Distribution version $$v; \
397           $(MAKE) dist dist-version=$$v; \
398         else \
399           false; \
400         fi
401 endif
402
403 define format-me
404 @rm -f $@
405 makeinfo --no-validate --plaintext --no-number-sections $< -o $@
406 -chmod a-w $@
407 endef
408 INSTALL: manual/install.texi; $(format-me)
409 NOTES: manual/creature.texi; $(format-me)
410 manual/dir-add.texi manual/dir-add.info: FORCE
411         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
412 FAQ: scripts/gen-FAQ.pl FAQ.in
413         $(PERL) $^ > $@.new && rm -f $@ && mv $@.new $@ && chmod a-w $@
414 ifeq ($(with-cvs),yes)
415         test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated:  $(PERL) $^' $@
416 endif
417 FORCE:
418
419 iconvdata/% localedata/% po/% manual/%: FORCE
420         $(MAKE) $(PARALLELMFLAGS) -C $(@D) $(@F)
421
422 # glibc 2.0 contains some header files which aren't used with glibc 2.1
423 # anymore.
424 # These rules should remove those headers
425 ifeq (,$(install_root))
426 ifeq ($(old-glibc-headers),yes)
427 install: remove-old-headers
428 endif
429 endif
430
431 headers2_0 :=   __math.h bytesex.h confname.h direntry.h elfclass.h     \
432                 errnos.h fcntlbits.h huge_val.h ioctl-types.h           \
433                 ioctls.h iovec.h jmp_buf.h libc-lock.h local_lim.h      \
434                 mathcalls.h mpool.h nan.h ndbm.h posix1_lim.h           \
435                 posix2_lim.h posix_opt.h resourcebits.h schedbits.h     \
436                 selectbits.h semaphorebits.h sigaction.h sigcontext.h   \
437                 signum.h sigset.h sockaddrcom.h socketbits.h stab.def   \
438                 statbuf.h statfsbuf.h stdio-lock.h stdio_lim.h          \
439                 syscall-list.h termbits.h timebits.h ustatbits.h        \
440                 utmpbits.h utsnamelen.h waitflags.h waitstatus.h        \
441                 xopen_lim.h gnu/types.h sys/ipc_buf.h                   \
442                 sys/kernel_termios.h sys/msq_buf.h sys/sem_buf.h        \
443                 sys/shm_buf.h sys/socketcall.h sigstack.h
444
445 .PHONY: remove-old-headers
446 remove-old-headers:
447         rm -f $(addprefix $(inst_includedir)/, $(headers2_0))