/
Makefile.include
281 lines (252 loc) · 7.45 KB
/
Makefile.include
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
###
# sim
# ---------------------------------
# Copyright (c)2010 Daniel Fiser <danfis@danfis.cz>
#
# This file is part of sim.
#
# sim is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
#
# sim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
CC ?= gcc
CXX ?= g++
MOC ?= moc
FLEX ?= flex
DOXYGEN ?= doxygen
DIA ?= dia
CONVERT ?= convert
M4 ?= m4
SYSTEM = $(shell uname)
SYSTEM_CXXFLAGS =
SYSTEM_CFLAGS =
SYSTEM_LDFLAGS =
ifeq '$(SYSTEM)' 'FreeBSD'
AWK ?= gawk
SED ?= gsed
SYSTEM_CXXFLAGS = -Wno-long-long
SYSTEM_CFLAGS = -Wno-long-long
else
AWK ?= awk
SED ?= sed
ifeq '$(SYSTEM)' 'Darwin'
SYSTEM_LDFLAGS = -pthread
else
SYSTEM_LDFLAGS = -lrt -pthread
endif
endif
NOWALL ?= no
NOPEDANTIC ?= no
DEBUG ?= yes
PROFIL ?= no
ifeq '$(PROFIL)' 'yes'
DEBUG = yes
endif
ifeq '$(DEBUG)' 'yes'
CFLAGS = -g
CXXFLAGS = -g
endif
ifeq '$(PROFIL)' 'yes'
CFLAGS += -pg
CXXFLAGS += -pg
endif
ifneq '$(NOWALL)' 'yes'
CFLAGS += -Wall
CXXFLAGS += -Wall
endif
ifneq '$(NOPEDANTIC)' 'yes'
CFLAGS += -pedantic
CXXFLAGS += -pedantic
endif
CXXFLAGS += $(SYSTEM_CXXFLAGS)
CFLAGS += $(SYSTEM_CFLAGS)
CFLAGS += --std=gnu99
LDFLAGS += $(SYSTEM_LDFLAGS)
HAVE_ODE ?= no
HAVE_BT ?= no
HAVE_OSG ?= no
HAVE_SDL ?= no
HAVE_OPENCV ?= no
HAVE_PHYSX ?= no
WANT_ODE ?= yes
WANT_OSG ?= yes
WANT_BT ?= yes
WANT_SDL ?= yes
WANT_OPENCV ?= yes
WANT_PHYSX ?= no
# Try to find ODE
ifeq '$(WANT_ODE)' 'yes'
ifeq '$(HAVE_ODE)' 'no'
HAVE_ODE := $(shell if ode-config --version >/dev/null 2>&1; then echo "yes"; else echo "no"; fi;)
ifeq '$(HAVE_ODE)' 'yes'
ODE_CXXFLAGS = $(shell ode-config --cflags)
ODE_LDFLAGS = $(shell ode-config --libs)
else
HAVE_ODE := $(shell if pkg-config ode --exists; then echo "yes"; else echo "no"; fi;)
ifeq '$(HAVE_ODE)' 'yes'
ODE_CXXFLAGS = $(shell pkg-config ode --cflags)
ODE_LDFLAGS = $(shell pkg-config ode --libs)
endif
endif
endif
endif
# Try to find OSG
ifeq '$(WANT_OSG)' 'yes'
ifeq '$(HAVE_OSG)' 'no'
HAVE_OSG = $(shell if pkg-config openscenegraph --exists; then echo "yes"; else echo "no"; fi;)
ifeq '$(HAVE_OSG)' 'yes'
OSG_CXXFLAGS = $(shell pkg-config openscenegraph --cflags)
OSG_LDFLAGS = $(shell pkg-config openscenegraph --libs)
endif
endif
endif
# Try to find Bullet
ifeq '$(WANT_BT)' 'yes'
ifeq '$(HAVE_BT)' 'no'
HAVE_BT = $(shell if pkg-config bullet --exists; then echo "yes"; else echo "no"; fi;)
ifeq '$(HAVE_BT)' 'yes'
BT_CXXFLAGS = $(shell pkg-config bullet --cflags)
BT_LDFLAGS = $(shell pkg-config bullet --libs-only-L)
BT_LDFLAGS += -lBulletDynamics -lBulletCollision -lLinearMath
endif
endif
endif
# Try to find SDL
ifeq '$(WANT_SDL)' 'yes'
ifeq '$(HAVE_SDL)' 'no'
HAVE_SDL = $(shell if pkg-config sdl --exists; then echo "yes"; else echo "no"; fi;)
ifeq '$(HAVE_SDL)' 'yes'
SDL_CXXFLAGS = $(shell pkg-config sdl --cflags)
SDL_LDFLAGS = $(shell pkg-config sdl --libs)
endif
endif
endif
# Try to find OpenCV
ifeq '$(WANT_OPENCV)' 'yes'
ifeq '$(HAVE_OPENCV)' 'no'
HAVE_OPENCV = $(shell if pkg-config opencv --exists; then echo "yes"; else echo "no"; fi;)
ifeq '$(HAVE_OPENCV)' 'yes'
OPENCV_CXXFLAGS = $(shell pkg-config opencv --cflags)
OPENCV_LDFLAGS = $(shell pkg-config opencv --libs)
endif
endif
endif
ifeq '$(WANT_PHYSX)' 'yes'
ifeq '$(HAVE_PHYSX)' 'no'
PHYSX_CXXFLAGS =
PHYSX_LDFLAGS =
endif
endif
check-dep-osg:
@echo "Checking Openscenegraph..."
@if [ "$(HAVE_OSG)" != "yes" ]; then echo "Dependecy error: pkg-config can't find openscenegraph package"; else echo "Openscenegraph found"; fi;
@echo " OSG_CXXFLAGS = $(OSG_CXXFLAGS)"
@echo " OSG_LDFLAGS = $(OSG_LDFLAGS)"
check-dep-bt:
@echo "Checking Bullet..."
@if [ "$(HAVE_BT)" != "yes" ]; then echo "Dependecy error: pkg-config can't find bullet package"; else echo "Bullet found"; fi;
@echo " BT_CXXFLAGS = $(BT_CXXFLAGS)"
@echo " BT_LDFLAGS = $(BT_LDFLAGS)"
check-dep-ode:
@echo "Checking ODE..."
@if [ "$(HAVE_ODE)" != "yes" ]; then echo "Dependecy error: pkg-config can't find ode package"; else echo "ODE found"; fi;
@echo " ODE_CXXFLAGS = $(ODE_CXXFLAGS)"
@echo " ODE_LDFLAGS = $(ODE_LDFLAGS)"
check-dep-sdl:
@echo "Checking SDL..."
@if [ "$(HAVE_SDL)" != "yes" ]; then echo "Dependecy error: pkg-config can't find sdl package"; else echo "SDL found"; fi;
@echo " SDL_CXXFLAGS = $(SDL_CXXFLAGS)"
@echo " SDL_LDFLAGS = $(SDL_LDFLAGS)"
check-dep-opencv:
@echo "Checking OpenCV..."
@if [ "$(HAVE_OPENCV)" != "yes" ]; then echo "Dependecy error: pkg-config can't find OpenCV package"; else echo "Openscenegraph found"; fi;
@echo " OPENCV_CXXFLAGS = $(OPENCV_CXXFLAGS)"
@echo " OPENCV_LDFLAGS = $(OPENCV_LDFLAGS)"
check-dep-physx:
@echo "Checking PhysX..."
@echo "PhysX must be configured by hand!"
@echo " PHYSX_CXXFLAGS = $(PHYSX_CXXFLAGS)"
@echo " PHYSX_LDFLAGS = $(PHYSX_LDFLAGS)"
CHECKTARGETS =
ifeq '$(WANT_OSG)' 'yes'
CHECKTARGETS += check-dep-osg
endif
ifeq '$(WANT_ODE)' 'yes'
CHECKTARGETS += check-dep-ode
endif
ifeq '$(WANT_BT)' 'yes'
CHECKTARGETS += check-dep-bt
endif
ifeq '$(WANT_SDL)' 'yes'
CHECKTARGETS += check-dep-sdl
endif
ifeq '$(WANT_OPENCV)' 'yes'
CHECKTARGETS += check-dep-opencv
endif
ifeq '$(WANT_PHYSX)' 'yes'
CHECKTARGETS += check-dep-physx
endif
check-dep: $(CHECKTARGETS)
showvars:
@echo "SYSTEM = "$(SYSTEM)
@echo ""
@echo "CC = $(CC)"
@echo "CXX = $(CXX)"
@echo "MOC = $(MOC)"
@echo "FLEX = $(FLEX)"
@echo "AWK = $(AWK)"
@echo "SED = $(SED)"
@echo "M4 = $(M4)"
@echo "DOXYGEN = $(DOXYGEN)"
@echo "SED = $(SED)"
@echo "DIA = $(DIA)"
@echo ""
@echo "DEBUG = $(DEBUG)"
@echo "PROFIL = $(PROFIL)"
@echo "NOWALL = $(NOWALL)"
@echo "NOPEDANTIC = $(NOPEDANTIC)"
@echo ""
@echo "CFLAGS = $(CFLAGS)"
@echo "CXXFLAGS = $(CXXFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo ""
@echo "WANT_ODE = $(WANT_ODE)"
@echo "HAVE_ODE = $(HAVE_ODE)"
@echo "ODE_CXXFLAGS = $(ODE_CXXFLAGS)"
@echo "ODE_LDFLAGS = $(ODE_LDFLAGS)"
@echo ""
@echo "WANT_BT = $(WANT_BT)"
@echo "HAVE_BT = $(HAVE_BT)"
@echo "BT_CXXFLAGS = $(BT_CXXFLAGS)"
@echo "BT_LDFLAGS = $(BT_LDFLAGS)"
@echo ""
@echo "WANT_OSG = $(WANT_OSG)"
@echo "HAVE_OSG = $(HAVE_OSG)"
@echo "OSG_CXXFLAGS = $(OSG_CXXFLAGS)"
@echo "OSG_LDFLAGS = $(OSG_LDFLAGS)"
@echo ""
@echo "WANT_SDL = $(WANT_SDL)"
@echo "HAVE_SDL = $(HAVE_SDL)"
@echo "SDL_CXXFLAGS = $(SDL_CXXFLAGS)"
@echo "SDL_LDFLAGS = $(SDL_LDFLAGS)"
@echo ""
@echo "WANT_OPENCV = $(WANT_OPENCV)"
@echo "HAVE_OPENCV = $(HAVE_OPENCV)"
@echo "OPENCV_CXXFLAGS = $(OPENCV_CXXFLAGS)"
@echo "OPENCV_LDFLAGS = $(OPENCV_LDFLAGS)"
@echo ""
@echo "WANT_PHYSX = $(WANT_PHYSX)"
@echo "HAVE_PHYSX = $(HAVE_PHYSX)"
@echo "PHYSX_CXXFLAGS = $(PHYSX_CXXFLAGS)"
@echo "PHYSX_LDFLAGS = $(PHYSX_LDFLAGS)"
.DEFAULT_GOAL := all
.PHONY: showvars check-dep-osg check-dep-bt check-dep-ode check-dep-sdl