forked from adamatom/NanoCBOR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (34 loc) · 1.06 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
NANOCBOR_DIR ?= $(CURDIR)
# cannot simply use CC ?= gcc, as CC defaults to "cc" if undefined on GNU Make
ifeq ($(origin CC),default)
CC := gcc
endif
RM = rm -rf
TIDY ?= clang-tidy
CFLAGS ?=
INC_GLOBAL ?= /usr/include
INC_DIR = $(NANOCBOR_DIR)/include
SRC_DIR = $(NANOCBOR_DIR)/src
TEST_DIR=tests
BIN_DIR ?= bin
OBJ_DIR ?= $(BIN_DIR)/objs
# Only check at issues present for c99 compatible code
CFLAGS_TIDY ?= -std=c99
TIDYFLAGS=-checks=*,-llvmlibc-restrict-system-libc-headers,-bugprone-reserved-identifier,-cert-* -warnings-as-errors=*
CFLAGS_WARN += -Wall -Wextra -pedantic -Werror -Wshadow
CFLAGS += -fPIC $(CFLAGS_WARN) -I$(INC_DIR) -I$(INC_GLOBAL) -Og -g3
SRCS ?= $(wildcard $(SRC_DIR)/*.c)
OBJS ?= $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRCS))
lib: $(BIN_DIR)/nanocbor.so
prepare:
@mkdir -p $(OBJ_DIR)
# Build a binary
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c prepare
$(CC) $(CFLAGS) -c -o $@ $<
objs: $(OBJS)
$(BIN_DIR)/nanocbor.so: objs
$(CC) $(CFLAGS) $(OBJS) -o $@ -shared
clang-tidy:
$(TIDY) $(TIDYFLAGS) $(SRCS) -- $(CFLAGS) $(CFLAGS_TIDY)
clean:
$(RM) $(BIN_DIR)