@@ -1,47 +1,52 @@
|
|
1 |
CC=cc
|
2 |
CXX=g++
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
LINTFILTERS=$\
|
6 |
-readability/casting,$\
|
7 |
-build/header_guard,$\
|
8 |
-build/include_subdir
|
9 |
|
10 |
APPNAME=$(shell basename $(shell pwd))
|
11 |
-
APPARGS=
|
12 |
HEADERS=$(wildcard *.h)
|
13 |
-
SOURCES=$(wildcard *.c)
|
14 |
-
OBJECTS=$(SOURCES:%.
|
15 |
|
16 |
bin/$(APPNAME): $(OBJECTS) | bin/.
|
17 |
-
$(
|
18 |
|
19 |
build/%.o: %.c $(HEADERS) | build/.
|
20 |
$(CC) -c $(CFLAGS) $< -o $@ $(LIBS)
|
21 |
|
|
|
|
|
|
|
22 |
.PRECIOUS: %/.
|
23 |
%/.:
|
24 |
mkdir -p $(dir $@)
|
25 |
|
26 |
all: bin/$(APPNAME) lint memcheck helgrind
|
27 |
|
28 |
.PHONY: lint
|
29 |
lint:
|
30 |
cpplint --filter=$(LINTFILTERS) $(HEADERS) $(SOURCES)
|
31 |
|
32 |
.PHONY: memcheck
|
33 |
memcheck:
|
34 |
valgrind --tool=memcheck bin/$(APPNAME) $(APPARGS)
|
35 |
|
36 |
.PHONY: helgrind
|
37 |
helgrind:
|
38 |
valgrind --quiet --tool=helgrind bin/$(APPNAME) $(APPARGS)
|
39 |
|
40 |
.PHONY: gitignore
|
41 |
gitignore:
|
42 |
echo bin > .gitignore
|
43 |
echo build >> .gitignore
|
44 |
|
45 |
.PHONY: clean
|
46 |
clean:
|
47 |
rm -rf bin build
|
1 |
CC=cc
|
2 |
CXX=g++
|
3 |
+
FLAGS=-g -Wall -Wextra -fopenmp
|
4 |
+
CFLAGS=$(FLAGS) -std=gnu11
|
5 |
+
CXXFLAGS=$(FLAGS) -std=gnu++11
|
6 |
+
LIBS=
|
7 |
LINTFILTERS=$\
|
8 |
-readability/casting,$\
|
9 |
-build/header_guard,$\
|
10 |
-build/include_subdir
|
11 |
|
12 |
APPNAME=$(shell basename $(shell pwd))
|
13 |
+
APPARGS=
|
14 |
HEADERS=$(wildcard *.h)
|
15 |
+
SOURCES=$(wildcard *.c *.cpp)
|
16 |
+
OBJECTS=$(SOURCES:%.cpp=build/%.o)
|
17 |
|
18 |
bin/$(APPNAME): $(OBJECTS) | bin/.
|
19 |
+
$(CXX) $(CXXFLAGS) $^ -o $@ $(LIBS)
|
20 |
|
21 |
build/%.o: %.c $(HEADERS) | build/.
|
22 |
$(CC) -c $(CFLAGS) $< -o $@ $(LIBS)
|
23 |
|
24 |
+
build/%.o: %.cpp $(HEADERS) | build/.
|
25 |
+
$(CXX) -c $(CXXFLAGS) $< -o $@ $(LIBS)
|
26 |
+
|
27 |
.PRECIOUS: %/.
|
28 |
%/.:
|
29 |
mkdir -p $(dir $@)
|
30 |
|
31 |
all: bin/$(APPNAME) lint memcheck helgrind
|
32 |
|
33 |
.PHONY: lint
|
34 |
lint:
|
35 |
cpplint --filter=$(LINTFILTERS) $(HEADERS) $(SOURCES)
|
36 |
|
37 |
.PHONY: memcheck
|
38 |
memcheck:
|
39 |
valgrind --tool=memcheck bin/$(APPNAME) $(APPARGS)
|
40 |
|
41 |
.PHONY: helgrind
|
42 |
helgrind:
|
43 |
valgrind --quiet --tool=helgrind bin/$(APPNAME) $(APPARGS)
|
44 |
|
45 |
.PHONY: gitignore
|
46 |
gitignore:
|
47 |
echo bin > .gitignore
|
48 |
echo build >> .gitignore
|
49 |
|
50 |
.PHONY: clean
|
51 |
clean:
|
52 |
rm -rf bin build
|