From 1fd366764d17874b8211ef63d41313995833e36d Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Fri, 14 Jul 2023 11:17:59 -0500 Subject: The start-ish of it all. --- controller/Makefile | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 controller/Makefile (limited to 'controller/Makefile') 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 -- cgit v1.2.3