aboutsummaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-03-08 16:10:33 +0100
committerKarel Kočí <cynerd@email.cz>2016-03-08 16:10:33 +0100
commit5d29fe79d30f430ae326d9dc57ccfaed6fe61328 (patch)
tree8341804d561c0060176cbebc3f9a57c7c07f7816 /template
parent4e773191d447ac434536262a6f204dd991d4ad77 (diff)
downloadavr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.gz
avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.bz2
avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.zip
Another full update of current work
Diffstat (limited to 'template')
-rw-r--r--template/Makefile72
-rw-r--r--template/README.md9
l---------template/avr-ioe1
-rw-r--r--template/main.c5
4 files changed, 87 insertions, 0 deletions
diff --git a/template/Makefile b/template/Makefile
new file mode 100644
index 0000000..f67d0c2
--- /dev/null
+++ b/template/Makefile
@@ -0,0 +1,72 @@
+MAKEFLAGS += --no-builtin-rules
+# Change PROJNAME value to you project name
+# Care to not make any space at the end!
+PROJNAME = template
+
+# Add new source files to this variable
+SRC = main.c
+
+OBJ = $(patsubst %.c,%.o,$(SRC)) # This creates list of *.o files from *.c
+
+.PHONY: all
+ifneq ("$(wildcard .config)","") # Checking if configuration exists
+all: $(PROJNAME).hex
+ @echo Now you can flash $< to your chip.
+else
+all: help .config
+endif
+
+# Edit here help like you ever want
+.PHONY: help
+help:
+ @echo "This is avr-ioe template project"
+ @echo " all - Build project"
+ @echo " config - Start configuration program"
+ @echo " menuconfig - NCurses based configuration program"
+ @echo " help - Prints this text"
+ @echo " clean - Removing all object files generated from source files"
+
+.PHONY: clean
+clean:
+ @echo " CLEAN OBJ"
+ @$(RM) $(OBJ)
+ @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex"
+ @$(RM) $(PROJNAME).elf $(PROJNAME).hex
+ @$(MAKE) -C avr-ioe clean
+
+# Building targets are available only if configuration is generated
+ifneq ("$(wildcard .config)","")
+-include .config
+# If you want change some standard CFLAGS, change them in configuration not here.
+# Add here only options that should not be applied to avr-ioe also.
+CFLAGS = -Iavr-ioe/include -mmcu=$(MMCU) -imacros avr-ioe/.config.h \
+ $(shell echo $(CONFCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L)
+
+$(PROJNAME).elf: avr-ioe/libioe.a
+$(PROJNAME).elf: $(OBJ)
+ @echo " LD $@"
+ @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -Lavr-ioe -lioe
+
+$(PROJNAME).hex: $(PROJNAME).elf
+ @echo " OBJCOPY $@"
+ @avr-objcopy -O ihex -R .eeprom $< $@
+
+$(OBJ): %.o: %.c avr-ioe/libioe.a
+ @echo " CC $@"
+ @avr-gcc $(CFLAGS) -c -o $@ $<
+
+avr-ioe/libioe.a: .config
+ @CONFIG=$$(readlink -f .config) $(MAKE) -C avr-ioe libioe.a
+endif
+
+.config:
+ @echo Please generate configuration first using config or menuconfig target
+ @exit 1
+
+.PHONY: config
+config:
+ @CONFIG=$$(readlink -f .config) $(MAKE) -C avr-ioe menuconfig
+
+.PHONY: menuconfig
+menuconfig:
+ @CONFIG=$$(readlink -f .config) $(MAKE) -C avr-ioe menuconfig
diff --git a/template/README.md b/template/README.md
new file mode 100644
index 0000000..bdafb7f
--- /dev/null
+++ b/template/README.md
@@ -0,0 +1,9 @@
+AVR-IOE template project
+========================
+Use can use this as template for our project. Just move it where you want it and
+change symbolic link to avr-ioe. Or if you are going to use git, just remove
+symbolic link and add avr-ioe as submodule.
+
+In Makefile you can change project name and add or change source files.
+
+To configure avr-ioe just run `make menuconfig` in this folder.
diff --git a/template/avr-ioe b/template/avr-ioe
new file mode 120000
index 0000000..a96aa0e
--- /dev/null
+++ b/template/avr-ioe
@@ -0,0 +1 @@
+.. \ No newline at end of file
diff --git a/template/main.c b/template/main.c
new file mode 100644
index 0000000..90bb878
--- /dev/null
+++ b/template/main.c
@@ -0,0 +1,5 @@
+#include <avr-ioe.h>
+
+int main() {
+ return 0;
+};