-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile.include
More file actions
124 lines (106 loc) · 3.1 KB
/
Makefile.include
File metadata and controls
124 lines (106 loc) · 3.1 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#BASEPATH_ := $(dir $(realpath $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))))
BASEPATH_ := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
CC ?= gcc
CXX ?= g++
M4 ?= m4
SCAN_BUILD ?= scan-build
PROTOC ?= protoc
PYTHON2 ?= python2
SYSTEM = $(shell uname)
SYSTEM_CXXFLAGS =
SYSTEM_LDFLAGS =
CONFIG_FLAGS =
ifeq '$(SYSTEM)' 'FreeBSD'
SYSTEM_CXXFLAGS = -Wno-long-long
else
endif
DEBUG ?= no
PROFIL ?= no
WERROR ?= no
ifeq '$(PROFIL)' 'yes'
DEBUG = yes
endif
ifeq '$(DEBUG)' 'yes'
CFLAGS = -g -Wno-unused-function
CXXFLAGS = -g -Wno-unused-function
CONFIG_FLAGS += -DDEBUG
else
# force to use optimizations
CFLAGS += -O3
CXXFLAGS += -O3
endif
ifeq '$(PROFIL)' 'yes'
CFLAGS += -pg
CXXFLAGS += -pg
endif
CFLAGS += -Wall -pedantic --std=gnu99
CXXFLAGS += -Wall -pedantic
ifeq '$(WERROR)' 'yes'
CFLAGS += -Werror
endif
LDFLAGS += -pthread
LDFLAGS += $(SYSTEM_LDFLAGS)
OPTS_CFLAGS ?=
OPTS_LDFLGS ?=
USE_LOCAL_OPTS ?= $(shell if test -f $(BASEPATH_)/third-party/opts/libopts.a; then echo "yes"; else echo "no"; fi;)
ifeq '$(USE_LOCAL_OPTS)' 'yes'
OPTS_CFLAGS := -I$(BASEPATH_)/third-party/opts
OPTS_LDFLAGS := -L$(BASEPATH_)/third-party/opts -lopts
endif
BORUVKA_CFLAGS ?=
BORUVKA_LDFLAGS ?=
USE_LOCAL_BORUVKA ?= $(shell if test -f $(BASEPATH_)/third-party/boruvka/libboruvka.a; then echo "yes"; else echo "no"; fi;)
ifeq '$(USE_LOCAL_BORUVKA)' 'yes'
BORUVKA_CFLAGS := -I$(BASEPATH_)/third-party/boruvka
BORUVKA_LDFLAGS := -L$(BASEPATH_)/third-party/boruvka -lboruvka
endif
PROTOBUF_PATH_ := $(BASEPATH_)/third-party/protobuf
PROTOBUF_LIBPATH_ := $(PROTOBUF_PATH_)/build/lib
USE_LOCAL_PROTOBUF ?= $(shell if test -f $(PROTOBUF_LIBPATH_)/libprotobuf.a; then echo "yes"; else echo "no"; fi;)
ifeq '$(USE_LOCAL_PROTOBUF)' 'yes'
PROTOBUF_CFLAGS ?= $(shell PKG_CONFIG_PATH=$(PROTOBUF_LIBPATH_)/pkgconfig pkg-config --cflags protobuf)
PROTOBUF_LDFLAGS ?= $(shell PKG_CONFIG_PATH=$(PROTOBUF_LIBPATH_)/pkgconfig pkg-config --libs protobuf)
# PROTOBUF_CFLAGS := -I$(PROTOBUF_PATH_)/build/include
# PROTOBUF_LDFLAGS := -L$(PROTOBUF_PATH_)/build/lib -lprotobuf
PROTOC := $(realpath $(PROTOBUF_PATH_))/build/bin/protoc
else
PROTOBUF_CFLAGS ?= $(shell pkg-config --cflags protobuf)
PROTOBUF_LDFLAGS ?= $(shell pkg-config --libs protobuf)
endif
LP_SOLVE_CFLAGS ?=
LP_SOLVE_LDFLAGS ?=
ifneq '$(LP_SOLVE_CFLAGS)$(LP_SOLVE_LDFLAGS)' ''
USE_LP_SOLVE := yes
else
ifeq '$(shell if test -f /usr/lib/liblpsolve55.so; then echo "yes"; fi;)' 'yes'
LP_SOLVE_LDFLAGS = -llpsolve55
USE_LP_SOLVE := yes
endif
endif
CPLEX_CFLAGS ?=
CPLEX_LDFLAGS ?=
ifneq '$(CPLEX_CFLAGS)$(CPLEX_LDFLAGS)' ''
USE_CPLEX := yes
USE_LP_SOLVE := no # CPLEX has precedence over lp-solve
endif
ifeq '$(USE_CPLEX)' 'yes'
LP ?= yes
endif
ifeq '$(USE_LP_SOLVE)' 'yes'
LP ?= yes
endif
LP ?= no
ifeq '$(LP)' 'yes'
CONFIG_FLAGS += -DLP
ifeq '$(USE_CPLEX)' 'yes'
CONFIG_FLAGS += -DUSE_CPLEX
LP_CFLAGS = $(CPLEX_CFLAGS)
LP_LDFLAGS = $(CPLEX_LDFLAGS)
endif
ifeq '$(USE_LP_SOLVE)' 'yes'
CONFIG_FLAGS += -DUSE_LP_SOLVE
LP_CFLAGS = $(LP_SOLVE_CFLAGS)
LP_LDFLAGS = $(LP_SOLVE_LDFLAGS)
endif
endif
.DEFAULT_GOAL := all