1 #########################################################################
3 # Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. #
4 # All rights reserved. Email: russ@q12.org Web: www.q12.org #
6 # This library is free software; you can redistribute it and/or #
7 # modify it under the terms of EITHER: #
8 # (1) The GNU Lesser General Public License as published by the Free #
9 # Software Foundation; either version 2.1 of the License, or (at #
10 # your option) any later version. The text of the GNU Lesser #
11 # General Public License is included with this library in the #
13 # (2) The BSD-style license that is included with this library in #
14 # the file LICENSE-BSD.TXT. #
16 # This library is distributed in the hope that it will be useful, #
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files #
19 # LICENSE.TXT and LICENSE-BSD.TXT for more details. #
21 #########################################################################
23 USER_SETTINGS=config/user-settings
24 include $(USER_SETTINGS)
25 PLATFORM_MAKEFILE=config/makefile.$(PLATFORM)
26 include $(PLATFORM_MAKEFILE)
28 ##############################################################################
29 # check some variables that were supposed to be defined
31 ifneq ($(BUILD),debug)
32 ifneq ($(BUILD),release)
33 $(error the BUILD variable is not set properly)
37 ifneq ($(PRECISION),SINGLE)
38 ifneq ($(PRECISION),DOUBLE)
39 $(error the PRECISION variable is not set properly)
43 ##############################################################################
54 ode/src/rotation.cpp \
67 ode/src/fastlsolve.c \
68 ode/src/fastltsolve.c \
72 DRAWSTUFF_SRC = drawstuff/src/drawstuff.cpp drawstuff/src/windows.cpp
73 RESOURCE_FILE=lib/resources.RES
75 DRAWSTUFF_SRC = drawstuff/src/drawstuff.cpp drawstuff/src/x11.cpp
79 DRAWSTUFF_LIB_NAME=drawstuff
85 ode/test/test_ode.cpp \
86 ode/test/test_chain2.cpp \
87 ode/test/test_hinge.cpp \
88 ode/test/test_slider.cpp \
89 ode/test/test_collision.cpp \
90 ode/test/test_boxstack.cpp \
91 ode/test/test_buggy.cpp \
92 ode/test/test_joints.cpp \
93 ode/test/test_space.cpp \
95 ode/test/test_step.cpp \
96 ode/test/test_friction.cpp
98 ode/test/test_chain1.c
99 DRAWSTUFF_TEST_SRC_CPP = \
100 drawstuff/dstest/dstest.cpp
102 CONFIGURATOR_SRC=configurator.c
103 CONFIG_H=include/ode/config.h
105 ##############################################################################
110 # add some defines depending on the build mode
111 ifeq ($(BUILD),release)
112 DEFINES+=$(C_DEF)dNODEBUG
114 ifeq ($(BUILD),debug)
115 DEFINES+=$(C_DEF)dDEBUG_ALLOC
119 ODE_PREGEN_OBJECTS=$(ODE_PREGEN_SRC:%.c=%$(OBJ))
120 ODE_OBJECTS=$(ODE_SRC:%.cpp=%$(OBJ)) $(ODE_PREGEN_OBJECTS)
121 DRAWSTUFF_OBJECTS=$(DRAWSTUFF_SRC:%.cpp=%$(OBJ)) $(RESOURCE_FILE)
123 # side-effect variables causing creation of files containing lists of
124 # filenames to be linked, to work around command-line-length limitations
125 # on outdated 16-bit operating systems. because of command-line length
126 # limitations we cannot issue a link command with all object filenames
127 # specified (because this command is too long and overflows the command
128 # buffer), but instead must create a file containing all object filenames
129 # to be linked, and specify this list-file with @listfile on the command-line.
131 # the difficult part is doing this in a flexible way; we don't want to
132 # hard-code the to-be-linked object filenames in a file, but instead
133 # want to dynamically create a file containing a list of all object filenames
134 # within the $XXX_OBJECTS makefile variables. to do this, we use side-effect
137 # idea: when these variables are EVALUATED (i.e. later during rule execution,
138 # not now during variable definition), they cause a SIDE EFFECT which creates
139 # a file with the list of all ODE object files. why the chicanery??? because
140 # if we have a command-line length limitation, no SINGLE command we issue will
141 # be able to create a file containing all object files to be linked
142 # (because that command itself would need to include all filenames, making
143 # it too long to be executed). instead, we must use the gnu-make "foreach"
144 # function, combined - probably in an unintended way - with the "shell"
145 # function. this is probably unintended because we are not using the "shell"
146 # function to return a string value for variable evaluation, but are instead
147 # using the "shell" function to cause a side effect (appending of each filename
148 # to the filename-list-file).
150 # one possible snag is that, forbidding use of any external EXE utilities and
151 # relying only on the facilities provided by the outdated 16-bit operating
152 # system, there is no way to issue a SERIES of commands which append text to
153 # the end of a file WITHOUT adding newlines. therefore, the list of to-be-
154 # linked object files is separated by newlines in the list file. fortunately,
155 # the linker utility for this outdated 16-bit operating system accepts
156 # filenames on separate lines in the list file.
158 # remember: when we evaluate these variables later, this causes the creation
159 # of the appropriate list file.
160 ifeq ($(WINDOWS16),1)
161 SIDE_EFFECT_ODE_OBJLIST = $(foreach o,$(ODE_OBJECTS),$(shell echo $(o) >> odeobj.txt ))
162 SIDE_EFFECT_DRAWSTUFF_OBJLIST = $(foreach o,$(DRAWSTUFF_OBJECTS),$(shell echo $(o) >> dsobj.txt ))
166 ODE_LIB=$(LIBPATH)/$(LIB_PREFIX)$(ODE_LIB_NAME)$(LIB_SUFFIX)
167 DRAWSTUFF_LIB=$(LIBPATH)/$(LIB_PREFIX)$(DRAWSTUFF_LIB_NAME)$(LIB_SUFFIX)
169 # executable file names
170 ODE_TEST_EXE=$(ODE_TEST_SRC_CPP:%.cpp=%.exe) $(ODE_TEST_SRC_C:%.c=%.exe)
171 DRAWSTUFF_TEST_EXE=$(DRAWSTUFF_TEST_SRC_CPP:%.cpp=%.exe)
172 CONFIGURATOR_EXE=$(CONFIGURATOR_SRC:%.c=%.exe)
174 ##############################################################################
177 # NOTE: the '.c' files are pregenerated sources, and must be compiled with
178 # -O1 optimization. that is why the rule for .c files is a bit different.
179 # why should it be compiled with O1? it is numerical code that is generated
180 # by fbuild. O1 optimization is used to preserve the operation orders that
181 # were discovered by fbuild to be the fastest on that platform. believe it or
182 # not, O2 makes this code run much slower for most compilers.
185 all: ode-lib drawstuff-lib ode-test drawstuff-test
188 ode-lib: configure $(ODE_LIB)
189 drawstuff-lib: configure $(DRAWSTUFF_LIB)
190 ode-test: ode-lib drawstuff-lib $(ODE_TEST_EXE)
191 drawstuff-test: drawstuff-lib $(DRAWSTUFF_TEST_EXE)
193 ifndef ODE_LIB_AR_RULE
194 ODE_LIB_AR_RULE=$(AR)$@
197 $(ODE_LIB): pre_ode_lib $(ODE_OBJECTS)
198 ifeq ($(WINDOWS16),1)
199 # if we have a command-line-length limitation, then dynamically create
200 # a file containing all object filenames, and pass this file to the linker
201 # instead of directly specifying the object filenames on the command line.
202 # the very evaluation of the following variable causes creation of file
204 $(SIDE_EFFECT_ODE_OBJLIST)
205 $(ODE_LIB_AR_RULE) @odeobj.txt
207 # if we have no command-line-length limitation, directly specify all
208 # object files to be linked.
209 $(ODE_LIB_AR_RULE) $(ODE_OBJECTS)
216 $(DRAWSTUFF_LIB): pre_drawstuff_lib $(DRAWSTUFF_OBJECTS)
218 # if we have a command-line-length limitation, then do the same as above.
219 $(SIDE_EFFECT_DRAWSTUFF_OBJLIST)
222 # if we have no command-line-length limitation, directly specify all object
223 # files to be linked.
224 $(AR)$@ $(DRAWSTUFF_OBJECTS)
230 # rules to be executed before library linking starts: delete list file (if one is used)
234 $(DEL_CMD) odeobj.txt
243 -$(DEL_CMD) $(ODE_OBJECTS) $(ODE_TEST_EXE) $(ODE_LIB) $(DRAWSTUFF_OBJECTS) $(DRAWSTUFF_TEST_EXE) $(DRAWSTUFF_LIB) ode/test/*$(OBJ) drawstuff/dstest/*$(OBJ) $(CONFIGURATOR_EXE) $(CONFIG_H)
246 $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)1 $(C_OUT)$@ $<
249 $(CC) $(C_FLAGS) $(C_INC)$(INCPATH) $(DEFINES) $(C_OPT)$(OPT) $(C_OUT)$@ $<
252 $(CC) $(C_EXEOUT)$@ $< $(ODE_LIB) $(DRAWSTUFF_LIB) $(RESOURCE_FILE) $(LINK_OPENGL) $(LINK_MATH)
254 # windows specific rules
256 lib/resources.RES: drawstuff/src/resources.rc
262 configure: $(CONFIG_H)
264 $(CONFIG_H): $(CONFIGURATOR_EXE) $(USER_SETTINGS) $(PLATFORM_MAKEFILE)
265 $(THIS_DIR)$(CONFIGURATOR_EXE) $(CONFIG_H) "$(CC) $(DEFINES) $(C_EXEOUT)" "$(DEL_CMD)" $(THIS_DIR)
267 $(CONFIGURATOR_EXE): $(CONFIGURATOR_SRC) $(USER_SETTINGS) $(PLATFORM_MAKEFILE)
268 $(CC) $(C_DEF)d$(PRECISION) $(DEFINES) $(C_EXEOUT)$@ $<
271 # unix-gcc specific dependency making
273 DEP_RULE=gcc -M $(C_INC)$(INCPATH) $(DEFINES)
274 depend: $(ODE_SRC) $(ODE_PREGEN_SRC) $(DRAWSTUFF_SRC) $(ODE_TEST_SRC_CPP) $(ODE_TEST_SRC_C) $(DRAWSTUFF_TEST_SRC_CPP)
275 $(DEP_RULE) $(ODE_SRC) $(ODE_PREGEN_SRC) | tools/process_deps ode/src/ > Makefile.deps
276 $(DEP_RULE) $(DRAWSTUFF_SRC) | tools/process_deps drawstuff/src/ >> Makefile.deps
277 $(DEP_RULE) $(ODE_TEST_SRC_CPP) | tools/process_deps ode/test/ >> Makefile.deps
278 $(DEP_RULE) $(DRAWSTUFF_TEST_SRC_CPP) | tools/process_deps drawstuff/dstest/ >> Makefile.deps
280 include Makefile.deps