about summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-01-19 18:19:01 -0500
committerRich Felker <dalias@aerifal.cx>2016-01-19 18:19:01 -0500
commit9f5eb77992b42d484d69e879d24ef86466f20f21 (patch)
tree197eab964463b8cce631315bf4c3c0cede6edd1f /Makefile
parent53f41fb568ae43034c9876cc9bd3961fd6d13671 (diff)
downloadmusl-9f5eb77992b42d484d69e879d24ef86466f20f21.tar.gz
musl-9f5eb77992b42d484d69e879d24ef86466f20f21.tar.xz
musl-9f5eb77992b42d484d69e879d24ef86466f20f21.zip
add support for arch-provided replacement files as .c or .S
previously, replacement files provided in $(ARCH) dirs under src/ had
to be .s files. in order to replace a file with C source, an empty .s
file was needed there to suppress the original file, and a separate .c
file was needed in arch/$(ARCH)/src/.

support for .S is new and is aimed at short-term use eliminating .sub
files. asm source files are still expected not to make any heavy
preprocessor use, just simple conditionals on subarch. eventually most
affected files may be replaced with C source files with minimal inline
asm instead of asm source files.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile12
1 files changed, 9 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 44b39b95..62b027ae 100644
--- a/Makefile
+++ b/Makefile
@@ -18,9 +18,9 @@ libdir = $(prefix)/lib
 syslibdir = /lib
 
 BASE_SRCS = $(sort $(wildcard $(srcdir)/src/*/*.c $(srcdir)/arch/$(ARCH)/src/*.c))
-BASE_OBJS = $(patsubst $(srcdir)/%.c,%.o,$(BASE_SRCS))
-ARCH_SRCS = $(wildcard $(srcdir)/src/*/$(ARCH)/*.s $(srcdir)/src/*/$(ARCH)$(ASMSUBARCH)/*.sub)
-ARCH_OBJS = $(patsubst $(srcdir)/%.sub,%.o,$(patsubst $(srcdir)/%.s,%.o,$(ARCH_SRCS)))
+BASE_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(BASE_SRCS)))
+ARCH_SRCS = $(wildcard $(srcdir)/src/*/$(ARCH)/*.[csS] $(srcdir)/src/*/$(ARCH)$(ASMSUBARCH)/*.sub)
+ARCH_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(ARCH_SRCS)))
 REPLACED_OBJS = $(sort $(subst /$(ARCH)$(ASMSUBARCH)/,/,$(subst /$(ARCH)/,/,$(ARCH_OBJS))) $(subst /$(ARCH)$(ASMSUBARCH)/,/$(ARCH)/,$(subst /$(ARCH)/,/,$(ARCH_OBJS))))
 OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS))))
 LOBJS = $(OBJS:.o=.lo)
@@ -152,6 +152,9 @@ obj/%.o: $(srcdir)/%.sub
 obj/%.o: $(srcdir)/%.s
 	$(AS_CMD) $(CFLAGS_ALL_STATIC)
 
+obj/%.o: $(srcdir)/%.S
+	$(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $<
+
 obj/%.o: $(srcdir)/%.c $(GENH) $(IMPH)
 	$(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $<
 
@@ -161,6 +164,9 @@ obj/%.lo: $(srcdir)/%.sub
 obj/%.lo: $(srcdir)/%.s
 	$(AS_CMD) $(CFLAGS_ALL_SHARED)
 
+obj/%.lo: $(srcdir)/%.S
+	$(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $<
+
 obj/%.lo: $(srcdir)/%.c $(GENH) $(IMPH)
 	$(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $<