Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160706035414.10083-1-koorogi@koorogi.info>
Date: Tue,  5 Jul 2016 22:54:10 -0500
From: Bobby Bingham <koorogi@...rogi.info>
To: musl@...ts.openwall.com
Subject: [PATCH 1/5] generalize "generic" fallback for bits headers

Previously, ports could provide a given bits header, or they could inherit
a generic version.  There was a limitation that there could only be one
generic version of a given header.  In some cases, there were multiple
ports that could share one version of a header, and others which could
share a different version (e.g., 32-bit vs 64-bit versions).

This commit implements the makefile infrastructure necessary to provide
multiple bits header overlays, and to let each port decide which overlays
to use.  The first referenced overlay which contains a given bits header
will be the one that is used for that header.
---
 Makefile | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 8246b78..b401cdf 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ CFLAGS_AUTO = -Os -pipe
 CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc 
 
 CFLAGS_ALL = $(CFLAGS_C99FSE)
-CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(srcdir)/arch/$(ARCH) -I$(srcdir)/arch/generic -Iobj/src/internal -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
+CFLAGS_ALL += -D_XOPEN_SOURCE=700 $(foreach a,$(ARCH_FALLBACKS),-I$(srcdir)/arch/$(a)) -Iobj/src/internal -I$(srcdir)/src/internal -Iobj/include -I$(srcdir)/include
 CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
 
 LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
@@ -55,10 +55,9 @@ AR      = $(CROSS_COMPILE)ar
 RANLIB  = $(CROSS_COMPILE)ranlib
 INSTALL = $(srcdir)/tools/install.sh
 
-ARCH_INCLUDES = $(wildcard $(srcdir)/arch/$(ARCH)/bits/*.h)
-GENERIC_INCLUDES = $(wildcard $(srcdir)/arch/generic/bits/*.h)
+ARCH_INCLUDES = $(sort $(foreach a,$(ARCH_FALLBACKS),$(patsubst $(srcdir)/arch/$(a)/%,include/%,$(wildcard $(srcdir)/arch/$(a)/bits/*.h))))
 INCLUDES = $(wildcard $(srcdir)/include/*.h $(srcdir)/include/*/*.h)
-ALL_INCLUDES = $(sort $(INCLUDES:$(srcdir)/%=%) $(GENH:obj/%=%) $(ARCH_INCLUDES:$(srcdir)/arch/$(ARCH)/%=include/%) $(GENERIC_INCLUDES:$(srcdir)/arch/generic/%=include/%))
+ALL_INCLUDES = $(sort $(INCLUDES:$(srcdir)/%=%) $(GENH:obj/%=%) $(ARCH_INCLUDES))
 
 EMPTY_LIB_NAMES = m rt pthread crypt util xnet resolv dl
 EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a)
@@ -84,6 +83,12 @@ all:
 
 else
 
+-include $(srcdir)/arch/$(ARCH)/arch.mak
+
+ifeq ($(ARCH_FALLBACKS),)
+ARCH_FALLBACKS = $(ARCH) generic
+endif
+
 all: $(ALL_LIBS) $(ALL_TOOLS)
 
 OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include)
@@ -100,6 +105,12 @@ obj/include/bits/syscall.h: $(srcdir)/arch/$(ARCH)/bits/syscall.h.in
 	cp $< $@
 	sed -n -e s/__NR_/SYS_/p < $< >> $@
 
+define mkarchheaders
+$(DESTDIR)$(includedir)/bits/%: $(srcdir)/arch/$(1)/bits/%
+	$(INSTALL) -D -m 644 $$< $$@
+endef
+$(foreach a,$(ARCH_FALLBACKS),$(eval $(call mkarchheaders,$(a))))
+
 obj/src/internal/version.h: $(wildcard $(srcdir)/VERSION $(srcdir)/.git)
 	printf '#define VERSION "%s"\n' "$$(cd $(srcdir); sh tools/version.sh)" > $@
 
@@ -202,12 +213,6 @@ $(DESTDIR)$(libdir)/%.so: lib/%.so
 $(DESTDIR)$(libdir)/%: lib/%
 	$(INSTALL) -D -m 644 $< $@
 
-$(DESTDIR)$(includedir)/bits/%: $(srcdir)/arch/$(ARCH)/bits/%
-	$(INSTALL) -D -m 644 $< $@
-
-$(DESTDIR)$(includedir)/bits/%: $(srcdir)/arch/generic/bits/%
-	$(INSTALL) -D -m 644 $< $@
-
 $(DESTDIR)$(includedir)/bits/%: obj/include/bits/%
 	$(INSTALL) -D -m 644 $< $@
 
-- 
2.9.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.