-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (37 loc) · 1.28 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
.PHONY: clean example objs doxygen
.ONESHELL:
TARGET_DIR ?=
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
ifeq ($(TARGET_DIR),)
TARGET_DIR = $(ROOT_DIR)/target
endif
$(shell mkdir -p $(TARGET_DIR))
ifneq ($(SSTR_DEBUG),)
DEBUG_FLAGS = -DSSTR_DEBUG
SANITIZER_FLAGS = -fsanitize=address -lasan
endif
CFLAGS += -Wall -Wextra -Werror -std=c11 -ggdb -Wno-unused-result -I$(ROOT_DIR) $(SANITIZER_FLAGS) $(DEBUG_FLAGS)
CXXFLAGS += -Wall -Wextra -Werror -std=c++17 -ggdb -Wno-unused-result -I$(ROOT_DIR) $(SANITIZER_FLAGS) $(DEBUG_FLAGS)
LDFLAGS ?=
export
all: objs example
example: $(TARGET_DIR)/example/example
objs: $(TARGET_DIR)/example/%.c.o $(TARGET_DIR)/sstr.c.o
$(TARGET_DIR)/example/%.c.o: $(wildcard $(TARGET_DIR)/example/*.c)
$(MAKE) -C $(ROOT_DIR)/example
$(TARGET_DIR)/sstr.c.o: sstr.h sstr.c
$(CC) $(CFLAGS) -c sstr.c -o $@
$(TARGET_DIR)/example/example: $(TARGET_DIR)/example/example.c.o $(TARGET_DIR)/sstr.c.o
gcc $^ -o $@ $(LDFLAGS) $(CFLAGS)
test: $(TARGET_DIR)/sstr.c.o
make -C test
clean:
rm -rf $(TARGET_DIR)
doxygen:
if [ ! -d target/doxygen-awesome-css ]; then
mkdir -p target
git clone --depth=1 https://github.com/jothepro/doxygen-awesome-css.git target/doxygen-awesome-css
fi
doxygen doxygen/Doxyfile
mkdir -p docs
cp -rf doc/html/* docs/