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 ifeq ($(NAN_USE_BULLET), true)
43 CFLAGS += -DUSE_BULLET
44 CCFLAGS += -DUSE_BULLET
47 CPPFLAGS += -DNO_KETSJI
50 ifeq ($(BF_PROFILE), true)
55 ifeq ($(WITH_BF_OPENMP), true)
61 CFLAGS += $(NAN_DEBUG)
62 CCFLAGS += $(NAN_DEBUG)
65 REL_CFLAGS += -DNDEBUG
66 REL_CCFLAGS += -DNDEBUG
70 # OS dependent parts ---------------------------------------------------
76 CFLAGS += -pipe -fPIC -ffast-math -mcpu=7450 -mtune=G5 -funsigned-char -fno-strict-aliasing
77 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
79 CFLAGS += -pipe -fPIC -ffast-math -march=pentium-m -funsigned-char -fno-strict-aliasing
80 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
84 CPPFLAGS += -D_THREAD_SAFE
86 OPENGL_HEADERS = /System/Library/Frameworks/OpenGL.framework
98 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
99 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
102 CPPFLAGS += -D_THREAD_SAFE
104 OPENGL_HEADERS = /usr/X11R6/include
105 JAVA_HEADERS = /usr/local/jdk1.3.1/include
106 JAVA_SYSTEM_HEADERS = /usr/local/jdk1.3.1/include/freebsd
113 ifeq ($(IRIX_USE_GCC),true)
116 CFLAGS += -fPIC -funsigned-char -fno-strict-aliasing -mabi=n32 -mips4
117 CCFLAGS += -fPIC -fpermissive -funsigned-char -fno-strict-aliasing -mabi=n32 -mips4
120 CPPFLAGS += -DXP_UNIX
121 DBG_CFLAGS += -g3 -gdwarf-2 -ggdb
122 DBG_CCFLAGS += -g3 -gdwarf-2 -ggdb
126 CFLAGS += -n32 -mips3 -Xcpluscomm
127 CCFLAGS += -n32 -mips3 -Xcpluscomm -LANG:std
128 ifdef MIPS73_ISOHEADERS
129 CCFLAGS += -LANG:libc_in_namespace_std=off -I$(MIPS73_ISOHEADERS)
131 CCFLAGS += -LANG:libc_in_namespace_std=off
133 REL_CFLAGS += -n32 -mips3 -O2 -OPT:Olimit=0
134 REL_CCFLAGS += -n32 -mips3 -O2 -OPT:Olimit=0
136 OPENGL_HEADERS = /usr/include
140 ARFLAGSQUIET = -ar -o
147 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
148 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
156 OPENGL_HEADERS = /usr/X11R6/include
165 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
166 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
170 CPPFLAGS += -D__FreeBSD__
171 OPENGL_HEADERS = /usr/X11R6/include
178 # Adding gcc flag to $CC is not good, however if its not there makesdna wont build - Campbell
179 ifeq (x86_64, $(findstring x86_64, $(CPU)))
191 CFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
192 CCFLAGS += -pipe -fPIC -funsigned-char -fno-strict-aliasing
193 # CFLAGS += "-fast -xdepend -xarch=v8plus -xO3 -xlibmil -KPIC -DPIC -xchar=unsigned"
194 # CCFLAGS += "-fast -xdepend -xarch=v8plus -xO3 -xlibmil -xlibmopt -features=tmplife -norunpath -KPIC -DPIC -xchar=unsigned"
196 # Note, you might still want to compile a 32 bit binary if you have a 64bit system. if so remove the following lines
197 # ifeq ($(findstring 64,$(CPU)), 64)
206 # ifeq ($(CPU),sparc)
207 ifeq ($(findstring sparc,$(CPU)), sparc)
208 OPENGL_HEADERS = /usr/openwin/share/include
209 CPPFLAGS += -DSUN_OGL_NO_VERTEX_MACROS
210 JAVA_HEADERS = /usr/java/include
211 JAVA_SYSTEM_HEADERS = /usr/java/include/solaris
213 # OPENGL_HEADERS = /usr/X11/include/mesa
214 OPENGL_HEADERS = /usr/X11/include/
222 ifeq ($(FREE_WINDOWS),true)
225 CFLAGS += -pipe -mno-cygwin -mwindows -funsigned-char -fno-strict-aliasing
226 CCFLAGS += -pipe -mno-cygwin -mwindows -funsigned-char -fno-strict-aliasing
227 CPPFLAGS += -DFREE_WINDOWS
231 #OPENGL_HEADERS = /usr/include/w32api
236 WINRC = $(wildcard *.rc)
239 CC = $(SRCHOME)/tools/cygwin/cl_wrapper.pl
240 CCC = $(SRCHOME)/tools/cygwin/cl_wrapper.pl
241 JAVAC = $(SRCHOME)/tools/cygwin/java_wrapper.pl -c
242 JAVAH = $(SRCHOME)/tools/cygwin/java_wrapper.pl -h
244 REL_CCFLAGS += /O2 -GX
245 DBG_CFLAGS += /Fd$(DIR)/debug/
246 DBG_CCFLAGS += /Fd$(DIR)/debug/
251 CPPFLAGS += -DWIN32 -D_WIN32 -D__WIN32
252 CPPFLAGS += -D_M_IX86
253 CPPFLAGS += -I"/cygdrive/c/Program Files/Microsoft Visual Studio/VC98/include"
254 JAVA_HEADERS = /cygdrive/c/j2sdk1.4.0-beta3/include
255 JAVA_SYSTEM_HEADERS = /cygdrive/c/j2sdk1.4.0-beta3/include/win32
256 CPP = $(SRCHOME)/tools/cygwin/cl_wrapper.pl
260 WINRC = $(wildcard *.rc)
264 ifeq (debug, $(findstring debug, $(MAKECMDGOALS)))
265 export DEBUG_DIR=debug/
268 ifneq (x$(DEBUG_DIR), x)
269 CFLAGS +=$(DBG_CFLAGS)
270 CCFLAGS+=$(DBG_CCFLAGS)
272 CFLAGS +=$(REL_CFLAGS)
273 CCFLAGS+=$(REL_CCFLAGS)
276 # Note: include nan_warn's LEVEL_*_WARNINGS after CC/OS have been set.
283 $(DIR)/$(DEBUG_DIR)%.o: %.c
285 @set -e; $(CC) -M $(CPPFLAGS) $< 2>/dev/null \
286 | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \
287 > $(DIR)/$(DEBUG_DIR)$*.d; \
288 [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$(DEBUG_DIR)$*.d
292 @$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
294 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
297 $(DIR)/$(DEBUG_DIR)%.o: %.cpp
299 @set -e; $(CCC) -M $(CPPFLAGS) $< 2>/dev/null \
300 | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \
301 > $(DIR)/$(DEBUG_DIR)$*.d; \
302 [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$(DEBUG_DIR)$*.d
306 @$(CCC) -c $(CCFLAGS) $(CPPFLAGS) $< -o $@
308 $(CCC) -c $(CCFLAGS) $(CPPFLAGS) $< -o $@
311 $(DIR)/$(DEBUG_DIR)%.res: %.rc
312 ifeq ($(FREE_WINDOWS),true)
313 windres $< -O coff -o $@
315 $(SRCHOME)/tools/cygwin/cl_wrapper.pl - rc /fo$@ $<
318 $(DIR)/$(DEBUG_DIR)%.class: %.java
320 $(JAVAC) -verbose -g -deprecation -sourcepath . -classpath "$(JARS)" -d $(DIR)/$(DEBUG_DIR) $<
322 $(JAVAC) -verbose -g -deprecation -d $(DIR)/$(DEBUG_DIR) $<
325 $(DIR)/$(DEBUG_DIR)%.h: $(DIR)/$(DEBUG_DIR)%.class
326 $(JAVAH) -classpath $(DIR)/$(DEBUG_DIR) -d $(DIR)/$(DEBUG_DIR) -jni $*
329 @echo "WARNING: Fake header creation rule used, dependencies will be remade"
331 CSRCS ?= $(wildcard *.c)
332 CCSRCS ?= $(wildcard *.cpp)
333 JSRCS ?= $(wildcard *.java)
336 -include $(CSRCS:%.c=$(DIR)/$(DEBUG_DIR)%.d) $(CCSRCS:%.cpp=$(DIR)/$(DEBUG_DIR)%.d)
340 OBJS_AR += $(CSRCS:%.c=%.o)
341 OBJS_AR += $(CCSRCS:%.cpp=%.o)
342 OBJS_AR += $(WINRC:%.rc=%.res)
344 OBJS += $(CSRCS:%.c=$(DIR)/$(DEBUG_DIR)%.o)
345 OBJS += $(CCSRCS:%.cpp=$(DIR)/$(DEBUG_DIR)%.o)
346 OBJS += $(WINRC:%.rc=$(DIR)/$(DEBUG_DIR)%.res)
348 JCLASS += $(JSRCS:%.java=$(DIR)/$(DEBUG_DIR)%.class)
350 LIB_a = $(DIR)/$(DEBUG_DIR)lib$(LIBNAME).a
353 # $OBJS can be empty except for some spaces
354 ifneq (x, x$(strip $(OBJS)))
358 @echo " -- lib: lib$(LIBNAME).a -- "
359 @cd $(DIR)/$(DEBUG_DIR); $(AR) $(ARFLAGSQUIET) $@ $(OBJS_AR)
361 cd $(DIR)/$(DEBUG_DIR); $(AR) $(ARFLAGS) $@ $(OBJS_AR)
365 @echo " -- lib: lib$(LIBNAME).a -- "
366 @$(AR) $(ARFLAGSQUIET) $@ $?
368 $(AR) $(ARFLAGS) $@ $?
376 ALLTARGETS ?= $(LIB_a)
378 all debug :: makedir $(ALLTARGETS)
383 @echo "====> make creator subtarget in `pwd | sed 's/^.*develop\///'`"
384 @$(MAKE) makedir DIR=$(DIR)/$(DEBUG_DIR)cre
385 @$(MAKE) lib CSRCS="$(CRE_CSRCS)" LIBNAME=$(LIBNAME)$@
388 @echo "====> make publisher subtarget in `pwd | sed 's/^.*develop\///'`"
389 @$(MAKE) makedir DIR=$(DIR)/$(DEBUG_DIR)pub
390 @$(MAKE) lib CSRCS="$(PUB_CSRCS)" LIBNAME=$(LIBNAME)$@
393 @echo "====> make player subtarget in `pwd | sed 's/^.*develop\///'`"
394 @$(MAKE) makedir DIR=$(DIR)/player/$(DEBUG_DIR)
395 @$(MAKE) lib CSRCS="$(SAP_CSRCS)" LIBNAME=$(LIBNAME)$@
397 clean:: optclean debugclean
400 @-[ ! -d $(DIR) ] || ( cd $(DIR) && \
401 $(RM) *.o *.a *.d *.res ii_files/*.ii *.class *.h )
404 @-[ ! -d $(DIR)/debug ] || ( cd $(DIR)/debug && \
405 $(RM) *.o *.a *.d *.res ii_files/*.ii *.class *.h )
409 @# don't use mkdir -p. Cygwin will try to make network paths and fail
410 @[ -d $(DIR) ] || mkdir $(DIR)
411 @[ -d $(DIR)/debug ] || mkdir $(DIR)/debug