-
Notifications
You must be signed in to change notification settings - Fork 30
/
make.mk
159 lines (133 loc) · 4.45 KB
/
make.mk
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# MAKE INCLUDE FILE FOR DARWIN
# Stephen Gould <[email protected]>
#######################################################################
# DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING. IF YOU
# WANT TO OVERRIDE ANY OF THESE SETTINGS DO SO IN YOUR make.local FILE.
#######################################################################
OS = $(shell uname)
BIN_PATH = $(DRWN_PATH)/bin
EXT_PATH = $(DRWN_PATH)/external
INC_PATH = $(DRWN_PATH)/include
SRC_PATH = $(DRWN_PATH)/src
CCC = g++
LDCONFIG = /sbin/ldconfig
# force 32-bit compile (set to 1 in make.local)
DRWN_FORCE_32BIT = 0
ifeq (,$(MACHTYPE))
MACHTYPE = $(shell uname -m)
endif
ifeq (,$(findstring x86_64,$(MACHTYPE)))
DRWN_FORCE_32BIT = 1
endif
# compile and link debug symbols (set to 1 in make.local)
DRWN_DEBUG_SYMBOLS = 0
# use shared libraries (set to 1 in make.local)
DRWN_SHARED_LIBS = 0
# optional external libraries (force to 0 or 1 in make.local)
DRWN_BUILD_WITH_ZLIB = 0
ifeq ($(wildcard $(EXT_PATH)/zlib), $(EXT_PATH)/zlib)
DRWN_BUILD_WITH_ZLIB = 1
endif
DRWN_BUILD_VISION_LIB = 0
ifeq ($(wildcard $(EXT_PATH)/opencv), $(EXT_PATH)/opencv)
DRWN_BUILD_VISION_LIB = 1
endif
# platform flags
PLAT_CFLAGS = -D__LINUX__
PLAT_LFLAGS =
# define apple on max os x
ifeq ($(OS), Darwin)
PLAT_CFLAGS += -D__APPLE__
LDCONFIG = true
endif
# symbolic link to Eigen should be in external/eigen
EIGEN_CFLAGS = -I$(EXT_PATH) -DEIGEN_NO_DEBUG -msse2
#EIGEN_CFLAGS = -I$(EXT_PATH) -msse2
EIGEN_LFLAGS = -msse2
# initialize extra cflags
EXTRA_CFLAGS = -I$(INC_PATH) -I$(EXT_PATH)
# initialize extra libraries
EXTLIB =
# include local user make.local to override any settings
ifeq ($(wildcard $(DRWN_PATH)/make.local), $(DRWN_PATH)/make.local)
-include $(DRWN_PATH)/make.local
endif
# include project make.proj settings
ifneq (,$(PROJ_PATH))
EXTRA_CFLAGS += -I$(PROJ_PATH)/include
ifeq ($(wildcard $(PROJ_PATH)/make.proj), $(PROJ_PATH)/make.proj)
-include $(PROJ_PATH)/make.proj
endif
endif
# extra compiler and linker flags
ifeq ($(DRWN_BUILD_WITH_ZLIB), 1)
EXTRA_CFLAGS += -DDRWN_HAS_ZLIB -I$(EXT_PATH)/zlib
EXTRA_LFLAGS += $(EXT_PATH)/zlib/libz.a
endif
EXTRA_CFLAGS += $(EIGEN_CFLAGS)
EXTRA_LFLAGS += $(EIGEN_LFLAGS)
# libraries
DRWNLIBMAJORVER = 1
DRWNLIBMINORVER = 10.0
DRWNLIBVER = ${DRWNLIBMAJORVER}.${DRWNLIBMINORVER}
STATICDRWN := $(BIN_PATH)/libdrwnPGM.a $(BIN_PATH)/libdrwnML.a \
$(BIN_PATH)/libdrwnIO.a $(BIN_PATH)/libdrwnBase.a
ifeq ($(OS), Darwin)
SHAREDDRWN := $(BIN_PATH)/libdrwnBase.${DRWNLIBVER}.dylib \
$(BIN_PATH)/libdrwnIO.${DRWNLIBVER}.dylib \
$(BIN_PATH)/libdrwnML.${DRWNLIBVER}.dylib \
$(BIN_PATH)/libdrwnPGM.${DRWNLIBVER}.dylib
else
SHAREDDRWN := $(BIN_PATH)/libdrwnPGM.so.${DRWNLIBVER} \
$(BIN_PATH)/libdrwnML.so.${DRWNLIBVER} \
$(BIN_PATH)/libdrwnIO.so.${DRWNLIBVER} \
$(BIN_PATH)/libdrwnBase.so.${DRWNLIBVER}
endif
ifeq ($(DRWN_BUILD_VISION_LIB), 1)
EXTRA_CFLAGS += `pkg-config --cflags ${EXT_PATH}/opencv/lib/pkgconfig/opencv.pc`
EXTRA_LFLAGS += `pkg-config --libs ${EXT_PATH}/opencv/lib/pkgconfig/opencv.pc`
STATICDRWN := $(BIN_PATH)/libdrwnVision.a ${STATICDRWN}
ifeq ($(OS), Darwin)
SHAREDDRWN := ${SHAREDDRWN} $(BIN_PATH)/libdrwnVision.${DRWNLIBVER}.dylib
else
SHAREDDRWN := $(BIN_PATH)/libdrwnVision.so.${DRWNLIBVER} ${SHAREDDRWN}
endif
endif
ifeq ($(DRWN_SHARED_LIBS), 0)
LIBDRWN = $(STATICDRWN)
else
LIBDRWN = $(SHAREDDRWN)
ifeq ($(OS), Darwin)
EXTRA_LFLAGS += -L$(BIN_PATH)
else
EXTRA_LFLAGS += -Wl,--no-as-needed -Wl,-rpath,$(BIN_PATH) -L$(BIN_PATH)
endif
endif
# mac os x flags
ifeq ($(OS), Darwin)
CCC=clang++
ifeq ($(strip $(DRWN_FORCE_32BIT)), 0)
# PLAT_CFLAGS += -arch x86_64 -stdlib=libstdc++
# PLAT_LFLAGS += -arch x86_64 -lstdc++
PLAT_CFLAGS += -arch x86_64 -stdlib=libc++
PLAT_LFLAGS += -arch x86_64 -lc++
else
PLAT_CFLAGS += -arch i386 -stdlib=libstdc++
PLAT_LFLAGS += -arch i386 -stdlib=libstdc++
endif
endif
# compiler and linker flags
# BUG: OpenCV 2.4.1 on Ubuntu 12.04 appears to need an extra copy of EXTRA_LFLAGS
EXTRA_LFLAGS := $(EXTRA_LFLAGS) $(EXTRA_LFLAGS)
ifeq ($(strip $(DRWN_FORCE_32BIT)), 0)
CFLAGS = -O3 -fPIC $(PLAT_CFLAGS) $(EXTRA_CFLAGS) -Wall
LFLAGS = $(PLAT_LFLAGS) $(EXTLIB) $(LIBDRWN) $(EXTRA_LFLAGS) -lm -lpthread
else
CFLAGS = -O3 -m32 $(PLAT_CFLAGS) $(EXTRA_CFLAGS) -Wall
LFLAGS = -m32 $(PLAT_LFLAGS) $(EXTLIB) $(LIBDRWN) $(EXTRA_LFLAGS) -lm -lpthread
endif
ifeq ($(strip $(DRWN_DEBUG_SYMBOLS)), 1)
CFLAGS += -g
LFLAGS += -g
endif
OBJ = $(SRC:.cpp=.o)