-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathMakefile
48 lines (41 loc) · 1.52 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
# debug :run -n 4 xterm -e gdb ../bin/fname
CC := mpic++
BUILDDIR := build
SRCDIR := src
TESTDIR := test
EGDIR := examples
BUILDDIR := build
BINDIR := bin
TESTTARGET := bin/test
SRCEXT := cpp
CFLAGS := -Wall -std=c++14 -O3 # -DNOMPI # uncomment this flag if not using parallelism with MPI and boost
LIB := -lboost_mpi -lboost_serialization # can be commented if -DNOMPI is used above
# perf report -g 'graph,0.5,caller'
TESTS := $(shell find $(TESTDIR) -type f -name *.$(SRCEXT))
SOURCES := $(shell find $(EGDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(EGDIR)/%,$(BINDIR)/%,$(SOURCES:.$(SRCEXT)=))
OBJECTSTEST := $(patsubst $(TESTDIR)/%,$(BUILDDIR)/%,$(TESTS:.$(SRCEXT)=.o))
TESTINC := -I test
INC := -I include
examples: $(OBJECTS)
@mkdir -p $(BINDIR)
@echo "Finished"
$(TESTTARGET): $(OBJECTSTEST)
@mkdir -p $(BINDIR)
@echo " Linking..."
@echo " $(CC) $^ -o $(TESTTARGET) $(LIB)"; $(CC) $^ -o $(TESTTARGET) $(LIB)
$(BUILDDIR)/%.o: $(TESTDIR)/%.$(SRCEXT)
@mkdir -p $(BUILDDIR)
@echo " $(CC) $(CFLAGS) $(INC) $(TESTINC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) $(TESTINC) -c -o $@ $<
example:
@mkdir -p $(BINDIR)
@echo " making $(fname)..."
@echo " $(CC) examples/$(fname).cpp $(CFLAGS) $(INC) -o $(BINDIR)/$(fname) $(LIB) "; $(CC) examples/$(fname).cpp $(CFLAGS) $(INC) -o $(BINDIR)/$(fname) $(LIB)
$(BINDIR)/%: $(EGDIR)/%.$(SRCEXT)
@mkdir -p $(BINDIR)
@echo " $(CC) $(CFLAGS) $(INC) -o $@ $< $(LIB)"; $(CC) $(CFLAGS) $(INC) -o $@ $< $(LIB)
clean:
@echo " Cleaning...";
$(RM) -r $(BUILDDIR);
$(RM) -r $(BINDIR);
.PHONY: clean