Re: [PATCH v3] libiberty: cleanup Makefile.in

2015-05-28 Thread Bernhard Reutner-Fischer
On 28 May 2015 at 17:48, Ian Lance Taylor i...@google.com wrote:
 On Thu, May 28, 2015 at 1:57 AM, Bernhard Reutner-Fischer
 rep.dot@gmail.com wrote:

 +stamp-pic-ofiles: $(CFILES:%=$(srcdir)/%)

 To the best of my knowledge, in POSIX make variable substitutions of
 this form do not recognize % specially.  In POSIX make this kind of
 substitution can only be used to change the file extension.  Also,
 POSIX make does not permit a variable expansion in the right hand side
 of the substitution.

Pity. bmake (a port from some BSD make) does support it.

Either way, i'm withdrawing these patches and the idea to attempt to make
the pic/ and noasan/ handling prettier.

thanks anyway!

cheers,


[PATCH v3] libiberty: cleanup Makefile.in

2015-05-28 Thread Bernhard Reutner-Fischer
* configure.ac (TARGETLIB_PIC, TARGETLIB_NOASAN): New variables.
* configure: Regenerate.
* maint-tool: Refactor pic/ and noasan/ handling.
* Makefile.in: Likewise. Regenerate dependencies.

---
The below does the same but attempts to be limited to what POSIX
requires a make(1) to provide. Seems to compile fine with gnu-make and
bmake.

Changes v2 - v3:
- drop unneeded SUB_CFLAGS
- add dependencies on %.c for stamp-pic-ofiles and stamp-noasan-ofiles

Ok for trunk?

Signed-off-by: Bernhard Reutner-Fischer rep.dot@gmail.com
---
 libiberty/Makefile.in  | 2408 +---
 libiberty/configure|8 +
 libiberty/configure.ac |6 +
 libiberty/maint-tool   |   33 +-
 4 files changed, 1487 insertions(+), 968 deletions(-)

diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index f06cc69..ca4e75f 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -68,6 +68,7 @@ MAKEOVERRIDES =
 
 TARGETLIB = ./libiberty.a
 TESTLIB = ./testlib.a
+TARGETLIBS = $(TARGETLIB) @TARGETLIB_PIC@ @TARGETLIB_NOASAN@
 
 LIBOBJS = @LIBOBJS@
 
@@ -102,7 +103,7 @@ FLAGS_TO_PASS = \
 SUBDIRS = testsuite
 
 # FIXME: add @BUILD_INFO@ once we're sure it works for everyone.
-all: stamp-picdir stamp-noasandir $(TARGETLIB) required-list all-subdir
+all: $(TARGETLIBS) required-list all-subdir
@: $(MAKE) ; $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
 
 .PHONY: check installcheck
@@ -244,24 +245,24 @@ INSTALLED_HEADERS =   
  \
$(INCDIR)/timeval-utils.h
 
 $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
-   -rm -f $(TARGETLIB) pic/$(TARGETLIB) noasan/$(TARGETLIB)
-   $(AR) $(AR_FLAGS) $(TARGETLIB) \
+   -rm -f $@
+   $(AR) $(AR_FLAGS) $@ \
  $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
-   $(RANLIB) $(TARGETLIB)
-   if [ x$(PICFLAG) != x ]; then \
- cd pic; \
- $(AR) $(AR_FLAGS) $(TARGETLIB) \
-   $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
- $(RANLIB) $(TARGETLIB); \
- cd ..; \
-   else true; fi; \
-   if [ x$(NOASANFLAG) != x ]; then \
- cd noasan; \
- $(AR) $(AR_FLAGS) $(TARGETLIB) \
-   $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
- $(RANLIB) $(TARGETLIB); \
- cd ..; \
-   else true; fi
+   $(RANLIB) $@
+
+TARGETLIB_PIC_OFILES = `echo $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) | \
+sed -e 's,[^/ ]*/,./pic/,g';`
+./pic/libiberty.a: stamp-pic-ofiles
+   -rm -f $@
+   $(AR) $(AR_FLAGS) $@ $(TARGETLIB_PIC_OFILES)
+   $(RANLIB) $@
+
+TARGETLIB_NOASAN_OFILES =`echo $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) | 
\
+sed -e 's,[^/ ]*/,./noasan/,g';`
+./noasan/libiberty.a: stamp-noasan-ofiles
+   -rm -f $@
+   $(AR) $(AR_FLAGS) $@ $(TARGETLIB_NOASAN_OFILES)
+   $(RANLIB) $@
 
 $(TESTLIB): $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
-rm -f $(TESTLIB)
@@ -393,17 +394,15 @@ install_to_tooldir: all
 required-list: Makefile
echo $(REQUIRED_OFILES)  required-list
 
-stamp-picdir:
-   if [ x$(PICFLAG) != x ]  [ ! -d pic ]; then \
- mkdir pic; \
-   else true; fi
-   touch stamp-picdir
+stamp-pic-ofiles: $(CFILES:%=$(srcdir)/%)
+   [ -d pic ]  : || mkdir pic
+   $(MAKE) $(FLAGS_TO_PASS) $(TARGETLIB_PIC_OFILES)
+   touch $@
 
-stamp-noasandir:
-   if [ x$(NOASANFLAG) != x ]  [ ! -d noasan ]; then \
- mkdir noasan; \
-   else true; fi
-   touch stamp-noasandir
+stamp-noasan-ofiles: $(CFILES:%=$(srcdir)/%)
+   [ -d noasan ]  : || mkdir noasan
+   $(MAKE) $(FLAGS_TO_PASS) $(TARGETLIB_NOASAN_OFILES)
+   touch $@
 
 .PHONY: all etags tags ls clean stage1 stage2
 
@@ -444,7 +443,7 @@ maint-deps :
 mostlyclean: mostlyclean-subdir
-rm -rf *.$(objext) pic noasan core errs \#* *.E a.out
-rm -f errors dummy config.h stamp-*
-   -rm -f $(CONFIG_H) stamp-picdir stamp-noasandir
+   -rm -f $(CONFIG_H)
-rm -f libiberty.aux libiberty.cp libiberty.cps libiberty.fn 
libiberty.ky
-rm -f libiberty.log libiberty.tmp libiberty.tps libiberty.pg
-rm -f libiberty.pgs libiberty.toc libiberty.tp libiberty.tpl 
libiberty.vr
@@ -501,9 +500,6 @@ maintainer-clean-subdir: config.h
  cd $$dir  $(MAKE) $(FLAGS_TO_PASS) $$target; \
done
 
-$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS): stamp-picdir stamp-noasandir
-$(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
-
 # Don't export variables to the environment, in order to not confuse
 # configure.
 .NOEXPORT:
@@ -511,1200 +507,1708 @@ $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
 # The dependencies in the remainder of this file are automatically
 # generated by make maint-deps.  Manual edits will be lost.
 
-./_doprnt.$(objext): $(srcdir)/_doprnt.c config.h $(INCDIR)/ansidecl.h \
-   $(INCDIR)/safe-ctype.h
-   if [ x$(PICFLAG) != x ]; then 

Re: [PATCH v3] libiberty: cleanup Makefile.in

2015-05-28 Thread Ian Lance Taylor
On Thu, May 28, 2015 at 1:57 AM, Bernhard Reutner-Fischer
rep.dot@gmail.com wrote:

 +stamp-pic-ofiles: $(CFILES:%=$(srcdir)/%)

To the best of my knowledge, in POSIX make variable substitutions of
this form do not recognize % specially.  In POSIX make this kind of
substitution can only be used to change the file extension.  Also,
POSIX make does not permit a variable expansion in the right hand side
of the substitution.

Ian