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)
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 $@ $<
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 $@ $<