forked from jeremycw/httpserver.h
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (39 loc) · 1.06 KB
/
Copy pathMakefile
File metadata and controls
54 lines (39 loc) · 1.06 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
.PHONY: test test-cpp clean valgrind run
BINS=main db
CBINS=$(BINS:%=bin/%)
CXXBINS=$(BINS:%=bin/cpp/%)
CCOMMANDS=$(CBINS:%=% &)
CXXCOMMANDS=$(CXXBINS:%=% &)
TESTS=$(BINS:%=test/%)
TESTCMDS=$(TESTS:%=% >> test-results.txt; )
CFLAGS :=-O3 -std=c99 -Wall -Werror -Wextra
CXXFLAGS :=-O3 -std=c++98 -Wall -Werror -Wextra
CPATH=-I`pg_config --includedir`
LDFLAGS :=-lpq
all: $(CBINS)
run: bin/main
bin/main
cpp: $(CXXBINS)
test: $(CBINS) $(TESTS)
> test-results.txt
$(CCOMMANDS) $(TESTCMDS) killall $(BINS)
diff test-results.txt test/results.txt
test-cpp: $(CXXBINS) $(TESTS)
> test-results.txt
$(CXXCOMMANDS) $(TESTCMDS) killall $(BINS)
diff test-results.txt test/results.txt
valgrind: $(CBINS) test/valgrind
test/valgrind
diff valgrind-results.txt test/valgrind.txt
bin/%: test/%.c httpserver.h httpserver-pg.h | bin
$(CC) $(CFLAGS) $(CPATH) $< -o $@ $(LDFLAGS)
bin/cpp/%: test/%.cpp httpserver.h httpserver-pg.h | bin/cpp
$(CXX) $(CXXFLAGS) $(CPATH) $< -o $@ $(LDFLAGS)
test/%.cpp: test/%.c
cp $< $@
bin/cpp: bin
mkdir $@
bin:
mkdir $@
clean:
@rm -rf bin *.txt