aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2014-04-08 13:18:27 +0200
committerJakob Odersky <jodersky@gmail.com>2014-04-08 14:57:10 +0200
commit350437ef4b8ba0811d285f7454d2b54ffce6b029 (patch)
tree5084c73adbb4cc3aee9d000b3816d98a57203f36 /Makefile
parentc4ebb91caf33ecf5a47785584a4231eb1e4dfa2a (diff)
downloadmux-350437ef4b8ba0811d285f7454d2b54ffce6b029.tar.gz
mux-350437ef4b8ba0811d285f7454d2b54ffce6b029.tar.bz2
mux-350437ef4b8ba0811d285f7454d2b54ffce6b029.zip
change build structure
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile61
1 files changed, 40 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 17cb279..49c728e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,36 @@
# CPU model
+#
MCU=atmega2560
+
# CPU Frequency
+#
F_CPU=16000000L
-# Name of image to produce (can be arbitrary)
-TARGET=firmware
+# App
+#
+APP?=shell
+include apps/$(APP)/app.mk
+
+
+# Hardware modules
+#
+MODULES?=
+
# Serial port used for uploading
+#
SERIAL=/dev/ttyACM0
BAUD=115200
-# Modules to include in kernel
-MODULES=bug collection task tshield time io
+
+# Name of image to produce (can be arbitrary)
+#
+TARGET=firmware
+
# Toolchain flags
+#
CC=avr-gcc
CFLAGS= -std=gnu99 -O2 -Wall -finline-functions -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -mmcu=$(MCU) -DF_CPU=$(F_CPU)
LD=avr-gcc
@@ -32,23 +48,28 @@ CPPFLAGS= -O2 -Wall -fno-exceptions -ffunction-sections -fdata-sections -funsign
GDBINITFILE=gdb.conf
# Derived variables
+SOURCEDIRS=\
+ kernel \
+ kernel/io \
+ kernel/sched \
+ kernel/mcu/$(MCU) \
+ $(foreach module,$(MODULES),modules/$(module)) \
+ $(foreach module,$(MODULES),modules/$(module)/mcu/$(MCU)) \
+ apps/$(APP)
+
+INCLUDES=\
+ kernel/include \
+ kernel/mcu/$(MCU)/include \
+ $(foreach module,$(MODULES),modules/$(module)/include)
+
SOURCES=\
- $(foreach module,$(MODULES),$(wildcard kernel/$(module)/*.c)) \
- $(foreach module,$(MODULES),$(wildcard kernel/$(module)/mcu/$(MCU)/*.S)) \
- $(foreach module,$(MODULES),$(wildcard kernel/$(module)/mcu/$(MCU)/*.c)) \
- $(wildcard arduino/*.s) $(wildcard arduino/*.c) $(wildcard arduino/*.cpp) \
- $(wildcard *.s) $(wildcard *.c) $(wildcard *.cpp)
+ $(foreach dir,$(SOURCEDIRS),$(wildcard $(dir)/*.c)) \
+ $(foreach dir,$(SOURCEDIRS),$(wildcard $(dir)/*.S))
OBJECTS=$(addsuffix .o, $(basename $(SOURCES)))
-INCLUDES=\
- $(foreach module, $(MODULES), kernel/$(module)/include) \
- $(foreach module, $(MODULES), kernel/$(module)/mcu/$(MCU)/include)
-
# Rules
-all: target
-
-target: $(TARGET).hex
+all: $(TARGET).hex
$(TARGET).hex: $(TARGET).elf
$(OC) $(OCFLAGS) $< $@
@@ -92,11 +113,9 @@ cycle:
clean:
@rm -f *.o
- @for module in $(MODULES); do \
- rm -f kernel/$$module/*.o; \
- rm -f kernel/$$module/mcu/$(MCU)/*.o; \
+ @for dir in $(SOURCEDIRS); do \
+ rm -f $$dir/*.o; \
done
- @rm -f arduino/*.o
@rm -f $(TARGET).hex
@rm -f $(TARGET).elf
@rm -f $(GDBINITFILE)
@@ -120,4 +139,4 @@ $(GDBINITFILE): $(TARGET).elf
@echo "Use 'avr-gdb -x $(GDBINITFILE)'"
-.PHONY: clean cycle
+.PHONY: clean cycle target