DRY: Reduce duplication in platform Makefiles
Move builds for non-avr target (simulator) into a $(BUILD_FLAVOR)
build subdir (build/sim) to isolate it more completely and
cleanly from the AVR builds. This allows AVR and SIM to use common
build rules again.
Move newly bits out of Makefile-{SIM,AVR} and into Makefile-common.
This commit is contained in:
parent
917d879d03
commit
e4cfffee42
|
|
@ -127,6 +127,7 @@ CFLAGS += -Os
|
|||
CFLAGS += -ffunction-sections
|
||||
CFLAGS += -finline-functions-called-once
|
||||
CFLAGS += -mcall-prologues
|
||||
CFLAGS += -Wa,-adhlns=$(@:.o=.al)
|
||||
|
||||
LDFLAGS = -Wl,--as-needed
|
||||
|
||||
|
|
@ -141,8 +142,6 @@ endif
|
|||
|
||||
LIBS = -lm
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
||||
|
||||
-include Makefile-common
|
||||
|
||||
# Architecture specific targets
|
||||
|
|
|
|||
12
Makefile-SIM
12
Makefile-SIM
|
|
@ -35,6 +35,7 @@
|
|||
TARGET = sim
|
||||
|
||||
SIM_PATH = simulator
|
||||
BUILD_FLAVOR = $(TARGET)
|
||||
|
||||
# Arduino IDE takes the "compile everything available"-approach, so we have
|
||||
# to keep this working and can take a shortcut:
|
||||
|
|
@ -43,7 +44,6 @@ SOURCES = $(wildcard *.c)
|
|||
SIM_SOURCES = $(subst $(SIM_PATH)/,,$(wildcard $(SIM_PATH)/*.c))
|
||||
SOURCES := $(filter-out $(subst _sim.c,.c,$(SIM_SOURCES)),$(SOURCES)) $(SIM_SOURCES)
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.sim.o,$(SOURCES))
|
||||
CFLAGS += -g -Wall -Wstrict-prototypes -Wno-format -Os $(DEFS) -std=gnu99
|
||||
CFLAGS += -funsigned-char -funsigned-bitfields -fshort-enums -I.. -I.
|
||||
CFLAGS += -DSIMULATOR
|
||||
|
|
@ -55,13 +55,7 @@ CFLAGS += -D__AVR_ATmega1280__
|
|||
|
||||
include Makefile-common
|
||||
|
||||
$(BUILDDIR)/%.sim.o: %.c | $(BUILDDIR)
|
||||
@echo " CC $@"
|
||||
@cc -c $(CFLAGS) -MMD -o $@ $<
|
||||
@$(call CCPOST)
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
@echo " LINK $@"
|
||||
@cc $(CFLAGS) -o $@ $^
|
||||
$(TARGET): $(BUILDDIR)/$(TARGET).elf
|
||||
cp $< $@
|
||||
|
||||
vpath %.c $(SIM_PATH)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@
|
|||
BUILDDIR = build
|
||||
USER_CONFIG ?= config.h
|
||||
|
||||
ifdef BUILD_FLAVOR
|
||||
BUILDDIR := $(BUILDDIR)/$(BUILD_FLAVOR)
|
||||
endif
|
||||
|
||||
ifneq ($(USER_CONFIG),config.h)
|
||||
BUILDDIR := $(BUILDDIR)/$(USER_CONFIG:.h=)
|
||||
endif
|
||||
|
|
@ -45,6 +49,8 @@ OBJDUMP = $(TOOLCHAIN)objdump
|
|||
OBJCOPY = $(TOOLCHAIN)objcopy
|
||||
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
||||
|
||||
.PHONY: all clean doc functionsbysize
|
||||
.PRECIOUS: %.o %.elf
|
||||
|
||||
|
|
@ -79,7 +85,7 @@ endef
|
|||
|
||||
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
|
||||
@echo " CC $@"
|
||||
@$(CC) -c $(CFLAGS) -MMD -Wa,-adhlns=$(@:.o=.al) -o $@ $<
|
||||
@$(CC) -c $(CFLAGS) -MMD -o $@ $<
|
||||
@$(call CCPOST)
|
||||
|
||||
$(BUILDDIR)/%.elf: $(OBJ)
|
||||
|
|
|
|||
Loading…
Reference in New Issue