summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include.mk94
1 files changed, 94 insertions, 0 deletions
diff --git a/include.mk b/include.mk
new file mode 100644
index 0000000..2efc96e
--- /dev/null
+++ b/include.mk
@@ -0,0 +1,94 @@
+##
+## spreadspace teensy utils
+##
+##
+## Copyright (C) 2011 Christian Pointner <equinox@spreadspace.org>
+##
+## This file is part of spreadspace teensy utils.
+##
+## spreadspace teensy utils is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## any later version.
+##
+## spreadspace teensy utils is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with spreadspace teensy utils. If not, see <http://www.gnu.org/licenses/>.
+##
+
+#NAME :=
+#OBJ :=
+#BOARD_TYPE :=
+
+ifeq ($(BOARD_TYPE),teensy1)
+MCU := at90usb162
+endif
+ifeq ($(BOARD_TYPE),teensy2)
+MCU := atmega32u4
+endif
+ifeq ($(BOARD_TYPE),teensypp1)
+MCU := at90usb646
+endif
+ifeq ($(BOARD_TYPE),teensypp2)
+MCU := at90usb1286
+endif
+FORMAT := ihex
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+AR = avr-ar rcs
+NM = avr-nm
+COPY = cp
+
+
+SRC := $(OBJ:%.o=%.c)
+
+.PHONY: clean cleanall distclean program
+
+ELFFILE := $(NAME).elf
+
+all: $(ELFFILE)
+
+%.d: %.c
+ @set -e; rm -f $@; \
+ $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$; echo '(re)building $@'
+
+ifneq ($(MAKECMDGOALS),distclean)
+-include $(SRC:%.c=%.d)
+endif
+
+$(ELFFILE): $(OBJ)
+ $(CC) $(OBJ) -o $@ $(LDFLAGS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c $<
+
+
+strip: $(ELFFILE)
+ $(STRIP) -s $(ELFFILE)
+
+distclean: cleanall
+ find . -name *.o -exec rm -f {} \;
+ find . -name "*.\~*" -exec rm -rf {} \;
+ rm -f include.mk
+ rm -f version.h
+ rm -f tun.c
+
+clean:
+ rm -f *.o
+ rm -f *.d
+ rm -f *.d.*
+ rm -f $(ELFFILE)
+
+program: $(ELFFILE)
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $(ELFFILE:%.elf=%.hex)
+ teensy_loader_cli -mmcu=$(MCU) -w -v $@
+