forked from srtjanuario/binpacking-cg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
65 lines (51 loc) · 2.14 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
62
63
64
65
CPLEX_VERSION = 12.10
#detecta se o sistema é de 32 ou 64 bits
BITS_OPTION = -m64
####diretorios com as libs do cplex
CPLEXDIR = /Applications/CPLEX_Studio1210/cplex
CONCERTDIR = /Applications/CPLEX_Studio1210/concert
CPLEXLIBDIR = $(CPLEXDIR)/lib/x86-64_osx/static_pic
CONCERTLIBDIR = $(CONCERTDIR)/lib/x86-64_osx/static_pic
#### define o compilador
CPPC = g++ -O3 -std=c++2a
#############################
#### 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
bpcg: $(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 bpcg $(OBJDIR)/*.o $(OBJDIR)/*.d
clear
rebuild: clean bpcg