4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-19 12:59:21 +08:00
newlib-cygwin/newlib/libm/Makefile.inc
Mike Frysinger ac9f8c46b1 newlib: libm: merge build up a directory
Convert all the libm/ subdir makes into the top-level Makefile.  This
allows us to build all of libm from the top Makefile without using any
recursive make calls.  This is faster and avoids the funky lib.a logic
where we unpack subdir archives to repack into a single libm.a.  The
machine override logic is maintained though by way of Makefile include
ordering, and source file accumulation in libm_a_SOURCES.

One thing to note is that this will require GNU Make because of:
	libm_a_CFLAGS = ... $(libm_a_CFLAGS_$(subst /,_,$(@D)))
This was the only way I could find to supporting per-dir compiler
settings, and I couldn't find a POSIX compatible way of transforming
the variable content.  I don't think this is a big deal as other
Makefiles in the tree are using GNU Make-specific syntax, but I call
this out as it's the only one so far in the new automake code that
I've been writing.

Automake doesn't provide precise control over the output object names
(by design).  This is fine by default as we get consistent names in all
the subdirs: libm_a-<source>.o.  But this relies on using the same set
of compiler flags for all objects.  We currently compile libm/common/
with different optimizations than the rest.

If we want to compile objects differently, we can create an intermediate
archive with the subset of objects with unique flags, and then add those
objects to the main archive.  But Automake will use a different prefix
for the objects, and thus we can't rely on ordering to override.

But if we leverage $@, we can turn Automake's CFLAGS into a multiplex
on a per-dir (and even per-file if we wanted) basis.  Unfortunately,
since $@ contains /, Automake complains it's an invalid name.  While
GNU Make supports this, it's a POSIX extension, so Automake flags it.
Using $(subst) avoids the Automake warning to get a POSIX compliant
name, albeit with a GNU Make extension.
2022-02-17 20:56:32 -05:00

91 lines
2.5 KiB
Makefile

info_TEXINFOS += %D%/libm.texi
%C%_libm_TEXINFOS = %D%/targetdep.tex $(LIBM_CHEWOUT_FILES)
LIBM_CHEWOUT_FILES =
LIBM_CHAPTERS =
LIBM_DOCBOOK_OUT_FILES = $(LIBM_CHEWOUT_FILES:.def=.xml)
$(LIBM_CHEWOUT_FILES): $(MKDOC)
%D%/libm.dvi: %D%/targetdep.tex $(LIBM_CHEWOUT_FILES)
%D%/targetdep.tex.stamp: $(LIBM_CHAPTERS)
$(AM_V_GEN)cat $^ > $@.tmp
$(AM_V_at)$(SHELL) $(newlib_basedir)/../move-if-change $@.tmp $(@:.stamp=)
$(AM_V_at)touch $@
%D%/targetdep.tex: %D%/targetdep.tex.stamp; @true
%D%/libm.xml.stamp: %D%/libm.in.xml $(LIBM_CHAPTERS) $(LIBM_DOCBOOK_OUT_FILES)
$(AM_V_at)\
for chapter in $(LIBM_CHAPTERS); do \
$(TEXI2DOCBOOK) < $(srcdir)/$$chapter > %D%/`basename $${chapter%.tex}`.xml || exit 1; \
done
$(AM_V_GEN)xsltproc --xinclude --path $(builddir)/%D% --nonet $(srcdir)/refcontainers.xslt $< > $@.tmp
$(AM_V_at)$(SHELL) $(newlib_basedir)/../move-if-change $@.tmp $(@:.stamp=)
$(AM_V_at)touch $@
%D%/libm.xml: %D%/libm.xml.stamp; @true
%C%_man: %D%/libm.xml
$(AM_V_GEN)xmlto --skip-validation -o %D% --searchpath $(builddir)/%D% man -m $(srcdir)/man.xsl %D%/libm.xml
man: %C%_man
%C%_install-man: %C%_man
$(MKDIR_P) $(DESTDIR)$(mandir)/man3
$(INSTALL_DATA) %D%/*.3 $(DESTDIR)$(mandir)/man3/
install-man: %C%_install-man
## The order of includes is important for two reasons:
## * The integrated documentation (chapter ordering).
## * Object overridding -- machine dir must come last.
## Do not change the order without considering the doc impact.
if NEWLIB_HW_FP
include %D%/mathfp/Makefile.inc
else
include %D%/math/Makefile.inc
endif
include %D%/common/Makefile.inc
include %D%/complex/Makefile.inc
include %D%/fenv/Makefile.inc
if HAVE_LIBM_MACHINE_AARCH64
include %D%/machine/aarch64/Makefile.inc
endif
if HAVE_LIBM_MACHINE_ARM
include %D%/machine/arm/Makefile.inc
endif
if HAVE_LIBM_MACHINE_I386
include %D%/machine/i386/Makefile.inc
endif
if HAVE_LIBM_MACHINE_MIPS
include %D%/machine/mips/Makefile.inc
endif
if HAVE_LIBM_MACHINE_NDS32
include %D%/machine/nds32/Makefile.inc
endif
if HAVE_LIBM_MACHINE_POWERPC
include %D%/machine/powerpc/Makefile.inc
endif
if HAVE_LIBM_MACHINE_PRU
include %D%/machine/pru/Makefile.inc
endif
if HAVE_LIBM_MACHINE_SPARC
include %D%/machine/sparc/Makefile.inc
endif
if HAVE_LIBM_MACHINE_SPU
include %D%/machine/spu/Makefile.inc
endif
if HAVE_LIBM_MACHINE_RISCV
include %D%/machine/riscv/Makefile.inc
endif
if HAVE_LIBM_MACHINE_X86_64
include %D%/machine/x86_64/Makefile.inc
endif
CLEANFILES += \
%D%/targetdep.tex \
%D%/targetdep.tex.stamp \
$(LIBM_CHEWOUT_FILES) \
$(LIBM_DOCBOOK_OUT_FILES) \
%D%/*.xml %D%/*.xml.stamp %D%/*.3