fdwalk should return 0 on an empty directory
[kopensolaris-gnu/glibc.git] / Makerules
index 36e2441..ae9271b 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+# Copyright (C) 1991-2006, 2007 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -56,22 +56,6 @@ ifndef +included-Makeconfig
 include $(..)Makeconfig
 endif
 
-# `configure' writes a definition of `config-sysdirs' in `config.make'.
-sysdirs = $(strip $(full_config_sysdirs))
-
-+sysdir_pfx = $(common-objpfx)
-
-export sysdirs := $(sysdirs)
-
-+sysdep_dirs := $(full_config_sysdirs)
-ifdef objdir
-+sysdep_dirs := $(objdir) $(+sysdep_dirs)
-endif
-
-# Add -I switches to get the right sysdep directories.
-# `+includes' in Makeconfig references $(+sysdep-includes).
-+sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
-
 # This variable is used in ``include $(o-iterator)'' after defining
 # $(o-iterator-doit) to produce some desired rule using $o for the object
 # suffix, and setting $(object-suffixes-left) to $(object-suffixes); a copy
@@ -94,7 +78,7 @@ vpath %.x $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
 # being included individually by a subdir makefile (hurd/Makefile needs this).
 in-Makerules := yes
 
-sysdep-makefiles := $(wildcard $(full_config_sysdirs:=/Makefile))
+sysdep-makefiles := $(wildcard $(sysdirs:=/Makefile))
 ifneq (,$(sysdep-makefiles))
 include $(sysdep-makefiles)
 endif
@@ -165,7 +149,7 @@ ifndef subdir
 $(common-objpfx)%.make: $(..)%.make.c $(..)Makerules $(common-before-compile)
        rm -f $@T $@.dT
        (echo '# Generated from $*.make.c by Makerules.'; \
-        $(CC) $(CFLAGS) $(CPPFLAGS) -E $< \
+        $(CC) $(CFLAGS) $(CPPFLAGS) -E -DASSEMBLER $< \
               -MD -MP -MT '$$(common-objpfx)$*.make' -MF $@.dT \
         | sed -n '/@@@/{s/@@@[  ]*\(.*\)@@@/\1/;s/[     ]*$$//p;}'; \
         echo 'common-generated += $(@F)'; \
@@ -229,20 +213,22 @@ endef
 close-check-inhibit-asm = ;; esac ;
 endif
 
--include $(+sysdir_pfx)sysd-rules
+-include $(common-objpfx)sysd-rules
 ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))
 # The value of $(+sysdep_dirs) the sysd-rules was computed for
 # differs from the one we are using now.  So force a rebuild of sysd-rules.
 sysd-rules-force = FORCE
 FORCE:
 endif
-$(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
-                         $(wildcard $(foreach dir,$(sysdirs),\
-                                              $(dir)/Makefile))\
-                         $(sysd-rules-force)
+$(common-objpfx)sysd-rules: $(common-objpfx)config.make $(..)Makerules \
+                           $(sysdep-makefiles) $(sysd-rules-force)
        -@rm -f $@T
        (echo 'sysd-rules-sysdirs := $(config-sysdirs)';                      \
-        for dir in $(config-sysdirs:%='$$(..)%'); do                         \
+        for dir in $(config-sysdirs); do                                     \
+          case "$$dir" in                                                    \
+          /*) ;;                                                             \
+          *) dir="\$$(..)$$dir" ;;                                           \
+          esac;                                                              \
           for o in $(all-object-suffixes); do \
             $(open-check-inhibit-asm) \
             echo "\$$(objpfx)%$$o: $$dir/%.S \$$(before-compile); \
@@ -254,8 +240,12 @@ $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
             echo "\$$(objpfx)rtld-%$$o: $$dir/%.s \$$(before-compile); \
                  \$$(compile-command.s)";                                    \
             echo "\$$(objpfx)ptw-%$$o: $$dir/%.S \$$(before-compile); \
-                 \$$(compile-command.S)";                                    \
+                 \$$(compile-command.S) -DPTW";                              \
             echo "\$$(objpfx)ptw-%$$o: $$dir/%.s \$$(before-compile); \
+                 \$$(compile-command.s) -DPTW";                              \
+            echo "\$$(objpfx)m_%$$o: $$dir/s_%.S \$$(before-compile); \
+                 \$$(compile-command.S)";                                    \
+            echo "\$$(objpfx)m_%$$o: $$dir/s_%.s \$$(before-compile); \
                  \$$(compile-command.s)";                                    \
             $(close-check-inhibit-asm) \
             echo "\$$(objpfx)%$$o: $$dir/%.c \$$(before-compile); \
@@ -263,12 +253,13 @@ $(+sysdir_pfx)sysd-rules: $(+sysdir_pfx)config.make $(..)Makerules \
             echo "\$$(objpfx)rtld-%$$o: $$dir/%.c \$$(before-compile); \
                  \$$(compile-command.c)";                                    \
             echo "\$$(objpfx)ptw-%$$o: $$dir/%.c \$$(before-compile); \
+                 \$$(compile-command.c) -DPTW";                              \
+            echo "\$$(objpfx)m_%$$o: $$dir/s_%.c \$$(before-compile); \
                  \$$(compile-command.c)";                                    \
           done; \
-          echo "\$$(objpfx)m_%.S: $$dir/s_%.S; \$$(+make-include-of-dep)";   \
-          echo "\$$(objpfx)m_%.c: $$dir/s_%.c; \$$(+make-include-of-dep)";   \
+          echo "\$$(inst_includedir)/%.h: $$dir/%.h \$$(+force); \
+                       \$$(do-install)";                                     \
         done;                                                                \
-        echo "\$$(objpfx)m_%.c: s_%.c; \$$(+make-include-of-dep)";   \
         echo 'sysd-rules-done = t') > $@T
        mv -f $@T $@
 
@@ -277,17 +268,6 @@ ifndef sysd-rules-done
 no_deps=t
 endif
 
-# This is used by the m_%.[Sc] pattern rules in sysd-rules.
-define +make-include-of-dep
-echo '#include <$<>' > $@T
-mv -f $@T $@
-endef
-
-# It matters that this set of rules, for compiling from sources in
-# the current directory (the $srcdir/$subdir) come before the
-# generated sysdep rules in included from sysd-rules below.  When
-# compiling in the source tree, generated sources go into the current
-# directory, and those should be chosen before any sources in sysdeps.
 define o-iterator-doit
 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
 endef
@@ -346,7 +326,7 @@ postclean-generated += sysd-versions Versions.all abi-versions.h \
                       Versions.def.v.i Versions.def.v Versions.v.i Versions.v
 
 ifndef avoid-generated
-ifneq ($(sysd-versions-subdirs),$(all-subdirs) $(config-sysdirs))
+ifneq ($(sysd-versions-subdirs),$(sorted-subdirs) $(config-sysdirs))
 sysd-versions-force = FORCE
 FORCE:
 endif
@@ -364,14 +344,14 @@ $(common-objpfx)Versions.all: $(..)scripts/firstversions.awk \
        } | LC_ALL=C $(AWK) -f $< > $@T
        mv -f $@T $@
 # See %.v/%.v.i implicit rules in Makeconfig.
-$(common-objpfx)Versions.v.i: $(wildcard $(all-subdirs:%=$(..)%/Versions)) \
+$(common-objpfx)Versions.v.i: $(wildcard $(subdirs:%=$(..)%/Versions)) \
                              $(wildcard $(sysdirs:%=%/Versions)) \
                              $(common-objpfx)abi-versions.h \
                              $(sysd-versions-force)
 $(common-objpfx)sysd-versions: $(common-objpfx)Versions.all \
                               $(common-objpfx)Versions.v \
                               $(..)scripts/versions.awk
-       ( echo 'sysd-versions-subdirs = $(all-subdirs) $(config-sysdirs)' ; \
+       ( echo 'sysd-versions-subdirs = $(subdirs) $(config-sysdirs)' ; \
          cat $(word 2,$^) \
          | LC_ALL=C $(AWK) -v buildroot=$(common-objpfx) -v defsfile=$< \
                            -v move_if_change='$(move-if-change)' \
@@ -507,7 +487,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
                  -Wl,--verbose 2>&1 | \
          sed > $@T \
              -e '/^=========/,/^=========/!d;/^=========/d' \
-             -e 's/^.*\.hash[  ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+             $(if $(filter yes,$(have-hash-style)), \
+                  -e 's/^.*\.gnu\.hash[        ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+                  -e '/^[      ]*\.hash[       ]*:.*$$/{h;d;}' \
+                  -e '/DATA_SEGMENT_ALIGN/{H;g}' \
+               , \
+                  -e 's/^.*\.hash[     ]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
+              ) \
              -e 's/^.*\*(\.dynbss).*$$/& \
                 PROVIDE(__start___libc_freeres_ptrs = .); \
                 *(__libc_freeres_ptrs) \
@@ -572,6 +558,11 @@ define build-module
 $(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
          $(csu-objpfx)abi-note.o $(build-module-objlist)
 endef
+define build-module-asneeded
+$(build-module-helper) -o $@ -T $(common-objpfx)shlib.lds \
+         $(csu-objpfx)abi-note.o \
+         -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
+endef
 else
 ifneq (,$(findstring aix,$(config-os)))
 define build-module
@@ -703,6 +694,7 @@ endif
 \f
 +depfiles := $(sources:.c=.d) \
             $(patsubst %.o,%.d,$(filter %.o,$(extra-objs:.os=.o))) \
+            $(patsubst %.o,%.d,$(filter %.o,$(extra-test-objs:.os=.o))) \
             $(addsuffix .d,$(tests) $(xtests) $(test-srcs))
 ifeq ($(build-programs),yes)
 +depfiles += $(addsuffix .d,$(others) $(sysdep-others))
@@ -740,7 +732,9 @@ MAKEFLAGS := $(MAKEFLAGS)r
 # Generic rule for making directories.
 %/:
 # mkdir isn't smart enough to strip a trailing /.
-       mkdir $(@:%/=%)
+# We always require a mkdir which supports the -p option to avoid error
+# messages in case of races.
+       mkdir -p $(@:%/=%)
 \f
 # Make sure that object files are not removed
 # when they are intermediates between sources and library members.
@@ -842,12 +836,13 @@ force-install:
 
 # $(install-lib) are installed from the object directory into $(libdir);
 # files in $(install-lib) matching `lib%.a' are ranlib'd after installation
-# unless they also appear in $(non-lib.a).  $(install-data) are installed
-# as they are into $(datadir).  $(headers) are installed as they are in
+# unless they also appear in $(non-lib.a).  $(install-data) are installed as
+# they are into $(datadir).  $(headers) are installed as they are in
 # $(includedir).  $(install-bin), $(install-bin-script) and $(install-sbin)
 # are installed from the object directory into $(bindir), $(bindir) and
-# $(sbindir), respectively.  $(install-others) are absolute path names of
-# files to install; rules to install them are defined elsewhere.
+# $(sbindir), respectively.  $(install-others) and $(install-others-programs)
+# are absolute path names of files to install; rules to install them are
+# defined elsewhere.
 
 # The simple library name to install libc.a under.
 # This could be defined by a sysdep Makefile.
@@ -872,6 +867,13 @@ endef
 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
                             $(inst_libdir)/$(patsubst %,$(libtype$o),\
                                                     $(libprefix)$(libc-name)))
+
+install-lib-all: $(inst_slibdir)/libc.so$(libc.so-version) \
+               $(inst_slibdir)/libc-$(version).so \
+               $(inst_libdir)/libc.so \
+               $(inst_libdir)/libc.a \
+               install-lib
+
 install: $(installed-libcs)
 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
        $(make-target-directory)
@@ -1121,8 +1123,21 @@ $(addprefix $(inst_datadir)/,$(install-data)): $(inst_datadir)/%: % $(+force)
 endif
 headers := $(strip $(headers))
 ifdef headers
-$(addprefix $(inst_includedir)/,$(headers)): $(inst_includedir)/%: % $(+force)
+# This implicit rule installs headers from the source directory.
+# It may be ignored in preference to rules from sysd-rules to find
+# headers in the sysdeps tree.
+$(inst_includedir)/%.h: $(objpfx)%.h $(+force)
+       $(do-install)
+$(inst_includedir)/%.h: %.h $(+force)
        $(do-install)
+$(inst_includedir)/%.h: $(..)include/%.h $(+force)
+       $(do-install)
+headers-nonh := $(filter-out %.h,$(headers))
+ifdef headers-nonh
+$(addprefix $(inst_includedir)/,$(headers-nonh)): $(inst_includedir)/%: \
+                                                % $(+force)
+       $(do-install)
+endif  # headers-nonh
 endif  # headers
 
 .PHONY: install-bin-nosubdir install-bin-script-nosubdir \
@@ -1139,6 +1154,7 @@ install-lib-nosubdir: $(addprefix $(inst_libdir)/,\
 install-data-nosubdir: $(addprefix $(inst_datadir)/,$(install-data))
 install-headers-nosubdir: $(addprefix $(inst_includedir)/,$(headers))
 install-others-nosubdir: $(install-others)
+install-others-programs-nosubdir: $(install-others-programs)
 
 # We need all the `-nosubdir' targets so that `install' in the parent
 # doesn't depend on several things which each iterate over the subdirs.
@@ -1147,14 +1163,12 @@ install-others-nosubdir: $(install-others)
 install-%:: install-%-nosubdir ;
 
 .PHONY: install install-no-libc.a-nosubdir
-ifeq ($(build-programs),yes)
-install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
-                           install-bin-nosubdir install-bin-script-nosubdir \
-                           install-lib-nosubdir install-others-nosubdir \
-                           install-rootsbin-nosubdir install-sbin-nosubdir
-else
-install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir\
+install-no-libc.a-nosubdir: install-headers-nosubdir install-data-nosubdir \
                            install-lib-nosubdir install-others-nosubdir
+ifeq ($(build-programs),yes)
+install-no-libc.a-nosubdir: install-bin-nosubdir install-bin-script-nosubdir \
+                           install-rootsbin-nosubdir install-sbin-nosubdir \
+                           install-others-programs-nosubdir
 endif
 install: install-no-libc.a-nosubdir
 \f
@@ -1228,10 +1242,7 @@ endif
 
 ifeq ($(firstword $(sysd-sorted-done) f)$(firstword $(generating) f),tf)
 -include $(common-objpfx)tls.make
-config-tls := notls
-ifeq ($(use-tls),yes)
 config-tls := tls
-endif
 ifeq ($(use-thread),yes)
 config-tls := thread
 endif
@@ -1289,18 +1300,12 @@ endif
 
 endif
 
-# There's no good place to put this - here will do.
-ifeq ($(filter %posix, $(sysdirs)),)
-L_tmpnam  = 1
-TMP_MAX   = 0
-L_ctermid = 1
-L_cuserid = 1
-else
-L_tmpnam  = 20
-TMP_MAX   = 238328
-L_ctermid = 9
-L_cuserid = 9
-endif
+# These will have been set by sysdeps/posix/Makefile.
+L_tmpnam  ?= 1
+TMP_MAX   ?= 0
+L_ctermid ?= 1
+L_cuserid ?= 1
+
 stdio_lim = $(common-objpfx)bits/stdio_lim.h
 
 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
@@ -1377,8 +1382,8 @@ common-mostlyclean:
                                                      $(test-srcs)) \
                                     $(addsuffix -bp.out,$(tests) $(xtests) \
                                                         $(test-srcs)))
-       -rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib) \
-                                    $(install-lib.so) \
+       -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
+                                    $(install-lib) $(install-lib.so) \
                                     $(install-lib.so:%.so=%_pic.a))
        -rm -f core
        -rm -f $(objpfx)rtld-*.os