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