diff --git a/Makefile-AVR b/Makefile-AVR index e232dc3..f46f7df 100644 --- a/Makefile-AVR +++ b/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 Serial port the electronics is connected to. # -C Optional, default is /etc/avrdude.conf. -UPLOADER = avrdude +UPLOADER ?= avrdude # UPLOADER = /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 /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 diff --git a/Makefile-SIM b/Makefile-SIM index 89c1711..a61c1d9 100644 --- a/Makefile-SIM +++ b/Makefile-SIM @@ -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 diff --git a/Makefile-example b/Makefile-example new file mode 100644 index 0000000..4baeb80 --- /dev/null +++ b/Makefile-example @@ -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