From 5d29fe79d30f430ae326d9dc57ccfaed6fe61328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 8 Mar 2016 16:10:33 +0100 Subject: Another full update of current work --- template/Makefile | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ template/README.md | 9 +++++++ template/avr-ioe | 1 + template/main.c | 5 ++++ 4 files changed, 87 insertions(+) create mode 100644 template/Makefile create mode 100644 template/README.md create mode 120000 template/avr-ioe create mode 100644 template/main.c (limited to 'template') 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 + +int main() { + return 0; +}; -- cgit v1.2.3