mirror of https://github.com/rusefi/rusefi-1.git
169 lines
4.3 KiB
Makefile
169 lines
4.3 KiB
Makefile
# ARM Cortex-Mx common makefile scripts and rules.
|
|
|
|
# Output directory and files
|
|
ifeq ($(BUILDDIR),)
|
|
BUILDDIR = build
|
|
endif
|
|
ifeq ($(BUILDDIR),.)
|
|
BUILDDIR = build
|
|
endif
|
|
OUTFILES = $(BUILDDIR)/$(PROJECT)
|
|
|
|
# Automatic compiler options
|
|
OPT = $(USE_OPT)
|
|
COPT = $(USE_COPT)
|
|
CPPOPT = $(USE_CPPOPT)
|
|
ifeq ($(USE_LINK_GC),yes)
|
|
OPT += -ffunction-sections -fdata-sections -fno-common
|
|
endif
|
|
|
|
# Source files groups and paths
|
|
ifeq ($(USE_THUMB),yes)
|
|
TCSRC += $(CSRC)
|
|
TCPPSRC += $(CPPSRC)
|
|
else
|
|
ACSRC += $(CSRC)
|
|
ACPPSRC += $(CPPSRC)
|
|
endif
|
|
ASRC = $(ACSRC)$(ACPPSRC)
|
|
TSRC = $(TCSRC)$(TCPPSRC)
|
|
SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))
|
|
|
|
# Various directories
|
|
OBJDIR = $(BUILDDIR)/obj
|
|
LSTDIR = $(BUILDDIR)/lst
|
|
|
|
# Object files groups
|
|
ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o)))
|
|
ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o)))
|
|
TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o)))
|
|
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)
|
|
|
|
# Paths
|
|
IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
|
|
LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
|
|
|
# Macros
|
|
DEFS = $(DDEFS) $(UDEFS)
|
|
ADEFS = $(DADEFS) $(UADEFS)
|
|
|
|
# Libs
|
|
LIBS = $(DLIBS) $(ULIBS)
|
|
|
|
# Various settings
|
|
#MCFLAGS = -mcpu=$(MCU)
|
|
ODFLAGS = -x --syms
|
|
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
|
|
ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
|
|
CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
|
|
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
|
|
ifeq ($(USE_LINK_GC),yes)
|
|
LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
|
|
else
|
|
LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
|
|
endif
|
|
|
|
# Generate dependency information
|
|
CFLAGS += -MD -MP -MF .dep/$(@F).d
|
|
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
|
|
|
|
# Paths where to search for sources
|
|
VPATH = $(SRCPATHS)
|
|
|
|
#
|
|
# Makefile rules
|
|
#
|
|
|
|
all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK
|
|
|
|
MAKE_ALL_RULE_HOOK:
|
|
|
|
$(OBJS): | $(BUILDDIR)
|
|
|
|
$(BUILDDIR) $(OBJDIR) $(LSTDIR):
|
|
ifneq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo Compiler Options
|
|
@echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o
|
|
@echo
|
|
endif
|
|
mkdir -p $(OBJDIR)
|
|
mkdir -p $(LSTDIR)
|
|
|
|
$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo
|
|
$(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
|
|
else
|
|
@echo Compiling $(<F)
|
|
@$(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
|
|
endif
|
|
|
|
$(TCPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo
|
|
$(CPPC) -c $(CPPFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
|
|
else
|
|
@echo Compiling $(<F)
|
|
@$(CPPC) -c $(CPPFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
|
|
endif
|
|
|
|
$(ACOBJS) : $(OBJDIR)/%.o : %.c Makefile
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo
|
|
$(CC) -c $(CFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
|
|
else
|
|
@echo Compiling $(<F)
|
|
@$(CC) -c $(CFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
|
|
endif
|
|
|
|
$(TCOBJS) : $(OBJDIR)/%.o : %.c Makefile
|
|
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 Makefile
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo
|
|
$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
|
|
else
|
|
@echo Compiling $(<F)
|
|
@$(AS) -c $(ASFLAGS) -I. $(IINCDIR) $< -o $@
|
|
endif
|
|
|
|
$(ASMXOBJS) : $(OBJDIR)/%.o : %.S Makefile
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo
|
|
$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
|
|
else
|
|
@echo Compiling $(<F)
|
|
@$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
|
|
endif
|
|
|
|
$(BUILDDIR)/$(PROJECT): $(OBJS)
|
|
ifeq ($(USE_VERBOSE_COMPILE),yes)
|
|
@echo
|
|
$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
|
else
|
|
@echo Linking $@
|
|
@$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
|
|
endif
|
|
|
|
clean:
|
|
@echo Cleaning
|
|
-rm -fR .dep $(BUILDDIR)
|
|
@echo Done
|
|
|
|
#
|
|
# Include the dependency files, should be the last of the makefile
|
|
#
|
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
|
|
|
# *** EOF ***
|