-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (73 loc) · 1.7 KB
/
Makefile
File metadata and controls
87 lines (73 loc) · 1.7 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
81
82
83
84
85
86
87
# flags
_CFLAGS := -O2 -std=c11 -pipe \
-Wall -Wextra -Wformat \
-Werror=implicit-function-declaration -Werror=int-conversion
override CFLAGS := $(_CFLAGS) $(CFLAGS)
# files
SRC := src/str_mem.c \
src/str_clone.c \
src/str_hash.c \
src/str_concat_array.c \
src/str_join_array.c \
src/str_span_chars.c \
src/str_span_nonmatching_chars.c \
src/str_span_until_substring.c \
src/str_sprintf.c \
src/str_repeat.c \
src/str_replace_substring.c \
src/str_replace_chars.c \
src/str_replace_char_spans.c \
src/str_decode_utf8.c \
src/str_count_codepoints.c \
src/str_to_valid_utf8.c \
src/str_encode_codepoint.c \
src/str_concat_array_to_stream.c \
src/str_read_all_file.c \
src/str_concat_array_to_fd.c \
src/str_get_line.c \
src/str_sort.c \
src/str_partition_array.c \
src/str_unique_partition_array.c
OBJ := $(SRC:.c=.o)
LIB := libstr.a
# targets
.PHONY: lib clean test stat
# clear targets on error
.DELETE_ON_ERROR:
# library target
lib: $(LIB)
# library
$(LIB): $(OBJ)
$(AR) $(ARFLAGS) $@ $?
# header dependencies
$(OBJ): str.h src/str_impl.h
src/str_hash.o: src/rapidhash/rapidhash.h
# testing
TBIN := test-str
TSRC := src/test.c \
src/test_utf8.c \
src/test_utf8_validator.c \
src/test_io.c \
src/mite/mite.c \
$(LIB)
# sanitisers only work for non-musl builds
ifneq ($(CC),musl-gcc)
CC_SAN := -fsanitize=address \
-fsanitize=leak \
-fsanitize=null \
-fsanitize=undefined \
-fsanitize-address-use-after-scope
endif
test: $(TBIN)
$(TBIN): $(TSRC) str.h src/mite/mite.h
$(CC) $(CFLAGS) $(LDFLAGS) $(CC_SAN) -o $@ $(TSRC)
chmod 0700 $@
./$@
# cleanup
clean:
$(RM) $(LIB) src/*.o $(TBIN)
# statistics
stat:
@echo SRC = $(SRC)
@echo LIB = $(LIB)
@nm $(LIB)