-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
63 lines (46 loc) · 1.62 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
49
50
51
52
53
54
55
56
57
58
59
60
61
CC = g++
LIBS = -ligraph
LIBDIRS = -L/usr/local/lib -L$(PWD)/lib
INC = -I$(PWD)/include -I$(PWD)/include/alglib -I$(PWD)/include/igraph
FLAGS = -std=c++11 -g -Wl,-rpath=$(PWD)/lib -Wl,-z,now
PROG1 = $(PWD)/src/main_analysis.cpp
TARGET1 = $(PWD)/bin/analysis
PROG2 = $(PWD)/src/main_threshold.cpp
TARGET2 = $(PWD)/bin/threshold
SRCDIR = $(PWD)/src
SRCEXT = cpp
INCLUDEDIR = $(PWD)/include
LIBDIR = $(PWD)/lib
BUILDDIR = $(PWD)/build
EXTERNALDIR = $(PWD)/external/
IGRAPHDIR = igraph-0.8.0
SOURCES = $(shell find $(SRCDIR) -xtype f -name "*".$(SRCEXT) ! -name main* )
OBJECTS = $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
#$(info $(SOURCES))
#$(info $(OBJECTS))
all: $(TARGET1) $(TARGET2)
$(TARGET1): $(OBJECTS) $(PROG1)
$(CC) -o $@ $^ $(FLAGS) $(INC) $(LIBDIRS) $(LIBS)
$(TARGET2): $(OBJECTS) $(PROG2)
$(CC) -o $@ $^ $(FLAGS) $(INC) $(LIBDIRS) $(LIBS)
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) igraph
@mkdir -p $(BUILDDIR)
$(CC) -c -o $@ $< $(FLAGS) $(INC) $(LIBDIRS) $(LIBS)
.PHONY: igraph
igraph:
@mkdir -p $(BUILDDIR)
cd $(EXTERNALDIR) && \
tar zxvf $(IGRAPHDIR).tar.gz && \
cd $(IGRAPHDIR) && \
./configure --libdir=$(LIBDIR) --prefix=$(BUILDDIR) && \
$(MAKE) MAKEFLAGS= && \
$(MAKE) install && \
cp $(BUILDDIR)/include/igraph/* $(INCLUDEDIR)/igraph/
.PHONY: clean
clean:
$(RM) -r $(BUILDDIR) $(TARGET)
#$(RM) $(LIBDIR)/lib*
#$(MAKE) --directory=$(IGRAPHDIR) clean
# http://nuclear.mutantstargoat.com/articles/make/#building-sub-projects
# https://github.com/igraph/igraph/issues/1263#issue-523750694
# ./configure --includedir=$(INCLUDEDIR)/igraph --libdir=$(LIBDIR) --prefix=$(BUILDDIR)