public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] newlib: simplify header setup rules
@ 2022-02-25  0:27 Mike Frysinger
  2022-02-26  4:10 ` [PATCH] newlib: speed up targ-include setup & add error checking Mike Frysinger
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Frysinger @ 2022-02-25  0:27 UTC (permalink / raw)
  To: newlib

---
 newlib/Makefile.am | 36 +++++++++++++++---------------------
 newlib/Makefile.in | 36 +++++++++++++++---------------------
 2 files changed, 30 insertions(+), 42 deletions(-)

diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 9d9fd7048493..b5060fc16109 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -214,39 +214,33 @@ stmp-targ-include: config.status
 		targ-include/bits
 	-$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
 	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/machine/*.h; do \
-		if [ -f $$i ]; then \
-		  cp $$i targ-include/machine/`basename $$i`; \
-		else true; fi ; \
-	      done; \
+		[ -f $$i ] && cp $$i targ-include/machine/; \
+	    done; \
 	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/sys/*.h; do \
-		if [ -f $$i ]; then \
-		  cp $$i targ-include/sys/`basename $$i`; \
-		else true; fi ; \
-	      done; \
+		[ -f $$i ] && cp $$i targ-include/sys/; \
+	    done; \
 	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/include/*.h; do \
-		if [ -f $$i ]; then \
-		  cp $$i targ-include/`basename $$i`; \
-		else true; fi ; \
-	      done; \
+		[ -f $$i ] && cp $$i targ-include/; \
+	    done; \
 	  fi
 	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/machine/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/`basename $$i`; \
+	      cp $$i targ-include/machine/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/sys/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/sys/`basename $$i`; \
+	      cp $$i targ-include/sys/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/include/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/`basename $$i`; \
+	      cp $$i targ-include/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/`basename $$i`; \
+	      cp $$i targ-include/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*; do \
@@ -261,27 +255,27 @@ stmp-targ-include: config.status
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/sys/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/sys/`basename $$i`; \
+	      cp $$i targ-include/sys/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/bits/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/bits/`basename $$i`; \
+	      cp $$i targ-include/bits/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/`basename $$i`; \
+	      cp $$i targ-include/machine/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/$(machine_dir)/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/`basename $$i`; \
+	      cp $$i targ-include/machine/; \
 	    else true; fi ; \
 	  done
 	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/$(machine_dir)/include/*.h; do \
 	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/`basename $$i`; \
+	      cp $$i targ-include/machine/; \
 	    else true; fi ; \
 	  done
 	$(AM_V_at)$(MAKE) targ-include/newlib.h
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] newlib: speed up targ-include setup & add error checking
  2022-02-25  0:27 [PATCH] newlib: simplify header setup rules Mike Frysinger
@ 2022-02-26  4:10 ` Mike Frysinger
  2022-02-26  4:50   ` Mike Frysinger
  2022-02-28 10:40   ` Corinna Vinschen
  0 siblings, 2 replies; 4+ messages in thread
From: Mike Frysinger @ 2022-02-26  4:10 UTC (permalink / raw)
  To: newlib

The current targ-include setup runs `cp` and `basename` for every
header file it installs, in serial.  This can be a little noticeable
on systems, so cleanup the logic to rely on cp's ability to copy
multiple files to a single directory.

We still need the for loop to check for empty directories with no
headers (i.e. the glob doesn't match anything).
---
 newlib/Makefile.am | 84 +++++++++++------------------------------
 newlib/Makefile.in | 93 +++++++++++++---------------------------------
 2 files changed, 47 insertions(+), 130 deletions(-)

diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index b5060fc16109..c80b6d80dc04 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -207,77 +207,35 @@ targ-include/_newlib_version.h: _newlib_version.h targ-include
 # The targ-include directory just holds the includes files for the
 # particular system and machine we have been configured for.  It is
 # used while building.
+TARG_INCLUDE_CP_DIR = \
+	; srcdir="$(srcdir)/libc/$$s"; dstdir="targ-include/$$d"; \
+	if (cd $$srcdir 2>/dev/null && [ "`echo *.h`" != "*.h" ]); then cp $$srcdir/*.h $$dstdir/; fi
 stmp-targ-include: config.status
 	$(AM_V_GEN)rm -rf targ-include stmp-targ-include
 	$(AM_V_at)$(MAKE) targ-include/sys \
 		targ-include/machine \
 		targ-include/bits
-	-$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
-	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/machine/*.h; do \
-		[ -f $$i ] && cp $$i targ-include/machine/; \
-	    done; \
-	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/sys/*.h; do \
-		[ -f $$i ] && cp $$i targ-include/sys/; \
-	    done; \
-	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/include/*.h; do \
-		[ -f $$i ] && cp $$i targ-include/; \
-	    done; \
+	$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
+	    s=machine/$(shared_machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR) || exit $$?; \
+	    s=machine/$(shared_machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR) || exit $$?; \
+	    s=machine/$(shared_machine_dir)/include d= $(TARG_INCLUDE_CP_DIR) || exit $$?; \
 	  fi
-	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/machine/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/sys/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/sys/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/include/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*; do \
+	$(AM_V_at)s=machine/$(machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=machine/$(machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=machine/$(machine_dir)/include d= $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/include d= $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*/; do \
 	    if [ -d $$i ]; then \
-		for j in $$i/*.h; do \
-		    if [ ! -d targ-include/`basename $$i` ]; then \
-		    	mkdir targ-include/`basename $$i`; \
-		    fi; \
-	      	    cp $$j targ-include/`basename $$i`/`basename $$j`; \
-		done \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/sys/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/sys/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/bits/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/bits/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/$(machine_dir)/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/$(machine_dir)/include/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
+		d=`basename $$i`; \
+		$(MKDIR_P) targ-include/$$d; \
+		s=sys/${sys_dir}/include/$$d $(TARG_INCLUDE_CP_DIR) || exit $$?; \
+	    fi \
 	  done
+	$(AM_V_at)s=sys/$(sys_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/bits d=bits $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/machine/$(machine_dir) d=machine $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/machine/$(machine_dir)/include d=machine $(TARG_INCLUDE_CP_DIR)
 	$(AM_V_at)$(MAKE) targ-include/newlib.h
 	$(AM_V_at)touch $@
 
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 71db9e4d0aff..d49b30e768a5 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -3993,6 +3993,14 @@ libm_a_SOURCES = $(am__append_141) $(am__append_144) \
 libm_a_CFLAGS = $(AM_CFLAGS) $(libm_a_CFLAGS_$(subst /,_,$(@D))) $(libm_a_CFLAGS_$(subst /,_,$(@D)_$(<F)))
 libm_a_CCASFLAGS = $(AM_CCASFLAGS) $(libm_a_CCASFLAGS_$(subst /,_,$(@D))) $(libm_a_CCASFLAGS_$(subst /,_,$(@D)_$(<F)))
 libm_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/libm/common $(libm_a_CPPFLAGS_$(subst /,_,$(@D))) $(libm_a_CPPFLAGS_$(subst /,_,$(@D)_$(<F)))
+
+# The targ-include directory just holds the includes files for the
+# particular system and machine we have been configured for.  It is
+# used while building.
+TARG_INCLUDE_CP_DIR = \
+	; srcdir="$(srcdir)/libc/$$s"; dstdir="targ-include/$$d"; \
+	if (cd $$srcdir 2>/dev/null && [ "`echo *.h`" != "*.h" ]); then cp $$srcdir/*.h $$dstdir/; fi
+
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
 MULTISRCTOP = 
 MULTIBUILDTOP = 
@@ -23488,81 +23496,32 @@ targ-include/newlib.h: newlib.h targ-include
 
 targ-include/_newlib_version.h: _newlib_version.h targ-include
 	$(AM_V_GEN)cp _newlib_version.h $@
-
-# The targ-include directory just holds the includes files for the
-# particular system and machine we have been configured for.  It is
-# used while building.
 stmp-targ-include: config.status
 	$(AM_V_GEN)rm -rf targ-include stmp-targ-include
 	$(AM_V_at)$(MAKE) targ-include/sys \
 		targ-include/machine \
 		targ-include/bits
-	-$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
-	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/machine/*.h; do \
-		[ -f $$i ] && cp $$i targ-include/machine/; \
-	    done; \
-	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/sys/*.h; do \
-		[ -f $$i ] && cp $$i targ-include/sys/; \
-	    done; \
-	    for i in $(srcdir)/libc/machine/$(shared_machine_dir)/include/*.h; do \
-		[ -f $$i ] && cp $$i targ-include/; \
-	    done; \
+	$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
+	    s=machine/$(shared_machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR) || exit $$?; \
+	    s=machine/$(shared_machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR) || exit $$?; \
+	    s=machine/$(shared_machine_dir)/include d= $(TARG_INCLUDE_CP_DIR) || exit $$?; \
 	  fi
-	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/machine/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/sys/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/sys/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/include/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*; do \
+	$(AM_V_at)s=machine/$(machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=machine/$(machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=machine/$(machine_dir)/include d= $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/include d= $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*/; do \
 	    if [ -d $$i ]; then \
-		for j in $$i/*.h; do \
-		    if [ ! -d targ-include/`basename $$i` ]; then \
-		    	mkdir targ-include/`basename $$i`; \
-		    fi; \
-	      	    cp $$j targ-include/`basename $$i`/`basename $$j`; \
-		done \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/sys/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/sys/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/bits/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/bits/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/$(machine_dir)/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
-	  done
-	-$(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/machine/$(machine_dir)/include/*.h; do \
-	    if [ -f $$i ]; then \
-	      cp $$i targ-include/machine/; \
-	    else true; fi ; \
+		d=`basename $$i`; \
+		$(MKDIR_P) targ-include/$$d; \
+		s=sys/${sys_dir}/include/$$d $(TARG_INCLUDE_CP_DIR) || exit $$?; \
+	    fi \
 	  done
+	$(AM_V_at)s=sys/$(sys_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/bits d=bits $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/machine/$(machine_dir) d=machine $(TARG_INCLUDE_CP_DIR)
+	$(AM_V_at)s=sys/$(sys_dir)/machine/$(machine_dir)/include d=machine $(TARG_INCLUDE_CP_DIR)
 	$(AM_V_at)$(MAKE) targ-include/newlib.h
 	$(AM_V_at)touch $@
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] newlib: speed up targ-include setup & add error checking
  2022-02-26  4:10 ` [PATCH] newlib: speed up targ-include setup & add error checking Mike Frysinger
@ 2022-02-26  4:50   ` Mike Frysinger
  2022-02-28 10:40   ` Corinna Vinschen
  1 sibling, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2022-02-26  4:50 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 57 bytes --]

i was on the fence with squashing these 2 together
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] newlib: speed up targ-include setup & add error checking
  2022-02-26  4:10 ` [PATCH] newlib: speed up targ-include setup & add error checking Mike Frysinger
  2022-02-26  4:50   ` Mike Frysinger
@ 2022-02-28 10:40   ` Corinna Vinschen
  1 sibling, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2022-02-28 10:40 UTC (permalink / raw)
  To: newlib

On Feb 25 23:10, Mike Frysinger wrote:
> The current targ-include setup runs `cp` and `basename` for every
> header file it installs, in serial.  This can be a little noticeable
> on systems, so cleanup the logic to rely on cp's ability to copy
> multiple files to a single directory.
> 
> We still need the for loop to check for empty directories with no
> headers (i.e. the glob doesn't match anything).
> ---
>  newlib/Makefile.am | 84 +++++++++++------------------------------
>  newlib/Makefile.in | 93 +++++++++++++---------------------------------
>  2 files changed, 47 insertions(+), 130 deletions(-)

LGTM.  Please squash these two.


Thx,
Corinna


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-28 10:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25  0:27 [PATCH] newlib: simplify header setup rules Mike Frysinger
2022-02-26  4:10 ` [PATCH] newlib: speed up targ-include setup & add error checking Mike Frysinger
2022-02-26  4:50   ` Mike Frysinger
2022-02-28 10:40   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).