-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
56 lines (43 loc) · 1.05 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
51
52
53
54
55
CC = gcc
CFLAGS += -g -O2 -Wall
AR = ar rcu
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
REGEX_SHARE_LIB = libregex.so
CFLAGS += -std=gnu89
endif
ifeq ($(UNAME_S), Linux)
REGEX_SHARE_LIB = libregex.so
endif
_REGEX_LIB = \
reg_malloc.c \
reg_parse.c \
reg_stream.c \
reg_list.c \
reg_state.c \
state_gen.c \
state_match.c \
regex.c \
reg_error.c
REGEX_LIB = $(addprefix src/, $(_REGEX_LIB))
_TEST_CAST = \
test_parse.c \
test_edge.c \
test_list.c \
test_error.c \
test_api.c
TEST_CAST = $(addprefix test/, $(_TEST_CAST))
REGEX_LIB_OBJ = $(foreach s, $(REGEX_LIB), $(basename $(s)).o)
TEST_CAST_OUT = $(foreach s, $(TEST_CAST), $(basename $(s)))
all: $(REGEX_LIB_OBJ) $(REGEX_SHARE_LIB) $(TEST_CAST_OUT)
$(REGEX_LIB_OBJ): $(REGEX_LIB)
$(CC) $(CFLAGS) -c -o $@ $(basename $@).c
$(REGEX_SHARE_LIB): $(REGEX_LIB_OBJ)
$(CC) -shared -o $@ $(REGEX_LIB_OBJ)
$(TEST_CAST_OUT): $(TEST_CAST) $(REGEX_SHARE_LIB)
$(CC) $(CFLAGS) -o $@ [email protected] $(REGEX_SHARE_LIB)
.PHONY : clean
clean:
rm -rf $(REGEX_LIB_OBJ)
rm -rf $(TEST_CAST_OUT)
rm -rf $(REGEX_SHARE_LIB)