-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
54 lines (40 loc) · 1.34 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
ifdef CROSS_COMPILER
CC = $(CROSS_COMPILER)
else
ifndef CC
# default compiler
CC = gcc
endif
endif
AR = ar
CFLAGS += -Wall -Iinclude -std=c99
OUTDIR = out
TARGET = librepan.a
SRCDIR = src
TEST_TARGET = repan-test
GEN_CTABLE_TARGET = repan-gen-ctable
TOOLS_SRCDIR = src-tools
OBJS = $(addprefix $(OUTDIR)/, alloc.o gen_nodes.o literal.o nodes.o \
opt_flatten.o opt_merge_alternatives.o opt_uncapture.o parser_decode.o \
parser_glob.o parser_javascript.o parser_pcre.o parser_posix.o \
parser_util.o to_string_pcre.o to_string_encode.o unicode_expand.o \
unicode_gen.o util.o)
TEST_OBJS = $(addprefix $(OUTDIR)/, repan-test.o)
GEN_CTABLE_OBJS = $(addprefix $(OUTDIR)/, repan-gen-ctable.o)
all: $(OUTDIR) $(OUTDIR)/$(TARGET) $(OUTDIR)/$(TEST_TARGET) $(OUTDIR)/$(GEN_CTABLE_TARGET)
$(OUTDIR) :
mkdir $(OUTDIR)
$(OUTDIR)/%.o : $(SRCDIR)/%.c $(OUTDIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OUTDIR)/%.o : $(TOOLS_SRCDIR)/%.c $(OUTDIR)
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(TARGET)
rm -f $(OUTDIR)/$(TEST_TARGET)
$(OUTDIR)/$(TARGET): $(OBJS)
$(AR) r $@ $?
$(OUTDIR)/$(TEST_TARGET) : $(OUTDIR)/$(TARGET) $(TEST_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(TEST_OBJS) -o $@ -L$(OUTDIR) -lrepan
$(OUTDIR)/$(GEN_CTABLE_TARGET) : $(GEN_CTABLE_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(GEN_CTABLE_OBJS) -o $@ -L$(OUTDIR)