-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
32 lines (25 loc) · 767 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
CXX := clang++-3.8
LLVM_CONFIG := llvm-config-3.8
CXXFLAGS := -O3 -std=c++11 -MMD -MP $(shell $(LLVM_CONFIG) --cxxflags)
LIBS := -lm $(shell $(LLVM_CONFIG) --system-libs --ldflags --libs all)
PROG := qcc
SRCS := $(wildcard src/*.cpp)
OBJS := $(SRCS:%.cpp=%.o)
DEPS := $(SRCS:%.cpp=%.d)
TESTS := $(patsubst %.c,%,$(filter-out test/main.c, $(wildcard test/*.c)))
.PHONY: test clean
$(PROG): $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ -rdynamic $(OBJS) $(LIBS)
test: $(PROG)
@for t in $$(ls example); do \
./qcc example/$$t > /dev/null || exit; \
done
@for t in $(TESTS); do \
./test/test.sh $$t; \
done
@for t in $(TESTS); do \
$$t.bin || exit; \
done
clean:
-$(RM) $(PROG) $(OBJS) $(DEPS) $(TESTS:%=%.bc) $(TESTS:%=%.s) $(TESTS:%=%.bin)
-include $(DEPS)