+
+THUMBOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(THUMBSRC))
+ARMOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(ARMSRC))
+ASMOBJ = $(patsubst %.s,$(OBJDIR)/%.o,$(ASMSRC))
+
+$(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
+ $(CC) $(CFLAGS) -mthumb -mthumb-interwork -o $@ $<
+
+$(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES)
+ $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
+
+$(ASMOBJ): $(OBJDIR)/%.o: %.s
+ $(CC) $(CFLAGS) -mthumb-interwork -o $@ $<
+
+$(OBJDIR)/%.s19: $(OBJDIR)/%.elf
+ $(OBJCOPY) -Osrec --srec-forceS3 $^ $@
+
+# Automatic dependency generation
+DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \
+ $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(ARMSRC))) \
+ $(patsubst %.s,$(OBJDIR)/%.d,$(notdir $(ASMSRC)))
+
+$(DEPENDENCY_FILES): Makefile ../common/Makefile.common
+$(OBJDIR)/%.d: %.c
+ $(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
+$(OBJDIR)/%.d: %.s
+ $(CC) -MM -MT "$(@) $(@:.d=.o)" $(CFLAGS) $< > $@
+
+-include $(DEPENDENCY_FILES)