newlib: speed up targ-include setup & add error checking

The current targ-include setup runs `cp` 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 directory in
a single call.

We still need a check for empty directories with no headers (i.e. the
glob doesn't match anything), so add a helper variable to contain that
logic to reduce the boiler plate a little.
This commit is contained in:
Mike Frysinger 2022-02-19 00:54:20 -05:00
parent ed459780f4
commit a531ad9726
2 changed files with 47 additions and 130 deletions

View File

@ -204,77 +204,35 @@ all-recursive: stmp-targ-include
# The targ-include directory just holds the includes files for the # The targ-include directory just holds the includes files for the
# particular system and machine we have been configured for. It is # particular system and machine we have been configured for. It is
# used while building. # 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 stmp-targ-include: config.status
$(AM_V_GEN)rm -rf targ-include stmp-targ-include $(AM_V_GEN)rm -rf targ-include stmp-targ-include
$(AM_V_at)$(MAKE) targ-include/sys \ $(AM_V_at)$(MAKE) targ-include/sys \
targ-include/machine \ targ-include/machine \
targ-include/bits targ-include/bits
-$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \ $(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
for i in $(srcdir)/libc/machine/$(shared_machine_dir)/machine/*.h; do \ s=machine/$(shared_machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR) || exit $$?; \
[ -f $$i ] && cp $$i targ-include/machine/; \ s=machine/$(shared_machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR) || exit $$?; \
done; \ s=machine/$(shared_machine_dir)/include d= $(TARG_INCLUDE_CP_DIR) || exit $$?; \
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; \
fi fi
-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/machine/*.h; do \ $(AM_V_at)s=machine/$(machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR)
if [ -f $$i ]; then \ $(AM_V_at)s=machine/$(machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR)
cp $$i targ-include/machine/; \ $(AM_V_at)s=machine/$(machine_dir)/include d= $(TARG_INCLUDE_CP_DIR)
else true; fi ; \ $(AM_V_at)s=sys/$(sys_dir)/include d= $(TARG_INCLUDE_CP_DIR)
done $(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*/; do \
-$(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 \
if [ -d $$i ]; then \ if [ -d $$i ]; then \
for j in $$i/*.h; do \ d=`basename $$i`; \
if [ ! -d targ-include/`basename $$i` ]; then \ $(MKDIR_P) targ-include/$$d; \
mkdir targ-include/`basename $$i`; \ s=sys/${sys_dir}/include/$$d $(TARG_INCLUDE_CP_DIR) || exit $$?; \
fi; \ 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 ; \
done 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)$(MAKE) targ-include/newlib.h
$(AM_V_at)touch $@ $(AM_V_at)touch $@

View File

@ -1420,6 +1420,14 @@ libm_a_SOURCES = $(am__append_6) $(am__append_9) $(libm_common_src) \
libm_a_CFLAGS = $(AM_CFLAGS) $(libm_a_CFLAGS_$(subst /,_,$(@D))) $(libm_a_CFLAGS_$(subst /,_,$(@D)_$(<F))) 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_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))) 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 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
MULTISRCTOP = MULTISRCTOP =
MULTIBUILDTOP = MULTIBUILDTOP =
@ -8727,81 +8735,32 @@ targ-include/_newlib_version.h: _newlib_version.h targ-include
$(AM_V_GEN)cp _newlib_version.h $@ $(AM_V_GEN)cp _newlib_version.h $@
all-recursive: stmp-targ-include all-recursive: stmp-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.
stmp-targ-include: config.status stmp-targ-include: config.status
$(AM_V_GEN)rm -rf targ-include stmp-targ-include $(AM_V_GEN)rm -rf targ-include stmp-targ-include
$(AM_V_at)$(MAKE) targ-include/sys \ $(AM_V_at)$(MAKE) targ-include/sys \
targ-include/machine \ targ-include/machine \
targ-include/bits targ-include/bits
-$(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \ $(AM_V_at)if [ -n "$(shared_machine_dir)" ]; then \
for i in $(srcdir)/libc/machine/$(shared_machine_dir)/machine/*.h; do \ s=machine/$(shared_machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR) || exit $$?; \
[ -f $$i ] && cp $$i targ-include/machine/; \ s=machine/$(shared_machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR) || exit $$?; \
done; \ s=machine/$(shared_machine_dir)/include d= $(TARG_INCLUDE_CP_DIR) || exit $$?; \
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; \
fi fi
-$(AM_V_at)for i in $(srcdir)/libc/machine/$(machine_dir)/machine/*.h; do \ $(AM_V_at)s=machine/$(machine_dir)/machine d=machine $(TARG_INCLUDE_CP_DIR)
if [ -f $$i ]; then \ $(AM_V_at)s=machine/$(machine_dir)/sys d=sys $(TARG_INCLUDE_CP_DIR)
cp $$i targ-include/machine/; \ $(AM_V_at)s=machine/$(machine_dir)/include d= $(TARG_INCLUDE_CP_DIR)
else true; fi ; \ $(AM_V_at)s=sys/$(sys_dir)/include d= $(TARG_INCLUDE_CP_DIR)
done $(AM_V_at)for i in $(srcdir)/libc/sys/$(sys_dir)/include/*/; do \
-$(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 \
if [ -d $$i ]; then \ if [ -d $$i ]; then \
for j in $$i/*.h; do \ d=`basename $$i`; \
if [ ! -d targ-include/`basename $$i` ]; then \ $(MKDIR_P) targ-include/$$d; \
mkdir targ-include/`basename $$i`; \ s=sys/${sys_dir}/include/$$d $(TARG_INCLUDE_CP_DIR) || exit $$?; \
fi; \ 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 ; \
done 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)$(MAKE) targ-include/newlib.h
$(AM_V_at)touch $@ $(AM_V_at)touch $@