This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: reverted 59d9f1d


On Fri, Apr 09, 2010 at 03:21:22PM -0700, Roland McGrath wrote:
> Dan's change was wrong because it doesn't handle the $(..) issue right.
> Every run will regenerate the file, and differently in main vs subdirs.

Thanks.  I spent a while looking at this on Saturday.  Here's a patch
which handles both subdir cases (.. = ../ and .. = `pwd`/) and falls
back to -I options for non-subdir.  It also falls back to -I options
when includes.mk needs to be regenerated.

What do you think?

-- 
Daniel Jacobowitz
CodeSourcery

diff --git a/Makeconfig b/Makeconfig
index cd77fe1..37a0f7a 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -670,9 +670,20 @@ endif	# $(+cflags) == ""
 # library source directory, in the include directory, and in the
 # current directory.
 +sysdep-includes = $(addprefix -I,$(+sysdep_dirs))
++common-includes = $(+sysdep-includes) $(includes) $(sysincludes)
+ifdef subdir
+abspfx := $(shell cd $(sysdep_dir)/.. && pwd)/
+emptyvar := # Nothing.
+absinclude = $(patsubst -I$(..)%,-I$(abspfx)%,\
+	       $(patsubst $(emptyvar) $(..)%,$(emptyvar) $(abspfx)%, $1))
++abs-includes = $(call absinclude,$(+common-includes))
++include-file = $(if $(includes-force),$(+common-includes),@$(common-objpfx)includes)
+else
++include-file = $(+common-includes)
+endif
 +includes = -I$(..)include $(if $(subdir),$(objpfx:%/=-I%)) \
-	    $(+sysdep-includes) $(includes) \
-	    $(patsubst %/,-I%,$(..)) $(libio-include) -I. $(sysincludes)
+	    $(+include-file) \
+	    $(patsubst %/,-I%,$(..)) $(libio-include) -I.
 
 # Since libio has several internal header files, we use a -I instead
 # of many little headers in the include directory.
diff --git a/Makefile b/Makefile
index 61cfa43..d2327b3 100644
--- a/Makefile
+++ b/Makefile
@@ -227,7 +227,7 @@ parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
 parent-clean: parent-mostlyclean common-clean
 
 postclean = $(addprefix $(common-objpfx),$(postclean-generated)) \
-	    $(addprefix $(objpfx),sysd-dirs sysd-rules) \
+	    $(addprefix $(objpfx),sysd-dirs sysd-rules includes includes.mk) \
 	    $(addprefix $(objpfx),sysd-sorted soversions.mk soversions.i)
 
 clean: parent-clean
diff --git a/Makerules b/Makerules
index 9bfe550..8edab8c 100644
--- a/Makerules
+++ b/Makerules
@@ -269,6 +269,22 @@ ifndef sysd-rules-done
 no_deps=t
 endif
 
+ifdef subdir
+-include $(common-objpfx)includes.mk
+ifneq ($(+abs-includes),$(saved-includes))
+# Recreate includes.mk (and includes).
+includes-force = FORCE
+FORCE:
+endif
+$(common-objpfx)includes.mk: $(includes-force)
+	-@rm -f $@T $(common-objpfx)includesT
+	for inc in $(+abs-includes); do echo "$$inc"; done \
+	  > $(common-objpfx)includesT
+	mv -f $(common-objpfx)includesT $(common-objpfx)includes
+	echo 'saved-includes := $(+abs-includes)' > $@T
+	mv -f $@T $@
+endif
+
 define o-iterator-doit
 $(objpfx)%$o: %.S $(before-compile); $$(compile-command.S)
 endef


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]