HAL_ChibiOS: build crashcatcher lib alongside chibios

This commit is contained in:
bugobliterator 2021-10-21 16:17:59 +05:30 committed by Andrew Tridgell
parent c5dd02fb2b
commit c32bd845f2
2 changed files with 39 additions and 6 deletions

View File

@ -129,6 +129,11 @@ CSRC += $(HWDEF)/common/stubs.c \
# $(TESTSRC) \
# test.c
LIBCC_CSRC = $(CRASHCATCHER)/Core/src/CrashCatcher.c \
$(CRASHCATCHER)/HexDump/src/HexDump.c
LIBCC_ASMXSRC = $(CRASHCATCHER)/Core/src/CrashCatcher_armv7m.S
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC = $(sort $(ALLCPPSRC))
@ -158,7 +163,8 @@ ASMSRC = $(ALLASMSRC)
ASMXSRC = $(ALLXASMSRC)
INCDIR = $(CHIBIOS)/os/license \
$(ALLINC) $(HWDEF)/common
$(ALLINC) $(HWDEF)/common \
$(CRASHCATCHER)/include \
#
# Project, sources and paths

View File

@ -85,7 +85,7 @@ else
endif
ASRC := $(ACSRC) $(ACPPSRC)
TSRC := $(TCSRC) $(TCPPSRC)
SRCPATHS := $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))
SRCPATHS := $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)) $(dir $(LIBCC_CSRC)) $(dir $(LIBCC_ASMXSRC)))
# Various directories
OBJDIR := $(BUILDDIR)/obj
@ -99,7 +99,9 @@ TCPPOBJS := $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o)))
ASMOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
ASMXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
OBJS := $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS)
LIBCC_ASMXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(LIBCC_ASMXSRC:.S=.o)))
LIBCC_TCOBJS := $(addprefix $(OBJDIR)/, $(notdir $(LIBCC_CSRC:.c=.o)))
LIBCC_OBJS := $(LIBCC_ASMXOBJS) $(LIBCC_TCOBJS)
# Paths
IINCDIR := $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
LLIBDIR := $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
@ -117,7 +119,9 @@ MCFLAGS := -mcpu=$(MCU)
ODFLAGS = -x --syms
ASFLAGS = $(MCFLAGS) $(ADEFS)
ASXFLAGS = $(MCFLAGS) $(ADEFS)
LIBCC_ASXFLAGS = $(ASXFLAGS) $(USE_FPU_OPT)
CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) $(DEFS)
LIBCC_CFLAGS = $(CFLAGS)
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) $(DEFS)
LDFLAGS = $(MCFLAGS) $(OPT) -nostartfiles $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--library-path=$(RULESPATH)/ld,--script=$(LDSCRIPT)$(LDOPT)
@ -176,13 +180,13 @@ N := x
C = $(words $N)$(eval N := x $N)
ECHO = echo "[$C/$T] ChibiOS:"
endif
all: PRE_MAKE_ALL_RULE_HOOK $(OBJS) $(OUTFILES) POST_MAKE_ALL_RULE_HOOK
all: PRE_MAKE_ALL_RULE_HOOK $(OBJS) $(LIBCC_OBJS) $(OUTFILES) POST_MAKE_ALL_RULE_HOOK
PRE_MAKE_ALL_RULE_HOOK:
POST_MAKE_ALL_RULE_HOOK:
$(OBJS): | $(BUILDDIR) $(OBJDIR) $(LSTDIR)
$(LIBCC_OBJS) $(OBJS): | $(BUILDDIR) $(OBJDIR) $(LSTDIR)
$(BUILDDIR):
ifneq ($(USE_VERBOSE_COMPILE),yes)
@ -234,6 +238,15 @@ else
@$(CC) -c $(CFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif
$(LIBCC_TCOBJS) : $(OBJDIR)/%.o : %.c
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
$(CC) -c $(CFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
else
@$(ECHO) Compiling $(<F)
@$(CC) -c $(CFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif
$(ASMOBJS) : $(OBJDIR)/%.o : %.s
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
@ -252,6 +265,15 @@ else
@$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif
$(LIBCC_ASMXOBJS) : $(OBJDIR)/%.o : %.S
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
$(CC) -c $(LIBCC_ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
else
@$(ECHO) Compiling $(<F)
@$(CC) -c $(LIBCC_ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif
$(BUILDDIR)/$(PROJECT).elf: $(OBJS) $(LDSCRIPT)
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
@ -308,13 +330,18 @@ else
@echo Done
endif
lib: $(OBJS) $(BUILDDIR)/lib$(PROJECT).a pass
lib: $(OBJS) $(LIBCC_OBJS) $(BUILDDIR)/lib$(PROJECT).a $(BUILDDIR)/libcc.a pass
$(BUILDDIR)/lib$(PROJECT).a: $(OBJS)
@$(AR) -r $@ $^
@echo
@echo ChibiOS: Done!
$(BUILDDIR)/libcc.a: $(LIBCC_OBJS)
@$(AR) -r $@ $^
@echo
@echo CrashCatcher: Done!
pass: $(BUILDDIR)
@echo $(foreach f,$(IINCDIR),"$(f);") > $(BUILDDIR)/include_dirs