-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile
50 lines (39 loc) · 1.21 KB
/
Makefile
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
# compiler settings
ifeq ($(origin CC), default)
CC = $(CROSS_COMPILE)gcc
endif
CFLAGS = -Wall -g -I./include -I./include/RAM_Routines/write_erase -I./include/RAM_Routines/verify_CRC32
#CFLAGS += -DDEBUG # activate stm8gal debug output
#CFLAGS += -DMEMIMAGE_DEBUG # activate memory image debug output
#CFLAGS += -DMEMIMAGE_CHK_INCLUDE_ADDRESS # include addresses into CRC32 checksum
LFLAGS = -lm
# OS-dependent delete commands for 'make clean'
ifeq ($(OS),Windows_NT)
RM = cmd //C del //Q //F
RD = cmd //C rmdir //Q //S
else
RM = rm -f
RD = rm -fr
endif
# sources to compile
SRCDIR = ./src
SOURCES = $(notdir $(wildcard $(SRCDIR)/*.c))
OBJDIR = ./lib
OBJECTS := $(addprefix $(OBJDIR)/, $(SOURCES:.c=.o))
BIN = stm8gal
BINARGS = -v 3 -import output/test.s19 -export output/test.s19
all: $(OBJDIR) $(BIN)
# create directory for objects
$(OBJDIR):
mkdir -p $(OBJDIR)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
# $(CC) $(LFLAGS) $^ -o $@
$(BIN): $(OBJECTS)
$(CC) $(OBJECTS) $(LFLAGS) -o $@
clean:
$(RM) $(OBJDIR)/*
$(RM) -fr $(BIN)
$(RD) -fr .pio/*
memcheck:
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all -s ./$(BIN) $(BINARGS)