-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
executable file
·64 lines (45 loc) · 1.74 KB
/
makefile
File metadata and controls
executable file
·64 lines (45 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
###############################################################################
.PHONY: all build clean
CCDIR = ../../../tools/bin
CORE = -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard
OPTIMIZATION = -O0 -g0
DEFINITIONS =
###############################################################################
OUTDIR := build
LIBNAME := $(notdir $(shell pwd))
DIRS := $(shell ls -R . | grep : | sed 's/://')
ASSOURCES := $(wildcard $(addsuffix /*.s, $(DIRS)))
CSOURCES := $(wildcard $(addsuffix /*.c, $(DIRS)))
OBJECTS := $(addprefix $(OUTDIR)/, $(ASSOURCES:.s=.o))
OBJECTS += $(addprefix $(OUTDIR)/, $(CSOURCES:.c=.o))
HEADERS := $(addprefix -I", $(addsuffix ", $(DIRS)))
###############################################################################
AR = $(CCDIR)/arm-none-eabi-ar
CC = $(CCDIR)/arm-none-eabi-gcc
CXX = $(CCDIR)/arm-none-eabi-g++
SIZE = $(CCDIR)/arm-none-eabi-size
ASFLAGS = $(CORE) -x assembler-with-cpp
CFLAGS = -std=gnu17 $(CORE) $(OPTIMIZATION) $(DEFINITIONS) $(HEADERS) \
-ffunction-sections -fdata-sections -fcyclomatic-complexity \
--specs=nano.specs -Wall -Wextra
###############################################################################
all: build
build: $(OUTDIR)/$(LIBNAME).a \
$(OUTDIR)/$(LIBNAME).siz
$(OUTDIR)/$(LIBNAME).a: $(OBJECTS)
@echo arc: $(@F)
@mkdir -p $(@D)
@$(AR) rc $@ $^
$(OUTDIR)/$(LIBNAME).siz: $(OUTDIR)/$(LIBNAME).a
@$(SIZE) --format=berkeley $(OUTDIR)/$(LIBNAME).a
$(OUTDIR)/%.o: %.s
@echo gcc: $(@F)
@mkdir -p $(@D)
@$(CC) -c $(ASFLAGS) '$<' -o '$@'
$(OUTDIR)/%.o: %.c
@echo gcc: $(@F)
@mkdir -p $(@D)
@$(CC) -c $(CFLAGS) '$<' -o '$@'
clean:
rm -rf $(OUTDIR)
###############################################################################