summaryrefslogtreecommitdiff
path: root/controller/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'controller/Makefile')
-rw-r--r--controller/Makefile62
1 files changed, 62 insertions, 0 deletions
diff --git a/controller/Makefile b/controller/Makefile
new file mode 100644
index 0000000..fef034d
--- /dev/null
+++ b/controller/Makefile
@@ -0,0 +1,62 @@
+# A spec for using Tivaware's makefiles
+
+# Top-level concerns.
+PROJECT = controller
+MCU = TM4C123GH6PM
+
+# Utilities.
+CC = arm-none-eabi-gcc
+LD = arm-none-eabi-ld
+OBJCOPY = arm-none-eabi-objcopy
+RM = rm -rf
+MKDIR = @mkdir -p $(@D)
+
+# Custom/TI/build resource locations.
+SRCS = $(wildcard src/*.c) \
+ $(wildcard libs/*.c)
+OBJ = obj/
+OBJS = $(addprefix $(OBJ),$(notdir $(SRCS:.c=.o)))
+LD_SCRIPT = ld/$(MCU).ld
+IPATH = /home/dnw/Code/TivaC/libs
+
+# Flags.
+CFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections \
+ -fdata-sections -MD -std=c99 -Wall -pedantic -DPART_${MCU} -c -Os -Dgcc -ggdb
+CFLAGS += ${patsubst %,-I%,${subst :, ,${IPATH}}} -Iinc
+
+# Compiler/standard resource locations.
+LIBGCC := ${shell ${CC} ${CFLAGS} -print-libgcc-file-name}
+LIBC := ${shell ${CC} ${CFLAGS} -print-file-name=libc.a}
+LIBM := ${shell ${CC} ${CFLAGS} -print-file-name=libm.a}
+
+# More flags.
+LDFLAGS = -T $(LD_SCRIPT) -e Reset_Handler --gc-sections '${LIBGCC}' '${LIBC}' '${LIBM}'
+
+
+
+
+
+# Targets.
+all: bin/$(PROJECT).bin
+
+$(OBJ)%.o: src/%.c
+ $(MKDIR)
+ $(CC) -o $@ $^ $(CFLAGS)
+
+$(OBJ)%.o: libs/%.c
+ $(MKDIR)
+ $(CC) -o $@ $^ $(CFLAGS)
+
+$(info $$PROJECT is [${PROJECT}])
+bin/$(PROJECT).elf: $(OBJS)
+ $(MKDIR)
+ $(LD) -o $@ $^ $(LDFLAGS)
+
+bin/$(PROJECT).bin: bin/$(PROJECT).elf
+ $(OBJCOPY) -O binary $< $@
+
+clean:
+ -$(RM) obj
+ -$(RM) bin
+
+.PHONY: all clean