public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: [PATCH] newlib: libc: move stdio multiplex logic from build to source files
Date: Fri, 25 Feb 2022 23:47:48 -0500	[thread overview]
Message-ID: <20220226044748.32601-1-vapier@gentoo.org> (raw)

Rather than define per-object rules in the Makefile, have small files
that define & include the right content.  This simplifies the build
rules, and makes understanding the source a little easier (imo) as it
makes all the subdirs behave the same: you have 1 source file and it
produces 1 object.  It's also about the same amount of boiler plate,
without having to define custom build rules that can fall out of sync.
Some of these rules were already unnecessary as they were compiling a
single source file into the same named object w/out custom flags, and
Automake handles that for us completely.

This will also be important as we merge the libc.a build into the top
dir since it relies on a single flat list of objects for overrides.

Also take the opportunity to clean up the unnecessary header deps in
here.  Automake provides dependency generation for free now.
---
 newlib/libc/stdio/Makefile.am      | 241 ++-------------
 newlib/libc/stdio/Makefile.in      | 478 ++++++++++++-----------------
 newlib/libc/stdio/nano-svfprintf.c |   2 +
 newlib/libc/stdio/nano-svfscanf.c  |   2 +
 newlib/libc/stdio/svfiprintf.c     |   3 +
 newlib/libc/stdio/svfiscanf.c      |   3 +
 newlib/libc/stdio/svfiwprintf.c    |   3 +
 newlib/libc/stdio/svfiwscanf.c     |   3 +
 newlib/libc/stdio/svfprintf.c      |   2 +
 newlib/libc/stdio/svfscanf.c       |   2 +
 newlib/libc/stdio/svfwprintf.c     |   2 +
 newlib/libc/stdio/svfwscanf.c      |   2 +
 newlib/libc/stdio/vfiprintf.c      |   2 +
 newlib/libc/stdio/vfiscanf.c       |   2 +
 newlib/libc/stdio/vfiwprintf.c     |   2 +
 newlib/libc/stdio/vfiwscanf.c      |   2 +
 16 files changed, 249 insertions(+), 502 deletions(-)
 create mode 100644 newlib/libc/stdio/nano-svfprintf.c
 create mode 100644 newlib/libc/stdio/nano-svfscanf.c
 create mode 100644 newlib/libc/stdio/svfiprintf.c
 create mode 100644 newlib/libc/stdio/svfiscanf.c
 create mode 100644 newlib/libc/stdio/svfiwprintf.c
 create mode 100644 newlib/libc/stdio/svfiwscanf.c
 create mode 100644 newlib/libc/stdio/svfprintf.c
 create mode 100644 newlib/libc/stdio/svfscanf.c
 create mode 100644 newlib/libc/stdio/svfwprintf.c
 create mode 100644 newlib/libc/stdio/svfwscanf.c
 create mode 100644 newlib/libc/stdio/vfiprintf.c
 create mode 100644 newlib/libc/stdio/vfiscanf.c
 create mode 100644 newlib/libc/stdio/vfiwprintf.c
 create mode 100644 newlib/libc/stdio/vfiwscanf.c

diff --git a/newlib/libc/stdio/Makefile.am b/newlib/libc/stdio/Makefile.am
index 538549c6aba8..6009aa7288ff 100644
--- a/newlib/libc/stdio/Makefile.am
+++ b/newlib/libc/stdio/Makefile.am
@@ -192,33 +192,33 @@ endif !ELIX_LEVEL_2
 endif !ELIX_LEVEL_1
 
 if NEWLIB_NANO_FORMATTED_IO
-LIBADD_OBJS = \
-	%D%/$(lpfx)nano-vfprintf_float.o	\
-	%D%/$(lpfx)nano-svfprintf.o		\
-	%D%/$(lpfx)nano-svfscanf.o		\
-	%D%/$(lpfx)nano-vfprintf.o		\
-	%D%/$(lpfx)nano-vfprintf_i.o		\
-	%D%/$(lpfx)nano-vfscanf.o		\
-	%D%/$(lpfx)nano-vfscanf_i.o		\
-	%D%/$(lpfx)nano-vfscanf_float.o	\
-	%D%/$(lpfx)svfiwprintf.o		\
-	%D%/$(lpfx)svfwprintf.o		\
-	%D%/$(lpfx)vfiwprintf.o		\
-	%D%/$(lpfx)svfiwscanf.o		\
-	%D%/$(lpfx)svfwscanf.o		\
-	%D%/$(lpfx)vfiwscanf.o		\
-	%D%/$(lpfx)vfwscanf.o
+GENERAL_SOURCES += \
+	%D%/nano-vfprintf_float.c \
+	%D%/nano-svfprintf.c \
+	%D%/nano-svfscanf.c \
+	%D%/nano-vfprintf.c \
+	%D%/nano-vfprintf_i.c \
+	%D%/nano-vfscanf.c \
+	%D%/nano-vfscanf_i.c \
+	%D%/nano-vfscanf_float.c
 else
-LIBADD_OBJS = \
-	%D%/$(lpfx)svfiprintf.o $(lpfx)svfprintf.o \
-	%D%/$(lpfx)svfiscanf.o $(lpfx)svfscanf.o \
-	%D%/$(lpfx)vfiprintf.o \
-	%D%/$(lpfx)vfscanf.o $(lpfx)vfiscanf.o \
-	%D%/$(lpfx)svfiwprintf.o $(lpfx)svfwprintf.o \
-	%D%/$(lpfx)vfiwprintf.o \
-	%D%/$(lpfx)svfiwscanf.o $(lpfx)svfwscanf.o \
-	%D%/$(lpfx)vfiwscanf.o $(lpfx)vfwscanf.o
+GENERAL_SOURCES += \
+	%D%/svfiprintf.c \
+	%D%/svfprintf.c \
+	%D%/svfiscanf.c \
+	%D%/svfscanf.c \
+	%D%/vfiprintf.c \
+	%D%/vfscanf.c \
+	%D%/vfiscanf.c
 endif
+GENERAL_SOURCES += \
+	%D%/svfiwprintf.c \
+	%D%/svfwprintf.c \
+	%D%/vfiwprintf.c \
+	%D%/svfiwscanf.c \
+	%D%/svfwscanf.c \
+	%D%/vfiwscanf.c \
+	%D%/vfwscanf.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(GENERAL_SOURCES) $(ELIX_2_SOURCES) $(ELIX_4_SOURCES)
@@ -226,194 +226,3 @@ lib_a_LIBADD = $(LIBADD_OBJS)
 lib_a_CFLAGS = $(AM_CFLAGS)
 lib_a_DEPENDENCIES = $(LIBADD_OBJS)
 LIB_COMPILE = $(AM_V_CC)$(COMPILE)
-
-# Though small footprint nano-formatted-IO implementation is used
-# when NEWLIB_NANO_FORMATTED_IO is enabled, we keep all rules for
-# the other implementation of formatted IO including all i-family
-# functions.  The object files in !NEWLIB_NANO_FORMATTED_IO version
-# implementation will be neither compiled nor archived into final
-# library, because they are not depended on by final makefile target.
-
-if NEWLIB_NANO_FORMATTED_IO
-# Rules compiling small-footprint nano-formatted-io implementation.
-$(lpfx)nano-vfprintf.o: nano-vfprintf.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/nano-vfprintf.c -o $@
-
-$(lpfx)nano-vfprintf_i.o: nano-vfprintf_i.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/nano-vfprintf_i.c -o $@
-
-$(lpfx)nano-vfprintf_float.o: nano-vfprintf_float.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/nano-vfprintf_float.c -o $@
-
-$(lpfx)nano-svfprintf.o: nano-vfprintf.c
-	%D%/$(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/nano-vfprintf.c -o $@
-endif
-
-# This rule is needed so that libtool compiles vfiprintf before vfprintf.
-# Otherwise libtool moves vfprintf.o and subsequently can't find it.
-
-$(lpfx)vfiprintf.o: vfprintf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfprintf.c -o $@
-
-$(lpfx)svfprintf.o: vfprintf.c
-	%D%/$(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/vfprintf.c -o $@
-
-$(lpfx)svfiprintf.o: vfprintf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfprintf.c -o $@
-
-$(lpfx)vfiwprintf.o: vfwprintf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfwprintf.c -o $@
-
-$(lpfx)svfwprintf.o: vfwprintf.c
-	%D%/$(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/vfwprintf.c -o $@
-
-$(lpfx)svfiwprintf.o: vfwprintf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfwprintf.c -o $@
-
-if NEWLIB_NANO_FORMATTED_IO
-# Rules compiling small-footprint nano-formatted-io implementation.
-$(lpfx)nano-vfscanf.o: nano-vfscanf.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/nano-vfscanf.c -o $@
-
-$(lpfx)nano-vfscanf_i.o: nano-vfscanf_i.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/nano-vfscanf_i.c -o $@
-
-$(lpfx)nano-vfscanf_float.o: nano-vfscanf_float.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/nano-vfscanf_float.c -o $@
-
-$(lpfx)nano-svfscanf.o: nano-vfscanf.c
-	%D%/$(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/nano-vfscanf.c -o $@
-endif
-
-$(lpfx)vfscanf.o: vfscanf.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/vfscanf.c -o $@
-
-$(lpfx)vfiscanf.o: vfscanf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfscanf.c -o $@
-
-$(lpfx)svfscanf.o: vfscanf.c
-	%D%/$(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/vfscanf.c -o $@
-
-$(lpfx)svfiscanf.o: vfscanf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfscanf.c -o $@
-
-$(lpfx)vfwscanf.o: vfwscanf.c
-	%D%/$(LIB_COMPILE) -c $(srcdir)/vfwscanf.c -o $@
-
-$(lpfx)vfiwscanf.o: vfwscanf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -c $(srcdir)/vfwscanf.c -o $@
-
-$(lpfx)svfwscanf.o: vfwscanf.c
-	%D%/$(LIB_COMPILE) -DSTRING_ONLY -c $(srcdir)/vfwscanf.c -o $@
-
-$(lpfx)svfiwscanf.o: vfwscanf.c
-	%D%/$(LIB_COMPILE) -DINTEGER_ONLY -DSTRING_ONLY -c $(srcdir)/vfwscanf.c -o $@
-
-$(lpfx)clearerr.o: local.h
-$(lpfx)clearerr_u.o: local.h
-$(lpfx)fclose.o: local.h
-$(lpfx)fdopen.o: local.h
-$(lpfx)feof.o: local.h
-$(lpfx)feof_u.o: local.h
-$(lpfx)ferror.o: local.h
-$(lpfx)ferror_u.o: local.h
-$(lpfx)fflush.o: local.h
-$(lpfx)fflush_u.o: fflush.c
-$(lpfx)fgetc.o: local.h
-$(lpfx)fgetc_u.o: local.h
-$(lpfx)fgets.o: local.h
-$(lpfx)fgets_u.o: fgets.c
-$(lpfx)fgetwc.o: local.h
-$(lpfx)fgetwc_u.o: local.h
-$(lpfx)fgetws.o: local.h
-$(lpfx)fgetws_u.o: fgetws.c
-$(lpfx)fileno.o: local.h
-$(lpfx)fileno_u.o: local.h
-$(lpfx)findfp.o: local.h
-$(lpfx)fmemopen.o: local.h
-$(lpfx)fopen.o: local.h
-$(lpfx)fopencookie.o: local.h
-$(lpfx)fpurge.o: local.h
-$(lpfx)fputc.o: local.h
-$(lpfx)fputc_u.o: local.h
-$(lpfx)fputs.o: fvwrite.h
-$(lpfx)fputs_u.o: fputs.c
-$(lpfx)fputwc.o: local.h
-$(lpfx)fputwc_u.o: local.h
-$(lpfx)fputws.o: local.h fvwrite.h
-$(lpfx)fputws_u.o: fputws.c
-$(lpfx)fread.o: local.h
-$(lpfx)fread_u.o: fread.c
-$(lpfx)freopen.o: local.h
-$(lpfx)fseek.o: local.h
-$(lpfx)fsetlocking.o: local.h
-$(lpfx)ftell.o: local.h
-$(lpfx)funopen.o: local.h
-$(lpfx)fvwrite.o: local.h fvwrite.h
-$(lpfx)fwalk.o: local.h
-$(lpfx)fwide.o: local.h
-$(lpfx)fwprintf.o: local.h
-$(lpfx)fwrite.o: local.h fvwrite.h
-$(lpfx)fwrite_u.o: fwrite.c
-$(lpfx)fwscanf.o: local.h
-$(lpfx)getwc.o: local.h
-$(lpfx)getwc_u.o: local.h
-$(lpfx)getwchar.o: local.h
-$(lpfx)getwchar_u.o: local.h
-$(lpfx)iscanf.o: local.h
-$(lpfx)makebuf.o: local.h
-$(lpfx)open_memstream.o: local.h
-$(lpfx)puts.o: fvwrite.h
-$(lpfx)putwc.o: local.h
-$(lpfx)putwc_u.o: local.h
-$(lpfx)putwchar.o: local.h
-$(lpfx)putwchar_u.o: local.h
-$(lpfx)refill.o: local.h
-$(lpfx)scanf.o: local.h
-$(lpfx)setbuf.o: local.h
-$(lpfx)setvbuf.o: local.h
-$(lpfx)siprintf.o: local.h
-$(lpfx)siscanf.o: local.h
-$(lpfx)sniprintf.o: local.h
-$(lpfx)sprintf.o: local.h
-$(lpfx)sscanf.o: local.h
-$(lpfx)stdio.o: local.h
-if NEWLIB_NANO_FORMATTED_IO
-$(lpfx)nano-svfprintf.o: local.h nano-vfprintf_local.h
-$(lpfx)nano-svfscanf.o: local.h nano-vfscanf_local.h
-endif
-$(lpfx)svfiprintf.o: local.h
-$(lpfx)svfiscanf.o: local.h floatio.h
-$(lpfx)svfprintf.o: local.h
-$(lpfx)svfscanf.o: local.h floatio.h
-$(lpfx)swprintf.o: local.h
-$(lpfx)swscanf.o: local.h
-$(lpfx)ungetc.o: local.h
-$(lpfx)ungetwc.o: local.h
-if NEWLIB_NANO_FORMATTED_IO
-$(lpfx)nano-vfprintf.o: local.h nano-vfprintf_local.h
-$(lpfx)nano-vfprintf_i.o: local.h nano-vfprintf_local.h
-$(lpfx)nano-vfprintf_float.o: local.h floatio.h nano-vfprintf_local.h
-$(lpfx)nano-vfscanf.o: local.h nano-vfscanf_local.h
-$(lpfx)nano-vfscanf_i.o: local.h nano-vfscanf_local.h
-$(lpfx)nano-vfscanf_float.o: local.h floatio.h nano-vfscanf_local.h
-endif
-$(lpfx)vfiprintf.o: local.h
-$(lpfx)vfiscanf.o: local.h floatio.h
-$(lpfx)vfprintf.o: local.h
-$(lpfx)vfscanf.o: local.h floatio.h
-$(lpfx)vfwprintf.o: local.h
-$(lpfx)vfwscanf.o: local.h
-$(lpfx)viscanf.o: local.h
-$(lpfx)vscanf.o: local.h
-$(lpfx)vsiscanf.o: local.h
-$(lpfx)vsniprintf.o: local.h
-$(lpfx)vsscanf.o: local.h
-$(lpfx)vswprintf.o: local.h
-$(lpfx)vswscanf.o: local.h
-$(lpfx)vwprintf.o: local.h
-$(lpfx)vwscanf.o: local.h
-$(lpfx)wbuf.o: local.h fvwrite.h
-$(lpfx)wprintf.o: local.h
-$(lpfx)wscanf.o: local.h
-$(lpfx)wsetup.o: local.h
diff --git a/newlib/libc/stdio/nano-svfprintf.c b/newlib/libc/stdio/nano-svfprintf.c
new file mode 100644
index 000000000000..6d2daef83eb8
--- /dev/null
+++ b/newlib/libc/stdio/nano-svfprintf.c
@@ -0,0 +1,2 @@
+#define STRING_ONLY
+#include "nano-vfprintf.c"
diff --git a/newlib/libc/stdio/nano-svfscanf.c b/newlib/libc/stdio/nano-svfscanf.c
new file mode 100644
index 000000000000..8fe4d9bcd5f8
--- /dev/null
+++ b/newlib/libc/stdio/nano-svfscanf.c
@@ -0,0 +1,2 @@
+#define STRING_ONLY
+#include "nano-vfscanf.c"
diff --git a/newlib/libc/stdio/svfiprintf.c b/newlib/libc/stdio/svfiprintf.c
new file mode 100644
index 000000000000..bbcc81caa798
--- /dev/null
+++ b/newlib/libc/stdio/svfiprintf.c
@@ -0,0 +1,3 @@
+#define INTEGER_ONLY
+#define STRING_ONLY
+#include "vfprintf.c"
diff --git a/newlib/libc/stdio/svfiscanf.c b/newlib/libc/stdio/svfiscanf.c
new file mode 100644
index 000000000000..e79cc79f5377
--- /dev/null
+++ b/newlib/libc/stdio/svfiscanf.c
@@ -0,0 +1,3 @@
+#define INTEGER_ONLY
+#define STRING_ONLY
+#include "vfscanf.c"
diff --git a/newlib/libc/stdio/svfiwprintf.c b/newlib/libc/stdio/svfiwprintf.c
new file mode 100644
index 000000000000..a9df2ca1506d
--- /dev/null
+++ b/newlib/libc/stdio/svfiwprintf.c
@@ -0,0 +1,3 @@
+#define INTEGER_ONLY
+#define STRING_ONLY
+#include "vfwprintf.c"
diff --git a/newlib/libc/stdio/svfiwscanf.c b/newlib/libc/stdio/svfiwscanf.c
new file mode 100644
index 000000000000..7e6a36f07d96
--- /dev/null
+++ b/newlib/libc/stdio/svfiwscanf.c
@@ -0,0 +1,3 @@
+#define INTEGER_ONLY
+#define STRING_ONLY
+#include "vfwscanf.c"
diff --git a/newlib/libc/stdio/svfprintf.c b/newlib/libc/stdio/svfprintf.c
new file mode 100644
index 000000000000..fe053c298e05
--- /dev/null
+++ b/newlib/libc/stdio/svfprintf.c
@@ -0,0 +1,2 @@
+#define STRING_ONLY
+#include "vfprintf.c"
diff --git a/newlib/libc/stdio/svfscanf.c b/newlib/libc/stdio/svfscanf.c
new file mode 100644
index 000000000000..ed01020f6924
--- /dev/null
+++ b/newlib/libc/stdio/svfscanf.c
@@ -0,0 +1,2 @@
+#define STRING_ONLY
+#include "vfscanf.c"
diff --git a/newlib/libc/stdio/svfwprintf.c b/newlib/libc/stdio/svfwprintf.c
new file mode 100644
index 000000000000..1ee9dd5618a4
--- /dev/null
+++ b/newlib/libc/stdio/svfwprintf.c
@@ -0,0 +1,2 @@
+#define STRING_ONLY
+#include "vfwprintf.c"
diff --git a/newlib/libc/stdio/svfwscanf.c b/newlib/libc/stdio/svfwscanf.c
new file mode 100644
index 000000000000..3b2987d6626c
--- /dev/null
+++ b/newlib/libc/stdio/svfwscanf.c
@@ -0,0 +1,2 @@
+#define STRING_ONLY
+#include "vfwscanf.c"
diff --git a/newlib/libc/stdio/vfiprintf.c b/newlib/libc/stdio/vfiprintf.c
new file mode 100644
index 000000000000..83394a6bcefc
--- /dev/null
+++ b/newlib/libc/stdio/vfiprintf.c
@@ -0,0 +1,2 @@
+#define INTEGER_ONLY
+#include "vfprintf.c"
diff --git a/newlib/libc/stdio/vfiscanf.c b/newlib/libc/stdio/vfiscanf.c
new file mode 100644
index 000000000000..261122ed0ccd
--- /dev/null
+++ b/newlib/libc/stdio/vfiscanf.c
@@ -0,0 +1,2 @@
+#define INTEGER_ONLY
+#include "vfscanf.c"
diff --git a/newlib/libc/stdio/vfiwprintf.c b/newlib/libc/stdio/vfiwprintf.c
new file mode 100644
index 000000000000..32546b5845ca
--- /dev/null
+++ b/newlib/libc/stdio/vfiwprintf.c
@@ -0,0 +1,2 @@
+#define INTEGER_ONLY
+#include "vfwprintf.c"
diff --git a/newlib/libc/stdio/vfiwscanf.c b/newlib/libc/stdio/vfiwscanf.c
new file mode 100644
index 000000000000..8b96cd3bacbe
--- /dev/null
+++ b/newlib/libc/stdio/vfiwscanf.c
@@ -0,0 +1,2 @@
+#define INTEGER_ONLY
+#include "vfwscanf.c"
-- 
2.34.1


             reply	other threads:[~2022-02-26  4:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26  4:47 Mike Frysinger [this message]
2022-02-28 12:07 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220226044748.32601-1-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).