-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
46 lines (36 loc) · 909 Bytes
/
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
LIBRARY := libregex.a
OBJECTS := src/regex_allocators.o \
src/regex_compile.o \
src/regex_parse.o \
src/regex_program.o \
src/regex_vm_pike.o
DEPENDS := $(OBJECTS:%.o=%.d)
SUBDIRS := test examples/regex examples/regex2dot
CFLAGS += -std=c11 -Wall -pedantic
PREFIX ?= /usr/local
.PHONY: all
all: CPPFLAGS += -DNDEBUG
all: CFLAGS += -O2
all: $(LIBRARY) $(SUBDIRS)
.PHONY: debug
debug: CPPFLAGS += -DDEBUG
debug: CFLAGS += -g
debug: LDFLAGS += -g
debug: $(LIBRARY) $(SUBDIRS)
.PHONY: clean
clean:
for subdir in $(SUBDIRS); do \
$(MAKE) -C $$subdir clean; \
done
$(RM) $(LIBRARY) $(OBJECTS) $(DEPENDS)
-include $(DEPENDS)
$(LIBRARY): $(OBJECTS)
$(AR) rcs $@ $^
$(SUBDIRS): $(LIBRARY)
$(MAKE) -C $@
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -c -o $@ $<
.PHONY: install
install: all
mkdir -p $(PREFIX)/lib
install $(LIBRARY) $(PREFIX)/lib