-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkfq7
64 lines (50 loc) · 2.14 KB
/
mkfq7
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
62
63
64
CPLEX_VERSION = 12.4
#detecta se o sistema é de 32 ou 64 bits
BITS_OPTION = -m64
####diretorios com as libs do cplex
CPLEXDIR = /opt/ibm/ILOG/CPLEX_Studio127/cplex
CONCERTDIR = /opt/ibm/ILOG/CPLEX_Studio127/concert
CPLEXLIBDIR = $(CPLEXDIR)/lib/x86-64_linux/static_pic
CONCERTLIBDIR = $(CONCERTDIR)/lib/x86-64_linux/static_pic
#### define o compilador
CPPC = g++-5 -O3 -std=c++17
#############################
#### opcoes de compilacao e includes
CCOPT = $(BITS_OPTION) -g -fPIC -fexceptions -DNDEBUG -DIL_STD
CONCERTINCDIR = $(CONCERTDIR)/include
CPLEXINCDIR = $(CPLEXDIR)/include
CCFLAGS = $(CCOPT) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR)
#############################
#### flags do linker
CCLNFLAGS = -L$(CPLEXLIBDIR) -lilocplex -lcplex -L$(CONCERTLIBDIR) -lconcert -lm -lpthread
#############################
#### diretorios com os source files e com os objs files
SRCDIR = src
OBJDIR = obj
#############################
#### lista de todos os srcs e todos os objs
SRCS = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(SRCS))
#############################
#### regra principal, gera o executavel
tsp: $(OBJS)
@echo "\033[31m \nLinking all objects files: \033[0m"
$(CPPC) $(BITS_OPTION) $(OBJS) -o $@ $(CCLNFLAGS)
############################
#inclui os arquivos de dependencias
-include $(OBJS:.o=.d)
#regra para cada arquivo objeto: compila e gera o arquivo de dependencias do arquivo objeto
#cada arquivo objeto depende do .c e dos headers (informacao dos header esta no arquivo de dependencias gerado pelo compiler)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@echo "\033[31m \nCompiling $<: \033[0m"
$(CPPC) $(CCFLAGS) -c $< -o $@
@echo "\033[32m \ncreating $< dependency file: \033[0m"
$(CPPC) -MM $< > $(basename $@).d
@mv -f $(basename $@).d $(basename $@).d.tmp #proximas tres linhas colocam o diretorio no arquivo de dependencias (g++ nao coloca, surprisingly!)
@sed -e 's|.*:|$(basename $@).o:|' < $(basename $@).d.tmp > $(basename $@).d
@rm -f $(basename $@).d.tmp
#delete objetos e arquivos de dependencia
clean:
@echo "\033[31mcleaning obj directory \033[0m"
@rm tsp $(OBJDIR)/*.o $(OBJDIR)/*.d
rebuild: clean tsp