File: Makefile

package info (click to toggle)
ode 1:0.5.dfsg-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,692 kB
  • ctags: 4,152
  • sloc: cpp: 35,936; ansic: 2,496; makefile: 283; perl: 273; sh: 65
file content (373 lines) | stat: -rw-r--r-- 13,062 bytes parent folder | download | duplicates (2)
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#########################################################################
#                                                                       #
# Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.       #
# All rights reserved.  Email: russ@q12.org   Web: www.q12.org          #
#                                                                       #
# This library is free software; you can redistribute it and/or         #
# modify it under the terms of EITHER:                                  #
#   (1) The GNU Lesser General Public License as published by the Free  #
#       Software Foundation; either version 2.1 of the License, or (at  #
#       your option) any later version. The text of the GNU Lesser      #
#       General Public License is included with this library in the     #
#       file LICENSE.TXT.                                               #
#   (2) The BSD-style license that is included with this library in     #
#       the file LICENSE-BSD.TXT.                                       #
#                                                                       #
# This library 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 files    #
# LICENSE.TXT and LICENSE-BSD.TXT for more details.                     #
#                                                                       #
#########################################################################

.SUFFIXES:

USER_SETTINGS=config/user-settings
include $(USER_SETTINGS)
PLATFORM_MAKEFILE=config/makefile.$(PLATFORM)
include $(PLATFORM_MAKEFILE)

##############################################################################
# check some variables that were supposed to be defined

ifneq ($(BUILD),debug)
ifneq ($(BUILD),release)
$(error the BUILD variable is not set properly)
endif
endif

ifneq ($(PRECISION),SINGLE)
ifneq ($(PRECISION),DOUBLE)
$(error the PRECISION variable is not set properly)
endif
endif

##############################################################################
# package settings

ODE_SRC = \
	ode/src/array.cpp \
	ode/src/error.cpp \
	ode/src/memory.cpp \
	ode/src/obstack.cpp \
	ode/src/odemath.cpp \
	ode/src/matrix.cpp \
	ode/src/misc.cpp \
	ode/src/rotation.cpp \
	ode/src/mass.cpp \
	ode/src/ode.cpp \
	ode/src/step.cpp \
	ode/src/stepfast.cpp \
	ode/src/quickstep.cpp \
	ode/src/util.cpp \
	ode/src/lcp.cpp \
	ode/src/joint.cpp \
	ode/src/timer.cpp \
	ode/src/mat.cpp \
	ode/src/testing.cpp \
	ode/src/export-dif.cpp \
	ode/src/collision_kernel.cpp \
	ode/src/collision_util.cpp \
	ode/src/collision_std.cpp \
	ode/src/collision_space.cpp \
	ode/src/collision_transform.cpp \
	ode/src/collision_quadtreespace.cpp

ifdef OPCODE_DIRECTORY
ODE_SRC +=ode/src/collision_trimesh.cpp \
	ode/src/collision_trimesh_sphere.cpp \
	ode/src/collision_trimesh_box.cpp \
	ode/src/collision_trimesh_trimesh.cpp \
	ode/src/collision_trimesh_ray.cpp \
	ode/src/collision_trimesh_ccylinder.cpp \
	ode/src/collision_trimesh_distance.cpp
endif

ODE_PREGEN_SRC = \
	ode/src/fastldlt.c \
	ode/src/fastlsolve.c \
	ode/src/fastltsolve.c \
	ode/src/fastdot.c

ifeq ($(WINDOWS),1)
DRAWSTUFF_SRC = drawstuff/src/drawstuff.cpp drawstuff/src/windows.cpp
RESOURCE_FILE=lib/resources.RES
else
DRAWSTUFF_SRC = drawstuff/src/drawstuff.cpp drawstuff/src/x11.cpp
endif

ODE_LIB_NAME=ode
DRAWSTUFF_LIB_NAME=drawstuff

INCPATH=include
LIBPATH=lib

ODE_TEST_SRC_CPP = \
	ode/test/test_ode.cpp \
	ode/test/test_chain2.cpp \
	ode/test/test_hinge.cpp \
	ode/test/test_slider.cpp \
	ode/test/test_collision.cpp \
	ode/test/test_boxstack.cpp \
	ode/test/test_buggy.cpp \
	ode/test/test_crash.cpp \
	ode/test/test_joints.cpp \
	ode/test/test_space.cpp \
	ode/test/test_I.cpp \
	ode/test/test_step.cpp \
	ode/test/test_friction.cpp \
	ode/test/test_space_stress.cpp
ifdef OPCODE_DIRECTORY
ODE_TEST_SRC_CPP += \
	ode/test/test_trimesh.cpp \
	ode/test/test_moving_trimesh.cpp
endif

ODE_TEST_SRC_C = \
	ode/test/test_chain1.c
DRAWSTUFF_TEST_SRC_CPP = \
	drawstuff/dstest/dstest.cpp

CONFIGURATOR_SRC=configurator.c
CONFIG_H=include/ode/config.h

##############################################################################
# OPCODE build rules

ifdef OPCODE_DIRECTORY

ODE_SRC+=\
	OPCODE/OPC_AABBCollider.cpp \
	OPCODE/OPC_AABBTree.cpp \
	OPCODE/OPC_BaseModel.cpp \
	OPCODE/OPC_BoxPruning.cpp \
	OPCODE/OPC_Collider.cpp \
	OPCODE/OPC_Common.cpp \
	OPCODE/OPC_HybridModel.cpp \
	OPCODE/OPC_LSSCollider.cpp \
	OPCODE/OPC_MeshInterface.cpp \
	OPCODE/OPC_Model.cpp \
	OPCODE/OPC_OBBCollider.cpp \
	OPCODE/Opcode.cpp \
	OPCODE/OPC_OptimizedTree.cpp \
	OPCODE/OPC_Picking.cpp \
	OPCODE/OPC_PlanesCollider.cpp \
	OPCODE/OPC_RayCollider.cpp \
	OPCODE/OPC_SphereCollider.cpp \
	OPCODE/OPC_SweepAndPrune.cpp \
	OPCODE/OPC_TreeBuilders.cpp \
	OPCODE/OPC_TreeCollider.cpp \
	OPCODE/OPC_VolumeCollider.cpp \
	OPCODE/Ice/IceAABB.cpp \
	OPCODE/Ice/IceContainer.cpp \
	OPCODE/Ice/IceHPoint.cpp \
	OPCODE/Ice/IceIndexedTriangle.cpp \
	OPCODE/Ice/IceMatrix3x3.cpp \
	OPCODE/Ice/IceMatrix4x4.cpp \
	OPCODE/Ice/IceOBB.cpp \
	OPCODE/Ice/IcePlane.cpp \
	OPCODE/Ice/IcePoint.cpp \
	OPCODE/Ice/IceRandom.cpp \
	OPCODE/Ice/IceRay.cpp \
	OPCODE/Ice/IceRevisitedRadix.cpp \
	OPCODE/Ice/IceSegment.cpp \
	OPCODE/Ice/IceTriangle.cpp \
	OPCODE/Ice/IceUtils.cpp

# GCC versions 3.X generate bad code for some modules
# with -O2, so we use -O1 until we get this tied down a bit more.
# There are at least two problematic code modules with -O2, one of
# which is OPC_TreeCollider (if you identify the other, which causes
# problems with trimesh-trimesh collisions, then let us know).
ifeq ($(CC),g++)
OPCODE/%.o: OPT=1
endif

endif

##############################################################################
# derived things

DEFINES=

# support TriMesh/OPCODE on the compiler command line
ifdef OPCODE_DIRECTORY
DEFINES+=$(C_DEF)dTRIMESH_ENABLED
INC_OPCODE=$(C_INC)$(OPCODE_DIRECTORY)
endif

# add some defines depending on the build mode
ifeq ($(BUILD),release)
DEFINES+=$(C_DEF)dNODEBUG
endif

# object file names
ODE_PREGEN_OBJECTS=$(ODE_PREGEN_SRC:%.c=%$(OBJ))
ODE_OBJECTS=$(ODE_SRC:%.cpp=%$(OBJ)) $(ODE_PREGEN_OBJECTS)
DRAWSTUFF_OBJECTS=$(DRAWSTUFF_SRC:%.cpp=%$(OBJ)) $(RESOURCE_FILE)

# side-effect variables causing creation of files containing lists of
# filenames to be linked, to work around command-line-length limitations
# on outdated 16-bit operating systems. because of command-line length
# limitations we cannot issue a link command with all object filenames
# specified (because this command is too long and overflows the command
# buffer), but instead must create a file containing all object filenames
# to be linked, and specify this list-file with @listfile on the command-line.
#
# the difficult part is doing this in a flexible way; we don't want to
# hard-code the to-be-linked object filenames in a file, but instead
# want to dynamically create a file containing a list of all object filenames
# within the $XXX_OBJECTS makefile variables. to do this, we use side-effect
# variables.
#
# idea: when these variables are EVALUATED (i.e. later during rule execution,
# not now during variable definition), they cause a SIDE EFFECT which creates
# a file with the list of all ODE object files. why the chicanery??? because
# if we have a command-line length limitation, no SINGLE command we issue will 
# be able to create a file containing all object files to be linked
# (because that command itself would need to include all filenames, making
# it too long to be executed). instead, we must use the gnu-make "foreach"
# function, combined - probably in an unintended way - with the "shell" 
# function. this is probably unintended because we are not using the "shell"
# function to return a string value for variable evaluation, but are instead 
# using the "shell" function to cause a side effect (appending of each filename
# to the filename-list-file).
#
# one possible snag is that, forbidding use of any external EXE utilities and
# relying only on the facilities provided by the outdated 16-bit operating
# system, there is no way to issue a SERIES of commands which append text to
# the end of a file WITHOUT adding newlines. therefore, the list of to-be-
# linked object files is separated by newlines in the list file. fortunately,
# the linker utility for this outdated 16-bit operating system accepts
# filenames on separate lines in the list file.

# remember: when we evaluate these variables later, this causes the creation
# of the appropriate list file.
ifeq ($(WINDOWS16),1)
SIDE_EFFECT_ODE_OBJLIST = $(foreach o,$(ODE_OBJECTS),$(shell echo $(o) >> odeobj.txt ))
SIDE_EFFECT_DRAWSTUFF_OBJLIST = $(foreach o,$(DRAWSTUFF_OBJECTS),$(shell echo $(o) >> dsobj.txt ))
endif

# library file names
ODE_LIB=$(LIBPATH)/$(LIB_PREFIX)$(ODE_LIB_NAME)$(LIB_SUFFIX)
ODE_SHARED_SUFFIX=.so.0
ODE_SHARED_LIB=$(LIBPATH)/$(LIB_PREFIX)$(ODE_LIB_NAME)$(ODE_SHARED_SUFFIX)
DRAWSTUFF_LIB=$(LIBPATH)/$(LIB_PREFIX)$(DRAWSTUFF_LIB_NAME)$(LIB_SUFFIX)

# executable file names
ODE_TEST_EXE=$(ODE_TEST_SRC_CPP:%.cpp=%.exe) $(ODE_TEST_SRC_C:%.c=%.exe)
DRAWSTUFF_TEST_EXE=$(DRAWSTUFF_TEST_SRC_CPP:%.cpp=%.exe)
CONFIGURATOR_EXE=$(CONFIGURATOR_SRC:%.c=%.exe)

##############################################################################
# rules
#
# NOTE: the '.c' files are pregenerated sources, and must be compiled with
# -O1 optimization. that is why the rule for .c files is a bit different.
# why should it be compiled with O1? it is numerical code that is generated
# by fbuild. O1 optimization is used to preserve the operation orders that
# were discovered by fbuild to be the fastest on that platform. believe it or
# not, O2 makes this code run much slower for most compilers.

all: ode-lib drawstuff-lib ode-test drawstuff-test
	@echo SUCCESS

ode-lib: configure $(ODE_LIB)
ode-shared-lib: configure $(ODE_SHARED_LIB)
drawstuff-lib: configure $(DRAWSTUFF_LIB)
ode-test: ode-lib drawstuff-lib $(ODE_TEST_EXE)
drawstuff-test: drawstuff-lib $(DRAWSTUFF_TEST_EXE)

ifndef ODE_LIB_AR_RULE
ODE_LIB_AR_RULE=$(AR)$@
endif

$(ODE_LIB): pre_ode_lib $(ODE_OBJECTS)
ifeq ($(WINDOWS16),1)
#   if we have a command-line-length limitation, then dynamically create
#   a file containing all object filenames, and pass this file to the linker
#   instead of directly specifying the object filenames on the command line.
#   the very evaluation of the following variable causes creation of file
#   odeobj.txt
	$(SIDE_EFFECT_ODE_OBJLIST)
	$(ODE_LIB_AR_RULE) @odeobj.txt
else
#   if we have no command-line-length limitation, directly specify all
#   object files to be linked.
	$(ODE_LIB_AR_RULE) $(ODE_OBJECTS)
endif

ifdef RANLIB
	$(RANLIB) $@
endif

$(ODE_SHARED_LIB): pre_ode_lib $(ODE_OBJECTS)
	$(CC) -o $@ $(PICFLAGS) -shared -Wl,-soname,$(LIB_PREFIX)$(ODE_LIB_NAME)$(ODE_SHARED_SUFFIX) $(ODE_OBJECTS)

$(DRAWSTUFF_LIB): pre_drawstuff_lib $(DRAWSTUFF_OBJECTS)
ifeq ($WINDOWS16),1)
#   if we have a command-line-length limitation, then do the same as above.
	$(SIDE_EFFECT_DRAWSTUFF_OBJLIST)
	$(AR)$@ @dsobj.txt
else
#   if we have no command-line-length limitation, directly specify all object
#   files to be linked.
	$(AR)$@ $(DRAWSTUFF_OBJECTS)
endif
ifdef RANLIB
	$(RANLIB) $@
endif

# rules to be executed before library linking starts: delete list file (if one is used)

pre_ode_lib:
ifeq ($WINDOWS16),1)
	$(DEL_CMD) odeobj.txt
endif

pre_drawstuff_lib:
ifeq ($WINDOWS16),1)
	$(DEL_CMD) dsobj.txt
endif

clean:
	-$(DEL_CMD) $(ODE_OBJECTS) $(ODE_TEST_EXE) $(ODE_LIB) $(ODE_SHARED_LIB) $(DRAWSTUFF_OBJECTS) $(DRAWSTUFF_TEST_EXE) $(DRAWSTUFF_LIB) ode/test/*$(OBJ) drawstuff/dstest/*$(OBJ) $(CONFIGURATOR_EXE) $(CONFIG_H)
	-$(DEL_CMD) OPCODE/*.obj OPCODE/*.o OPCODE/Ice/*.obj OPCODE/Ice/*.o

%$(OBJ): %.c
	$(CC) $(PICFLAGS) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)1 $(C_OUT)$@ $<

%$(OBJ): %.cpp
	$(CC) $(PICFLAGS) $(C_FLAGS) $(C_INC)$(INCPATH) $(INC_OPCODE) $(DEFINES) $(C_OPT)$(OPT) $(C_OUT)$@ $<

%.exe: %$(OBJ)
	$(CC) $(C_EXEOUT)$@ $< $(ODE_LIB) $(DRAWSTUFF_LIB) $(RESOURCE_FILE) $(LINK_OPENGL) $(LINK_MATH)


# windows specific rules

lib/resources.RES: drawstuff/src/resources.rc
	$(RC_RULE)


# configurator rules

configure: $(CONFIG_H)

$(CONFIG_H): $(CONFIGURATOR_EXE) $(USER_SETTINGS) $(PLATFORM_MAKEFILE)
	$(THIS_DIR1)$(CONFIGURATOR_EXE) $(CONFIG_H) "$(CC) $(DEFINES) $(LINK_MATH) $(C_EXEOUT)" $(THIS_DIR2)

$(CONFIGURATOR_EXE): $(CONFIGURATOR_SRC) $(USER_SETTINGS) $(PLATFORM_MAKEFILE)
	$(CC) $(C_DEF)d$(PRECISION) $(DEFINES) $(C_EXEOUT)$@ $<


# unix-gcc specific dependency making

DEP_RULE=gcc -M $(C_INC)$(INCPATH) $(DEFINES)
depend:
	$(DEP_RULE) $(ODE_SRC) $(ODE_PREGEN_SRC) | tools/process_deps ode/src/ > Makefile.deps
	$(DEP_RULE) $(DRAWSTUFF_SRC) | tools/process_deps drawstuff/src/ >> Makefile.deps
	$(DEP_RULE) $(ODE_TEST_SRC_CPP) | tools/process_deps ode/test/ >> Makefile.deps
	$(DEP_RULE) $(DRAWSTUFF_TEST_SRC_CPP) | tools/process_deps drawstuff/dstest/ >> Makefile.deps

include Makefile.deps