rusefi-full/win32_functional_tests/rules.mk

167 lines
4.1 KiB
Makefile
Raw Normal View History

2015-07-10 06:01:56 -07:00
# ARM Cortex-Mx common makefile scripts and rules.
2017-03-23 17:59:14 -07:00
##############################################################################
# Processing options coming from the upper Makefile.
#
# Compiler options
OPT := $(USE_OPT)
COPT := $(USE_COPT)
CPPOPT := $(USE_CPPOPT)
# Garbage collection
ifeq ($(USE_LINK_GC),yes)
OPT += -ffunction-sections -fdata-sections -fno-common
LDOPT := ,--gc-sections
else
LDOPT :=
2015-07-10 06:01:56 -07:00
endif
2017-03-23 17:59:14 -07:00
# Linker extra options
ifneq ($(USE_LDOPT),)
LDOPT := $(LDOPT),$(USE_LDOPT)
2015-07-10 06:01:56 -07:00
endif
2017-03-23 17:59:14 -07:00
# Link time optimizations
ifeq ($(USE_LTO),yes)
OPT += -flto
2015-07-10 06:01:56 -07:00
endif
2017-03-23 17:59:14 -07:00
# Process stack size
ifeq ($(USE_PROCESS_STACKSIZE),)
LDOPT := $(LDOPT),--defsym=__process_stack_size__=0x400
2015-07-10 06:01:56 -07:00
else
2017-03-23 17:59:14 -07:00
LDOPT := $(LDOPT),--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE)
2015-07-10 06:01:56 -07:00
endif
2017-03-23 17:59:14 -07:00
# Exceptions stack size
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
LDOPT := $(LDOPT),--defsym=__main_stack_size__=0x400
else
LDOPT := $(LDOPT),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE)
endif
BUILDDIR = build
OUTFILES := $(BUILDDIR)/$(PROJECT).exe
SRCPATHS := $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(CSRC)) $(dir $(CPPSRC)))
2015-07-10 06:01:56 -07:00
# Various directories
2017-03-23 17:59:14 -07:00
OBJDIR := $(BUILDDIR)/obj
LSTDIR := $(BUILDDIR)/lst
2015-07-10 06:01:56 -07:00
# Object files groups
2017-03-23 17:59:14 -07:00
COBJS := $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o)))
CPPOBJS := $(addprefix $(OBJDIR)/, $(notdir $(CPPSRC:.cpp=.o)))
ASMOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
ASMXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
OBJS := $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS)
2015-07-10 06:01:56 -07:00
# Paths
2017-03-23 17:59:14 -07:00
IINCDIR := $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
LLIBDIR := $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
2015-07-10 06:01:56 -07:00
# Macros
2017-03-23 17:59:14 -07:00
DEFS := $(DDEFS) $(UDEFS)
ADEFS := $(DADEFS) $(UADEFS)
2015-07-10 06:01:56 -07:00
# Libs
2017-03-23 17:59:14 -07:00
LIBS := $(DLIBS) $(ULIBS)
2015-07-10 06:01:56 -07:00
# Various settings
2017-03-23 17:59:14 -07:00
MCFLAGS =
2015-07-10 06:01:56 -07:00
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)
2017-03-29 10:48:17 -07:00
LDFLAGS = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch$(LDOPT)
2015-07-10 06:01:56 -07:00
# Generate dependency information
2017-03-23 17:59:14 -07:00
ASFLAGS += -MD -MP -MF .dep/$(@F).d
ASXFLAGS += -MD -MP -MF .dep/$(@F).d
2015-07-10 06:01:56 -07:00
CFLAGS += -MD -MP -MF .dep/$(@F).d
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
# Paths where to search for sources
VPATH = $(SRCPATHS)
#
# Makefile rules
#
2017-03-23 17:59:14 -07:00
all: $(OBJS) $(OUTFILES)
2015-07-10 06:01:56 -07:00
2017-03-23 17:59:14 -07:00
$(OBJS): $(BUILDDIR) $(OBJDIR) $(LSTDIR)
2015-07-10 06:01:56 -07:00
2017-03-23 17:59:14 -07:00
$(BUILDDIR):
2015-07-10 06:01:56 -07:00
ifneq ($(USE_VERBOSE_COMPILE),yes)
@echo Compiler Options
2017-03-23 17:59:14 -07:00
@echo $(CC) -c $(CFLAGS) -I. $(IINCDIR) main.c -o main.o
2015-07-10 06:01:56 -07:00
@echo
endif
2017-03-23 17:59:14 -07:00
@mkdir -p $(BUILDDIR)
2015-07-10 06:01:56 -07:00
2017-03-23 17:59:14 -07:00
$(OBJDIR):
@mkdir -p $(OBJDIR)
2015-07-10 06:01:56 -07:00
2017-03-23 17:59:14 -07:00
$(LSTDIR):
@mkdir -p $(LSTDIR)
2015-07-10 06:01:56 -07:00
2017-03-23 17:59:14 -07:00
$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
2015-07-10 06:01:56 -07:00
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
2017-03-23 17:59:14 -07:00
$(CPPC) -c $(CPPFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
2015-07-10 06:01:56 -07:00
else
@echo Compiling $(<F)
2017-03-23 17:59:14 -07:00
@$(CPPC) -c $(CPPFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
2015-07-10 06:01:56 -07:00
endif
2017-03-23 17:59:14 -07:00
$(COBJS) : $(OBJDIR)/%.o : %.c Makefile
2015-07-10 06:01:56 -07:00
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
2017-03-23 17:59:14 -07:00
$(CC) -c $(CFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
2015-07-10 06:01:56 -07:00
else
@echo Compiling $(<F)
2017-03-23 17:59:14 -07:00
@$(CC) -c $(CFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
2015-07-10 06:01:56 -07:00
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)
2017-03-23 17:59:14 -07:00
@echo
2015-07-10 06:01:56 -07:00
$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
else
@echo Compiling $(<F)
@$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif
2017-03-23 17:59:14 -07:00
$(BUILDDIR)/$(PROJECT).exe: $(OBJS) $(LDSCRIPT)
2015-07-10 06:01:56 -07:00
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)
2017-03-23 17:59:14 -07:00
@echo
2015-07-10 06:01:56 -07:00
@echo Done
#
# Include the dependency files, should be the last of the makefile
#
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# *** EOF ***