1 # -*- mode: gnumakefile; tab-width: 8; indent-tabs-mode: t; -*-
6 # ***** BEGIN GPL LICENSE BLOCK *****
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software Foundation,
20 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 # All rights reserved.
25 # The Original Code is: all of this file.
29 # ***** END GPL LICENSE BLOCK *****
33 include nan_definitions.mk
35 CPPFLAGS ?= $(NAN_CPPFLAGS)
37 # common parts ---------------------------------------------------
39 # Uncomment next lines to enable integrated game engine
40 ifneq ($(NAN_NO_KETSJI), true)
41 CFLAGS += -DGAMEBLENDER=1
42 CFLAGS += -DUSE_SUMO_SOLID
43 CCFLAGS += -DUSE_SUMO_SOLID
44 ifeq ($(NAN_USE_BULLET), true)
45 CFLAGS += -DUSE_BULLET -DWITH_BULLET
46 CCFLAGS += -DUSE_BULLET -DWITH_BULLET
49 CPPFLAGS += -DNO_KETSJI
52 ifeq ($(BF_PROFILE), true)
57 ifeq ($(WITH_BF_OPENMP), true)
63 CFLAGS += $(NAN_DEBUG)
64 CCFLAGS += $(NAN_DEBUG)
67 REL_CFLAGS += -DNDEBUG
68 REL_CCFLAGS += -DNDEBUG
72 # OS dependent parts ---------------------------------------------------
78 CFLAGS += -pipe -fPIC -ffast-math -mcpu=7450 -mtune=G5 -funsigned-char -fno-strict-aliasing
79 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
81 CFLAGS += -pipe -fPIC -ffast-math -march=pentium-m -funsigned-char -fno-strict-aliasing
82 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
86 CPPFLAGS += -D_THREAD_SAFE
88 OPENGL_HEADERS = /System/Library/Frameworks/OpenGL.framework
100 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
101 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
104 CPPFLAGS += -D_THREAD_SAFE
106 OPENGL_HEADERS = /usr/X11R6/include
107 JAVA_HEADERS = /usr/local/jdk1.3.1/include
108 JAVA_SYSTEM_HEADERS = /usr/local/jdk1.3.1/include/freebsd
115 ifeq ($(IRIX_USE_GCC),true)
118 CFLAGS += -fPIC -funsigned-char -fno-strict-aliasing -mabi=n32 -mips4
119 CCFLAGS += -fPIC -fpermissive -funsigned-char -fno-strict-aliasing -mabi=n32 -mips4
122 CPPFLAGS += -DXP_UNIX
123 DBG_CFLAGS += -g3 -gdwarf-2 -ggdb
124 DBG_CCFLAGS += -g3 -gdwarf-2 -ggdb
128 CFLAGS += -n32 -mips3 -Xcpluscomm
129 CCFLAGS += -n32 -mips3 -Xcpluscomm -LANG:std
130 ifdef MIPS73_ISOHEADERS
131 CCFLAGS += -LANG:libc_in_namespace_std=off -I$(MIPS73_ISOHEADERS)
133 CCFLAGS += -LANG:libc_in_namespace_std=off
135 REL_CFLAGS += -n32 -mips3 -O2 -OPT:Olimit=0
136 REL_CCFLAGS += -n32 -mips3 -O2 -OPT:Olimit=0
138 OPENGL_HEADERS = /usr/include
142 ARFLAGSQUIET = -ar -o
149 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
150 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
158 OPENGL_HEADERS = /usr/X11R6/include
167 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
168 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
172 CPPFLAGS += -D__FreeBSD__
173 OPENGL_HEADERS = /usr/X11R6/include
180 # Adding gcc flag to $CC is not good, however if its not there makesdna wont build - Campbell
181 ifeq (x86_64, $(findstring x86_64, $(CPU)))
193 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
194 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
195 # CFLAGS += "-fast -xdepend -xarch=v8plus -xO3 -xlibmil -KPIC -DPIC -xchar=unsigned"
196 # CCFLAGS += "-fast -xdepend -xarch=v8plus -xO3 -xlibmil -xlibmopt -features=tmplife -norunpath -KPIC -DPIC -xchar=unsigned"
198 # Note, you might still want to compile a 32 bit binary if you have a 64bit system. if so remove the following lines
199 # ifeq ($(findstring 64,$(CPU)), 64)
208 # ifeq ($(CPU),sparc)
209 ifeq ($(findstring sparc,$(CPU)), sparc)
210 OPENGL_HEADERS = /usr/openwin/share/include
211 CPPFLAGS += -DSUN_OGL_NO_VERTEX_MACROS
212 JAVA_HEADERS = /usr/java/include
213 JAVA_SYSTEM_HEADERS = /usr/java/include/solaris
215 # OPENGL_HEADERS = /usr/X11/include/mesa
216 OPENGL_HEADERS = /usr/X11/include/
224 ifeq ($(FREE_WINDOWS),true)
227 CFLAGS += -pipe -mno-cygwin -mwindows -funsigned-char -fno-strict-aliasing
228 CCFLAGS += -pipe -mno-cygwin -mwindows -funsigned-char -fno-strict-aliasing
229 CPPFLAGS += -DFREE_WINDOWS
233 #OPENGL_HEADERS = /usr/include/w32api
238 WINRC = $(wildcard *.rc)
241 CC = $(SRCHOME)/tools/cygwin/cl_wrapper.pl
242 CCC = $(SRCHOME)/tools/cygwin/cl_wrapper.pl
243 JAVAC = $(SRCHOME)/tools/cygwin/java_wrapper.pl -c
244 JAVAH = $(SRCHOME)/tools/cygwin/java_wrapper.pl -h
246 REL_CCFLAGS += /O2 -GX
247 DBG_CFLAGS += /Fd$(DIR)/debug/
248 DBG_CCFLAGS += /Fd$(DIR)/debug/
253 CPPFLAGS += -DWIN32 -D_WIN32 -D__WIN32
254 CPPFLAGS += -D_M_IX86
255 CPPFLAGS += -I"/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/include"
256 JAVA_HEADERS = /cygdrive/c/j2sdk1.4.0-beta3/include
257 JAVA_SYSTEM_HEADERS = /cygdrive/c/j2sdk1.4.0-beta3/include/win32
258 CPP = $(SRCHOME)/tools/cygwin/cl_wrapper.pl
262 WINRC = $(wildcard *.rc)
266 ifeq (debug, $(findstring debug, $(MAKECMDGOALS)))
267 export DEBUG_DIR=debug/
270 ifneq (x$(DEBUG_DIR), x)
271 CFLAGS +=$(DBG_CFLAGS)
272 CCFLAGS+=$(DBG_CCFLAGS)
274 CFLAGS +=$(REL_CFLAGS)
275 CCFLAGS+=$(REL_CCFLAGS)
278 # Note: include nan_warn's LEVEL_*_WARNINGS after CC/OS have been set.
285 $(DIR)/$(DEBUG_DIR)%.o: %.c
287 @set -e; $(CC) -M $(CPPFLAGS) $< 2>/dev/null \
288 | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \
289 > $(DIR)/$(DEBUG_DIR)$*.d; \
290 [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$(DEBUG_DIR)$*.d
294 @$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
296 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
299 $(DIR)/$(DEBUG_DIR)%.o: %.cpp
301 @set -e; $(CCC) -M $(CPPFLAGS) $< 2>/dev/null \
302 | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \
303 > $(DIR)/$(DEBUG_DIR)$*.d; \
304 [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$(DEBUG_DIR)$*.d
308 @$(CCC) -c $(CCFLAGS) $(CPPFLAGS) $< -o $@
310 $(CCC) -c $(CCFLAGS) $(CPPFLAGS) $< -o $@
313 $(DIR)/$(DEBUG_DIR)%.res: %.rc
314 ifeq ($(FREE_WINDOWS),true)
315 windres $< -O coff -o $@
317 $(SRCHOME)/tools/cygwin/cl_wrapper.pl - rc /fo$@ $<
320 $(DIR)/$(DEBUG_DIR)%.class: %.java
322 $(JAVAC) -verbose -g -deprecation -sourcepath . -classpath "$(JARS)" -d $(DIR)/$(DEBUG_DIR) $<
324 $(JAVAC) -verbose -g -deprecation -d $(DIR)/$(DEBUG_DIR) $<
327 $(DIR)/$(DEBUG_DIR)%.h: $(DIR)/$(DEBUG_DIR)%.class
328 $(JAVAH) -classpath $(DIR)/$(DEBUG_DIR) -d $(DIR)/$(DEBUG_DIR) -jni $*
331 @echo "WARNING: Fake header creation rule used, dependencies will be remade"
333 CSRCS ?= $(wildcard *.c)
334 CCSRCS ?= $(wildcard *.cpp)
335 JSRCS ?= $(wildcard *.java)
338 -include $(CSRCS:%.c=$(DIR)/$(DEBUG_DIR)%.d) $(CCSRCS:%.cpp=$(DIR)/$(DEBUG_DIR)%.d)
342 OBJS_AR += $(CSRCS:%.c=%.o)
343 OBJS_AR += $(CCSRCS:%.cpp=%.o)
344 OBJS_AR += $(WINRC:%.rc=%.res)
346 OBJS += $(CSRCS:%.c=$(DIR)/$(DEBUG_DIR)%.o)
347 OBJS += $(CCSRCS:%.cpp=$(DIR)/$(DEBUG_DIR)%.o)
348 OBJS += $(WINRC:%.rc=$(DIR)/$(DEBUG_DIR)%.res)
350 JCLASS += $(JSRCS:%.java=$(DIR)/$(DEBUG_DIR)%.class)
352 LIB_a = $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a
355 # $OBJS can be empty except for some spaces
356 ifneq (x, x$(strip $(OBJS)))
360 @echo " -- lib: lib$(LIBNAME).a -- "
361 @cd $(DIR)/$(DEBUG_DIR); $(AR) $(ARFLAGSQUIET) $@ $(OBJS_AR)
363 cd $(DIR)/$(DEBUG_DIR); $(AR) $(ARFLAGS) $@ $(OBJS_AR)
367 @echo " -- lib: lib$(LIBNAME).a -- "
368 @$(AR) $(ARFLAGSQUIET) $@ $?
370 $(AR) $(ARFLAGS) $@ $?
378 ALLTARGETS ?= $(LIB_a)
380 all debug :: makedir $(ALLTARGETS)
385 @echo "====> make creator subtarget in `pwd | sed 's/^.*develop\///'`"
386 @$(MAKE) makedir DIR=$(DIR)/$(DEBUG_DIR)cre
387 @$(MAKE) lib CSRCS="$(CRE_CSRCS)" LIBNAME=$(LIBNAME)$@
390 @echo "====> make publisher subtarget in `pwd | sed 's/^.*develop\///'`"
391 @$(MAKE) makedir DIR=$(DIR)/$(DEBUG_DIR)pub
392 @$(MAKE) lib CSRCS="$(PUB_CSRCS)" LIBNAME=$(LIBNAME)$@
395 @echo "====> make player subtarget in `pwd | sed 's/^.*develop\///'`"
396 @$(MAKE) makedir DIR=$(DIR)/player/$(DEBUG_DIR)
397 @$(MAKE) lib CSRCS="$(SAP_CSRCS)" LIBNAME=$(LIBNAME)$@
399 clean:: optclean debugclean
402 @-[ ! -d $(DIR) ] || ( cd $(DIR) && \
403 $(RM) *.o *.a *.d *.res ii_files/*.ii *.class *.h )
406 @-[ ! -d $(DIR)/debug ] || ( cd $(DIR)/debug && \
407 $(RM) *.o *.a *.d *.res ii_files/*.ii *.class *.h )
411 @# don't use mkdir -p. Cygwin will try to make network paths and fail
412 @[ -d $(DIR) ] || mkdir $(DIR)
413 @[ -d $(DIR)/debug ] || mkdir $(DIR)/debug