Add preprocessing step
This commit is contained in:
43
Makefile
Normal file
43
Makefile
Normal file
@@ -0,0 +1,43 @@
|
||||
CC = arm-none-eabi-gcc
|
||||
|
||||
CFLAGS = -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||
CFLAGS += -Wall -Werror -Wpedantic -Wextra
|
||||
# Remove unused code and data; https://gcc.gnu.org/onlinedocs/gnat_ugn/Compilation-options.html
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
# Don't include memcpy
|
||||
CFLAGS += -fno-builtin
|
||||
# "-fno-common ... specifies that the compiler places uninitialized global variables in the BSS section of the object file."
|
||||
CFLAGS += -fno-common
|
||||
|
||||
DEBUG ?= 1
|
||||
ifeq ($(DEBUG), 0)
|
||||
# Optimize for size
|
||||
CFLAGS += -Os
|
||||
else
|
||||
CFLAGS += -O0 -g3 -ggdb
|
||||
endif
|
||||
|
||||
LDFLAGS = -T link.ld -nostartfiles -nostdlib --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map
|
||||
|
||||
SRC_DIR = src
|
||||
BUILD_DIR = build
|
||||
|
||||
SRC_FILES := $(wildcard $(SRC_DIR)/*.c)
|
||||
PREP_FILES := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.i,$(SRC_FILES))
|
||||
|
||||
.PHONY: build
|
||||
build: builddir preprocess
|
||||
|
||||
$(BUILD_DIR)/%.i: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) -E $^ -o $@
|
||||
|
||||
.PHONY: builddir
|
||||
builddir:
|
||||
mkdir $(BUILD_DIR)
|
||||
|
||||
.PHONY: preprocess
|
||||
preprocess: $(PREP_FILES)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
Reference in New Issue
Block a user