summaryrefslogtreecommitdiff
path: root/include.mk
diff options
context:
space:
mode:
Diffstat (limited to 'include.mk')
-rw-r--r--include.mk159
1 files changed, 29 insertions, 130 deletions
diff --git a/include.mk b/include.mk
index 3f03342..9b02076 100644
--- a/include.mk
+++ b/include.mk
@@ -20,148 +20,48 @@
## along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
##
-ifeq ($(BOARD_TYPE),teensy1)
- MCU := at90usb162
- F_CPU := 16000000
- PROG := teensy
-endif
-ifeq ($(BOARD_TYPE),teensy2)
- MCU := atmega32u4
- F_CPU := 16000000
- PROG := teensy
-endif
-ifeq ($(BOARD_TYPE),teensy1pp)
- MCU := at90usb646
- F_CPU := 16000000
- PROG := teensy
-endif
-ifeq ($(BOARD_TYPE),teensy2pp)
- MCU := at90usb1286
- F_CPU := 16000000
- PROG := teensy
-endif
-ifeq ($(BOARD_TYPE),hhd70dongle)
- MCU := atmega32u4
- F_CPU := 16000000
- PROG := DFU
-endif
-ifeq ($(BOARD_TYPE),arduinoUno)
- MCU := atmega328p
- F_CPU := 16000000
- PROG := avrdude
- UPLOAD_RATE := 57600
- PROG_TYPE := stk500v1
- AVRDUDE_PORT := /dev/ttyUSB0
- RESET_FUNC := ../tools/reset_arduino
- RESET_PARAM = $(AVRDUDE_PORT)
-endif
-ifeq ($(BOARD_TYPE),arduino2009v2)
- MCU := atmega328p
- F_CPU := 16000000
- PROG := avrdude
- UPLOAD_RATE := 57600
- PROG_TYPE := stk500v1
- AVRDUDE_PORT := /dev/ttyUSB0
- RESET_FUNC := ../tools/reset_arduino
- RESET_PARAM = $(AVRDUDE_PORT)
-endif
-ifeq ($(BOARD_TYPE),arduino2009)
- MCU := atmega168
- F_CPU := 16000000
- PROG := avrdude
- UPLOAD_RATE := 19200
- PROG_TYPE := stk500v1
- AVRDUDE_PORT := /dev/ttyUSB0
- RESET_FUNC := ../tools/reset_arduino
- RESET_PARAM = $(AVRDUDE_PORT)
-endif
-ifeq ($(BOARD_TYPE),arduino10000)
- MCU := atmega168
- F_CPU := 16000000
- PROG := avrdude
- UPLOAD_RATE := 19200
- PROG_TYPE := stk500v1
- AVRDUDE_PORT := /dev/ttyUSB0
- RESET_FUNC := ../tools/reset_arduino
- RESET_PARAM = $(AVRDUDE_PORT)
-endif
-ifeq ($(BOARD_TYPE),arduinoNG)
- MCU := atmega8
- F_CPU := 16000000
- PROG := avrdude
- UPLOAD_RATE := 19200
- PROG_TYPE := stk500v1
- AVRDUDE_PORT := /dev/ttyUSB0
- RESET_FUNC := ../tools/dummy_reset
-endif
-ifeq ($(BOARD_TYPE),AvrNetIo)
- MCU := atmega32
- F_CPU := 16000000
- PROG := avrdude
- UPLOAD_RATE := 19200
- PROG_TYPE := stk500v2
- AVRDUDE_PORT := /dev/ttyS0
-endif
-
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-LIB_DIR = ../lib
+include ../defines.mk
-DFU = dfu-programmer
-teensy = teensy_loader_cli
-avrdude = avrdude
-
-## external libs
-EXTERNAL_LIBS :=
-
-LUFA_STAMP = .lufa_stamp
-ifdef LUFA_DIR
-EXTERNAL_LIBS += prepare-lufa
-endif
-
-## Options common to compile, link and assembly rules
-COMMON = -mmcu=$(MCU)
-
-## Compile options common for all C compilation units.
-CFLAGS = $(COMMON)
-CFLAGS += -O2
-CFLAGS += -funsigned-char
-CFLAGS += -funsigned-bitfields
-CFLAGS += -ffunction-sections
-CFLAGS += -fpack-struct
-CFLAGS += -fshort-enums
-CFLAGS += -Wall
-CFLAGS += -Wstrict-prototypes
-CFLAGS += -I$(LIB_DIR)
-CFLAGS += -DF_CPU=$(F_CPU)UL
-CFLAGS += -D__BOARD_$(BOARD_TYPE)__
-
-## Linker flags
-LDFLAGS = $(COMMON)
-LDFLAGS +=
+LDFLAGS += -L./
+## project-specific objects
SRC := $(OBJ:%.o=%.c)
-
+DEP := $(SRC:%.c=%.d)
OBJ_LIB := $(LIBS:%=lib-%.o)
SRC_LIB := $(LIBS:%=$(LIB_DIR)/%.c)
DEP_LIB := $(LIBS:%=lib-%.d)
-.PHONY: prepare clean program erase flash reset run
+.PHONY: prepare clean clean-external clean-lufa program erase flash reset run
ELFFILE := $(NAME).elf
HEXFILE := $(NAME).hex
all: prepare $(HEXFILE)
-prepare: $(EXTERNAL_LIBS)
-prepare-lufa: $(LUFA_STAMP)
-$(LUFA_STAMP):
- @echo "preparing external LUFA lib ($(LUFA_DIR))"
- @echo " --- TODO ---"
-## call LUFA build
- @touch $@
+
+## external Libs
+ifndef LUFA_PATH
+LUFA_PATH := ../contrib/LUFA
+endif
+
+prepare: $(EXTERNAL_LIBS:%=build-%)
+clean-external: $(EXTERNAL_LIBS:%=clean-%)
+
+export
+build-lufa: liblufa.a
+
+liblufa.a:
+ @echo "building external LUFA lib ($(LUFA_PATH))"
+ make -f ../lufa.mk liblufa.a
+ make -f ../lufa.mk clean
+
+clean-lufa:
+ @echo "cleaning external LUFA lib ($(LUFA_PATH))"
+ make -f ../lufa.mk clean
+ @rm -f liblufa.a
+## project-specific objects
lib-%.d: $(LIB_DIR)/%.c
@set -e; rm -f $@; \
$(CC) -MM $(CFLAGS) $< > $@.$$$$; \
@@ -175,7 +75,7 @@ lib-%.d: $(LIB_DIR)/%.c
rm -f $@.$$$$; echo '(re)building $@'
ifneq ($(MAKECMDGOALS),clean)
--include $(SRC:%.c=%.d)
+-include $(DEP)
-include $(DEP_LIB)
endif
@@ -186,13 +86,12 @@ lib-%.o: $(LIB_DIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
$(ELFFILE): $(OBJ) $(OBJ_LIB)
- $(CC) $(LDFLAGS) $(OBJ) $(OBJ_LIB) -o $@
+ $(CC) $(LDFLAGS) $(OBJ) $(OBJ_LIB) $(EXTERNAL_LIBS:%=-l%) -o $@
$(HEXFILE): $(ELFFILE)
$(OBJCOPY) -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
clean:
- rm -f .*_stamp
rm -f *.o
rm -f *.d
rm -f *.d.*