[syslinux:wip.makefixes] Further separating out per-architecture files; remove arch/ directories

syslinux-bot for H. Peter Anvin (Intel) hpa at zytor.com
Mon Mar 25 15:18:12 PDT 2019


Commit-ID:  4594aa8c83ac85c37ca82d6212250b3381db580c
Gitweb:     https://www.syslinux.org/commit/4594aa8c83ac85c37ca82d6212250b3381db580c
Author:     H. Peter Anvin (Intel) <hpa at zytor.com>
AuthorDate: Mon, 25 Mar 2019 15:13:10 -0700
Committer:  H. Peter Anvin (Intel) <hpa at zytor.com>
CommitDate: Mon, 25 Mar 2019 15:13:10 -0700

Further separating out per-architecture files; remove arch/ directories

More things we only want to build for certain architectures.

Instead of the clumsy arch/ directories, add a list of architecture
names so we can filter out non-applicable architectures.

Signed-off-by: H. Peter Anvin (Intel) <hpa at zytor.com>

---
 com32/lib/Makefile                     | 16 +++++-----------
 com32/lib/bios/i386/memcpy.c           | 19 +++++++++++++++++++
 com32/lib/bios/i386/memset.c           | 18 ++++++++++++++++++
 com32/lib/memcpy.c                     | 29 -----------------------------
 com32/lib/memset.c                     | 30 ------------------------------
 core/Makefile                          |  3 +--
 core/Makefile.efi                      |  2 +-
 core/efi/{arch => }/i386/linux.S       |  0
 core/efi/{arch => }/i386/syslinux.ld   |  0
 core/efi/{arch => }/x86_64/linux.S     |  0
 core/efi/{arch => }/x86_64/syslinux.ld |  0
 mk/syslinux.mk                         |  6 ++++++
 12 files changed, 50 insertions(+), 73 deletions(-)

diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 5091e3fa..cef1636c 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -105,7 +105,7 @@ LIBCONSOLE_OBJS = \
 LIBLOAD_OBJS = \
 	syslinux/addlist.o syslinux/freelist.o syslinux/memmap.o	\
 	syslinux/movebits.o syslinux/shuffle.o syslinux/shuffle_pm.o	\
-	syslinux/shuffle_rm.o syslinux/biosboot.o syslinux/zonelist.o	\
+	syslinux/shuffle_rm.o syslinux/zonelist.o	\
 	syslinux/dump_mmap.o syslinux/dump_movelist.o			\
 	\
 	syslinux/run_default.o syslinux/run_command.o			\
@@ -113,7 +113,7 @@ LIBLOAD_OBJS = \
 	\
 	syslinux/loadfile.o syslinux/floadfile.o syslinux/zloadfile.o	\
 	\
-	syslinux/load_linux.o syslinux/initramfs.o			\
+	syslinux/initramfs.o			\
 	syslinux/initramfs_file.o syslinux/initramfs_loadfile.o		\
 	syslinux/initramfs_archive.o
 
@@ -146,20 +146,14 @@ CORELIBOBJS = \
 
 # Firmware-specific modules
 FWSRCS := $(sort $(shell find '$(SRC)/$(fwclass)' \
-	-name $(ARCH) -type d -true -o \
-	-regex '.*/arch/[^/]+' -type d -prune -o \
-	-type -f -print))
+		  $(patsubst %,-name % -type d -prune -o,$(OTHERARCHES)) \
+		  -type f -print))
 FWCSRCS := $(filter %.c, $(FWSRCS))
 FWSSRCS := $(filter %.S, $(FWSRCS))
-FWOBJS  := $(FWCSRCS:%(SRC)/%.c=%.o) $(FWSSRCS:%(SRC)/%.S=%.o)
+FWOBJS  := $(FWCSRCS:$(SRC)/%.c=%.o) $(FWSSRCS:$(SRC)/%.S=%.o)
 
 CORELIBOBJS += $(FWOBJS)
 
-ifneq ($(FWCLASS),EFI)
-# For EFI, these are part of gnu-efi
-CORELIBOBJS += $(ARCH)/setjmp.o memcpy.o memset.o
-endif
-
 ## OPTIONAL OBJECTS, AVAILABLE AS DYNAMIC LINKED MODULES
 # PNG library object files
 LIBPNG_OBJS = \
diff --git a/com32/lib/bios/i386/memcpy.c b/com32/lib/bios/i386/memcpy.c
new file mode 100644
index 00000000..ee31b788
--- /dev/null
+++ b/com32/lib/bios/i386/memcpy.c
@@ -0,0 +1,19 @@
+/*
+ * memcpy.c
+ */
+
+#include <string.h>
+#include <stdint.h>
+
+void *memcpy(void *dst, const void *src, size_t n)
+{
+	const char *p = src;
+	char *q = dst;
+	size_t nl = n >> 2;
+
+	asm volatile ("rep movsl ; movl %3,%0 ; rep movsb"
+		      : "+c" (nl), "+S" (p), "+D" (q)
+		      : "r" (n & 3));
+
+	return dst;
+}
diff --git a/com32/lib/bios/i386/memset.c b/com32/lib/bios/i386/memset.c
new file mode 100644
index 00000000..4fb0735b
--- /dev/null
+++ b/com32/lib/bios/i386/memset.c
@@ -0,0 +1,18 @@
+/*
+ * memset.c
+ */
+
+#include <string.h>
+#include <stdint.h>
+
+void *memset(void *dst, int c, size_t n)
+{
+	char *q = dst;
+	size_t nl = n >> 2;
+
+	asm volatile ("rep stosl ; movl %3,%0 ; rep stosb"
+		      : "+c" (nl), "+D" (q)
+		      : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3));
+
+	return dst;
+}
diff --git a/com32/lib/memcpy.c b/com32/lib/memcpy.c
deleted file mode 100644
index 5ce206d0..00000000
--- a/com32/lib/memcpy.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * memcpy.c
- */
-
-#include <string.h>
-#include <stdint.h>
-
-void *memcpy(void *dst, const void *src, size_t n)
-{
-	const char *p = src;
-	char *q = dst;
-#if defined(__i386__)
-	size_t nl = n >> 2;
-	asm volatile ("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb":"+c" (nl),
-		      "+S"(p), "+D"(q)
-		      :"r"(n & 3));
-#elif defined(__x86_64__)
-	size_t nq = n >> 3;
-	asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c"
-		      (nq), "+S"(p), "+D"(q)
-		      :"r"((uint32_t) (n & 7)));
-#else
-	while (n--) {
-		*q++ = *p++;
-	}
-#endif
-
-	return dst;
-}
diff --git a/com32/lib/memset.c b/com32/lib/memset.c
deleted file mode 100644
index aa00b5b1..00000000
--- a/com32/lib/memset.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * memset.c
- */
-
-#include <string.h>
-#include <stdint.h>
-
-void *memset(void *dst, int c, size_t n)
-{
-	char *q = dst;
-
-#if defined(__i386__)
-	size_t nl = n >> 2;
-	asm volatile ("cld ; rep ; stosl ; movl %3,%0 ; rep ; stosb"
-		      : "+c" (nl), "+D" (q)
-		      : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3));
-#elif defined(__x86_64__)
-	size_t nq = n >> 3;
-	asm volatile ("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb"
-		      :"+c" (nq), "+D" (q)
-		      : "a" ((unsigned char)c * 0x0101010101010101U),
-			"r" ((uint32_t) n & 7));
-#else
-	while (n--) {
-		*q++ = c;
-	}
-#endif
-
-	return dst;
-}
diff --git a/core/Makefile b/core/Makefile
index 2f5cac5f..705be47a 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -40,8 +40,7 @@ PREPCORE  = $(objdir)/prepcore/$(fwclass)/prepcore
 # All primary source files for the main syslinux files
 SRCFILES  := $(sort $(shell find $(SRCDIRS:%=$(SRC)/%) \
 	        -name tests   -type d -prune -o \
-		-name $(ARCH) -type d -true  -o \
-		-regex '.*/arch/[^/]+' -type d -prune -o \
+		$(patsubst %,-name % -type d -prune -o, $(OTHERARCHES)) \
 		-type f -print))
 NASMSRC	  := $(filter %.asm,$(SRCFILES))
 NASMHDR	  := $(filter %.inc,$(SRCFILES))
diff --git a/core/Makefile.efi b/core/Makefile.efi
index 7b1db7a4..f6f34376 100644
--- a/core/Makefile.efi
+++ b/core/Makefile.efi
@@ -34,7 +34,7 @@ CFLAGS  += $(DATE_DEFS)
 syslinux.efi: efi/syslinux.elf $(PREPCORE)
 	$(PREPCORE) $< $@
 
-CORELDSCRIPT = $(SRC)/efi/arch/$(ARCH)/syslinux.ld
+CORELDSCRIPT = $(SRC)/efi/$(ARCH)/syslinux.ld
 
 $(ETARGET): $(CORE_LIB) $(CORE_LIBS) $(CORELDSCRIPT)
 	$(LD) $(CORELDFLAGS) --strip-debug -o $@ \
diff --git a/core/efi/arch/i386/linux.S b/core/efi/i386/linux.S
similarity index 100%
rename from core/efi/arch/i386/linux.S
rename to core/efi/i386/linux.S
diff --git a/core/efi/arch/i386/syslinux.ld b/core/efi/i386/syslinux.ld
similarity index 100%
rename from core/efi/arch/i386/syslinux.ld
rename to core/efi/i386/syslinux.ld
diff --git a/core/efi/arch/x86_64/linux.S b/core/efi/x86_64/linux.S
similarity index 100%
rename from core/efi/arch/x86_64/linux.S
rename to core/efi/x86_64/linux.S
diff --git a/core/efi/arch/x86_64/syslinux.ld b/core/efi/x86_64/syslinux.ld
similarity index 100%
rename from core/efi/arch/x86_64/syslinux.ld
rename to core/efi/x86_64/syslinux.ld
diff --git a/mk/syslinux.mk b/mk/syslinux.mk
index bf0c4310..92c5ebc4 100644
--- a/mk/syslinux.mk
+++ b/mk/syslinux.mk
@@ -77,6 +77,12 @@ WGET	 = wget
 
 CC_FOR_BUILD ?= $(CC)
 
+# All supported CPU architectures
+ARCHLIST    := i386 x86_64
+
+# The architectures we are not currently building for
+OTHERARCHES := $(filter-out $(ARCH),$(ARCHLIST))
+
 com32    = $(topdir)/com32
 
 # Architecture definition


More information about the Syslinux-commits mailing list