Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (68 loc) · 1.86 KB
/
Copy pathMakefile
File metadata and controls
80 lines (68 loc) · 1.86 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
SILENT = @
CC = gcc
AR = ar
# Compiler flags to help with better code quality
CFLAGS = -Wall -Wextra
# CFLAGS += -Wconversion
CFLAGS += -Wshadow
CFLAGS += -Wunsafe-loop-optimizations
CFLAGS += -Waddress
CFLAGS += -Wlogical-op
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wold-style-definition
CFLAGS += -Wmissing-prototypes
CFLAGS += -Wno-missing-braces
CFLAGS += -Wmissing-field-initializers
CFLAGS += -Wmissing-declarations
CFLAGS += -Wpacked
CFLAGS += -Wundef
CFLAGS += -Wredundant-decls
#CFLAGS += -Wnested-externs
CFLAGS += -Wunreachable-code
# CFLAGS += -Winline
CFLAGS += -Woverlength-strings
CFLAGS += -Wpointer-sign
CFLAGS += -Wdisabled-optimization
CFLAGS += -Wvariadic-macros
CFLAGS += -fstrict-aliasing
CFLAGS += -Wstrict-overflow=5 -fstrict-overflow
CFLAGS += -funsigned-char
CFLAGS += -funsigned-bitfields
# CFLAGS += -fpack-struct
CFLAGS += -fshort-enums
CFLAGS += -Wformat=2
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
CFLAGS += -std=gnu18
CFLAGS += -Werror=switch
CFLAGS += -Werror=implicit-fallthrough=4
BIN_DIR = bin/
SOURCES_DIR = src/
INCLUDES_DIR = inc/
SUBDIRS = tests/
BINARY = libcan_parser.a
SOURCES = $(shell find ./$(SOURCES_DIR) -type f -name \*.c)
OBJS = $(patsubst $(SOURCES_DIR)/%,$(BIN_DIR)/%,$(SOURCES:.c=.o))
INCLUDES = $(INCLUDES_DIR)/$(shell find ./inc -type f -name \*.h)
LIB_VERSION_FILE = .lib_version
$(BIN_DIR)/$(BINARY) : $(OBJS)
mkdir -p $(BIN_DIR)
$(SILENT) $(AR) rcs $@ $<
$(OBJS) : $(SOURCES) $(INCLUDES)
$(SILENT) $(CC) -c $< $(CFLAGS) -I./$(INCLUDES_DIR) -o $@
#download include files
$(INCLUDES) : $(LIB_VERSION_FILE)
./update_libs.sh
.PHONY: clean
clean :
$(SILENT) for i in $(SUBDIRS);\
do make -C $$i clean; done
rm -f $(OBJS)
rm -f $(BIN_DIR)/$(BINARY)
.PHONY: tests
tests : $(BIN_DIR)/$(BINARY)
$(SILENT) make -C tests/
.PHONY: all
all : $(BIN_DIR)/$(BINARY)
$(SILENT) for i in $(SUBDIRS);\
do make -C $$i; done