make Makefile-{SIM,AVR,common} more generic
Allow stock makefile variables to be overridden by 'make' caller so the user's 'Makefile' can be authoritative. See Makefile-example for usage.
This commit is contained in:
parent
21e5343552
commit
11d7227d2c
24
Makefile-AVR
24
Makefile-AVR
|
|
@ -40,17 +40,17 @@
|
|||
# #
|
||||
##############################################################################
|
||||
|
||||
# MCU_TARGET = atmega168
|
||||
# MCU_TARGET = atmega328p
|
||||
MCU_TARGET = atmega644p
|
||||
# MCU_TARGET = atmega1280
|
||||
# MCU_TARGET = atmega2560
|
||||
# MCU_TARGET = at90usb1287
|
||||
# MCU_TARGET = atmega32u4
|
||||
# MCU_TARGET ?= atmega168
|
||||
# MCU_TARGET ?= atmega328p
|
||||
MCU_TARGET ?= atmega644p
|
||||
# MCU_TARGET ?= atmega1280
|
||||
# MCU_TARGET ?= atmega2560
|
||||
# MCU_TARGET ?= at90usb1287
|
||||
# MCU_TARGET ?= atmega32u4
|
||||
|
||||
# CPU clock rate
|
||||
F_CPU = 16000000L
|
||||
# F_CPU = 8000000L
|
||||
F_CPU ?= 16000000L
|
||||
# F_CPU ?= 8000000L
|
||||
|
||||
##############################################################################
|
||||
# #
|
||||
|
|
@ -79,9 +79,10 @@ TOOLCHAIN = avr-
|
|||
# -P <port> Serial port the electronics is connected to.
|
||||
# -C <config file> Optional, default is /etc/avrdude.conf.
|
||||
|
||||
UPLOADER = avrdude
|
||||
UPLOADER ?= avrdude
|
||||
# UPLOADER = <path-to-arduino-folder>/hardware/tools/avrdude
|
||||
|
||||
ifndef UPLOADER_FLAGS
|
||||
UPLOADER_FLAGS = -c stk500v2
|
||||
# UPLOADER_FLAGS += -b 19200
|
||||
# UPLOADER_FLAGS += -b 57600
|
||||
|
|
@ -91,6 +92,7 @@ UPLOADER_FLAGS += -p $(MCU_TARGET)
|
|||
# UPLOADER_FLAGS += -P /dev/ttyACM0
|
||||
UPLOADER_FLAGS += -P /dev/ttyUSB0
|
||||
# UPLOADER_FLAGS += -C <path-to-arduino-folder>/hardware/tools/avrdude.conf
|
||||
endif
|
||||
|
||||
|
||||
##############################################################################
|
||||
|
|
@ -108,7 +110,7 @@ TARGET = $(PROGRAM).hex
|
|||
# to keep this working and can take a shortcut:
|
||||
SOURCES = $(wildcard *.c)
|
||||
|
||||
CFLAGS = -DF_CPU=$(F_CPU)
|
||||
CFLAGS += -DF_CPU=$(F_CPU)
|
||||
CFLAGS += -mmcu=$(MCU_TARGET)
|
||||
CFLAGS += -g
|
||||
CFLAGS += -Wall
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ 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 += -g -Wall -Wstrict-prototypes -Wno-format -Os $(DEFS) -std=gnu99
|
||||
CFLAGS += -funsigned-char -funsigned-bitfields -fshort-enums -I.. -I.
|
||||
CFLAGS += -DSIMULATOR
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
################################################################################
|
||||
#
|
||||
## Example Makefile
|
||||
#
|
||||
# For convenience, copy this file to "Makefile" and customize it to fit your
|
||||
# needs.
|
||||
#
|
||||
# Then you can type 'make avr' or simply 'make' to build for your printer.
|
||||
#
|
||||
################################################################################
|
||||
.PHONY: sim avr clean all default
|
||||
|
||||
# Override variables in the stock makefiles
|
||||
export F_CPU = 20000000L
|
||||
export MCU_TARGET = atmega644p
|
||||
|
||||
default: avr
|
||||
|
||||
all: sim avr
|
||||
|
||||
# Build the simulator
|
||||
sim:
|
||||
@echo "----[ Simulator ]----"
|
||||
@make -sf Makefile-SIM
|
||||
|
||||
# Build Teacup for an Atmel processor
|
||||
avr:
|
||||
@echo "----[ $(MCU_TARGET) ]----"
|
||||
@make -sf Makefile-AVR
|
||||
|
||||
clean:
|
||||
@echo "----[ Clean ]----"
|
||||
@make -sf Makefile-SIM clean
|
||||
@make -sf Makefile-AVR clean
|
||||
# Add any more cleanup steps you want here. Example,
|
||||
# rm -f *.png
|
||||
Loading…
Reference in New Issue