-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
executable file
·95 lines (68 loc) · 2.79 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
include ../../make.project
MAINDIR = $(CURDIR)/../..
#-----------------------------------------------------------------------------
# paths
#-----------------------------------------------------------------------------
OBJDIR = ./obj
SRCDIR = ./src
PYTHON = ./python
MIPDIR = $(MAINDIR)/solvers/mip
SWIG = swig
PYLIB = `python-config --cflags`
PYOBJ = `python-config --prefix`
CPLEXCCFLAGS = `python $(MAINDIR)/tools/solverconfig.py CPLEX --cflags` -Wno-unused-private-field
CPLEXLDFLAGS = `python $(MAINDIR)/tools/solverconfig.py CPLEX --lflags`
OPTFLAGS = -O3
COMPILFLAGS = -Wall -D_UNIX -fPIC -I$(MIPDIR)/src/ $(CPLEXCCFLAGS)
CCC ?= g++
#-----------------------------------------------------------------------------
# Main Program
#-----------------------------------------------------------------------------
MAINNAME = CPLEX
MAINOBJ = $(MAINNAME).o
MAINSRC = $(addprefix $(SRCDIR)/,$(MAINOBJ:.o=.cpp))
MAINOBJFILES = $(addprefix $(OBJDIR)/,$(MAINOBJ))
#-----------------------------------------------------------------------------
# Interface
#-----------------------------------------------------------------------------
IFILE = $(PYTHON)/$(MAINNAME).i
PYFILE = $(PYTHON)/$(MAINNAME).py
WXXFILE = $(PYTHON)/$(MAINNAME)_wrap.cxx
WOBFILE = $(PYTHON)/$(MAINNAME)_wrap.o
SOFILE = $(PYTHON)/_$(MAINNAME).so
#------------------------------------------------------------
# make all : to compile the examples.
#------------------------------------------------------------
wrapper: $(OBJDIR) $(PYTHON) $(IFILE) $(WXXFILE) $(SOFILE)
debug: CFLAGS += -D_DEBUGWRAP -g
debug: wrapper $(MAINOBJFILES) $(WOBFILE)
test:
echo CPLEXDIR = $(CPLEXDIR)
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(PYTHON):
@mkdir -p $(PYTHON)
clean:
@echo "-> cleaning"
@-rm -rf $(OBJDIR)/* $(PYTHON)/*o $(PYTHON)/*~ $(PYTHON)/build *~ $(SRCDIR)/*~
clean_swig:
@echo "-> cleaning swig interface"
@-rm -rf $(OBJDIR)/* $(PYTHON)/* *~ $(SRCDIR)/*~
install_python: wrapper
cd $(PYTHON); python $(MAINDIR)/tools/setup.py install
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@echo "-> compiling $@"
@$(CCC) $(OPTFLAGS) $(COMPILFLAGS) $(CFLAGS) $(CCFLAGS) -c -o $@ $<
$(PYTHON)/%_wrap.o: $(PYTHON)/%_wrap.cxx
@echo "-> compiling $@"
@$(CCC) $(PYLIB) $(OPTFLAGS) $(COMPILFLAGS) $(CFLAGS) -I$(SRCDIR) -c $< -o $@
$(PYTHON)/%_wrap.cxx: $(PYTHON)/%.i
@echo "-> compiling $@"
@$(SWIG) -c++ -python $<
@python $(MAINDIR)/tools/finalize.py $(<:.i=.py) MipWrapper
$(PYTHON)/%.i: $(SRCDIR)/%.hpp
@echo "-> creating interface $@"
@python $(MAINDIR)/tools/mk_subinterface.py mip MipWrapper $<
$(PYTHON)/_%.so: $(OBJDIR)/%.o $(MIPDIR)/obj/MipWrapper.o $(PYTHON)/%_wrap.o
@echo "-> linking $@"
@$(CCC) $(OPTFLAGS) $(COMPILFLAGS) $(BUNDLE) -Wno-long-double $(CFLAGS) $(MAINOBJFILES) $(LFLAGS) $(MIPDIR)/obj/MipWrapper.o python/$(MAINNAME)_wrap.o -o $@ $(CPLEXLDFLAGS)