2013-07-30 20:49:44 +08:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# LINUX MAKEFILE
|
|
|
|
#
|
|
|
|
# Available options are:
|
|
|
|
# - CLANG=1 : Compiles with clang instead of gcc. Clang must be in your PATH.
|
|
|
|
# - V=1 : Enables the verbose mode.
|
|
|
|
# - DEBUG=1 : Enables the debug mode, disable compiler optimizations.
|
|
|
|
# - OPENAL=1 : Uses OpenAL instead of FMOD as sound engine.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2013-03-03 10:30:39 +08:00
|
|
|
all:
|
|
|
|
|
2013-05-31 15:18:20 +08:00
|
|
|
# Remove -Wall, because it enables -Wunused-function, and this warning exists in webp.h
|
|
|
|
# when enable c++11. I don't know why.
|
2013-06-03 13:50:19 +08:00
|
|
|
# GCC 4.6 is primary platform for cocos2d v.3, because it's default compiler for Android,
|
|
|
|
# Blackberry, some Linux distributions.It supports all important features of c++11, but have
|
|
|
|
# no flag "-std=c++11" (which was turned on in version 4.7).
|
2013-07-30 20:49:44 +08:00
|
|
|
CCFLAGS += -MMD -Wno-deprecated-declarations -fPIC
|
|
|
|
CXXFLAGS += -MMD -Wno-deprecated-declarations -fPIC -std=gnu++0x
|
|
|
|
|
|
|
|
ifeq ($(CLANG), 1)
|
|
|
|
CC := clang
|
|
|
|
CXX := clang++
|
|
|
|
DEFINES += -D__STRICT_ANSI__ # Allows clang 3.3 to use __float128
|
|
|
|
else
|
|
|
|
CC = gcc
|
|
|
|
CXX = g++
|
|
|
|
CCFLAGS += -Werror
|
|
|
|
CXXFLAGS += -Werror
|
|
|
|
endif
|
|
|
|
|
2013-03-03 10:30:39 +08:00
|
|
|
ARFLAGS = cr
|
|
|
|
|
2013-06-29 11:44:14 +08:00
|
|
|
DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
|
2013-03-03 10:30:39 +08:00
|
|
|
|
2013-03-21 02:47:24 +08:00
|
|
|
ifdef USE_BOX2D
|
2013-04-17 12:49:25 +08:00
|
|
|
DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1
|
2013-03-21 02:47:24 +08:00
|
|
|
else
|
2013-04-17 12:49:25 +08:00
|
|
|
DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
|
2013-03-21 02:47:24 +08:00
|
|
|
endif
|
|
|
|
|
2013-03-03 10:30:39 +08:00
|
|
|
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
|
|
|
ifndef COCOS_ROOT
|
2013-03-16 23:58:29 +08:00
|
|
|
COCOS_ROOT := $(realpath $(dir $(THIS_MAKEFILE))/../..)
|
2013-03-03 10:30:39 +08:00
|
|
|
endif
|
2013-10-22 18:01:56 +08:00
|
|
|
COCOS_SRC = $(COCOS_ROOT)/cocos/2d
|
2013-03-03 10:30:39 +08:00
|
|
|
OBJ_DIR ?= obj
|
|
|
|
|
2013-03-16 23:58:29 +08:00
|
|
|
LIB_DIR = $(COCOS_ROOT)/lib/linux
|
2013-03-03 10:30:39 +08:00
|
|
|
BIN_DIR = bin
|
|
|
|
|
|
|
|
INCLUDES += \
|
2013-10-22 18:01:56 +08:00
|
|
|
-I$(COCOS_SRC)/ \
|
|
|
|
-I$(COCOS_SRC)/../math/kazmath/include \
|
2013-03-03 10:30:39 +08:00
|
|
|
-I$(COCOS_SRC)/platform/linux \
|
2013-10-22 18:01:56 +08:00
|
|
|
-I$(COCOS_SRC)/../../external/jpeg/include/linux \
|
|
|
|
-I$(COCOS_SRC)/../../external/tiff/include/linux \
|
|
|
|
-I$(COCOS_SRC)/../../external/webp/include/linux \
|
|
|
|
-I$(COCOS_SRC)/../../external/tinyxml2 \
|
|
|
|
-I$(COCOS_SRC)/../../external/unzip \
|
|
|
|
-I$(COCOS_SRC)/../../external/glfw3/include/linux \
|
|
|
|
-I$(COCOS_SRC)/../physics \
|
|
|
|
-I$(COCOS_SRC)/../base \
|
|
|
|
-I$(COCOS_SRC)/../../external/chipmunk/include/chipmunk \
|
|
|
|
-I$(COCOS_SRC)/../../external/freetype2/include/linux \
|
|
|
|
-I$(COCOS_SRC)/../.. \
|
|
|
|
-I$(COCOS_SRC)/../audio/include
|
2013-03-03 10:30:39 +08:00
|
|
|
|
|
|
|
LBITS := $(shell getconf LONG_BIT)
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
|
|
|
CCFLAGS += -g3 -O0
|
|
|
|
CXXFLAGS += -g3 -O0
|
2013-03-13 07:52:10 +08:00
|
|
|
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1
|
2013-03-03 10:30:39 +08:00
|
|
|
OBJ_DIR := $(OBJ_DIR)/debug
|
|
|
|
LIB_DIR := $(LIB_DIR)/debug
|
|
|
|
BIN_DIR := $(BIN_DIR)/debug
|
|
|
|
else
|
|
|
|
CCFLAGS += -O3
|
|
|
|
CXXFLAGS += -O3
|
|
|
|
DEFINES += -DNDEBUG
|
|
|
|
OBJ_DIR := $(OBJ_DIR)/release
|
|
|
|
LIB_DIR := $(LIB_DIR)/release
|
|
|
|
BIN_DIR := $(BIN_DIR)/release
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef V
|
|
|
|
LOG_CC = @echo " CC $@";
|
|
|
|
LOG_CXX = @echo " CXX $@";
|
|
|
|
LOG_AR = @echo " AR $@";
|
|
|
|
LOG_LINK = @echo " LINK $@";
|
|
|
|
endif
|
|
|
|
|
|
|
|
OBJECTS := $(SOURCES:.cpp=.o)
|
|
|
|
OBJECTS := $(OBJECTS:.c=.o)
|
|
|
|
OBJECTS := $(subst ../,,$(OBJECTS))
|
|
|
|
OBJECTS := $(subst $(COCOS_ROOT)/,,$(OBJECTS))
|
|
|
|
OBJECTS := $(addprefix $(OBJ_DIR)/, $(OBJECTS))
|
|
|
|
DEPS = $(OBJECTS:.o=.d)
|
|
|
|
CORE_MAKEFILE_LIST := $(MAKEFILE_LIST)
|
|
|
|
-include $(DEPS)
|
|
|
|
|
2013-10-22 18:01:56 +08:00
|
|
|
STATICLIBS_DIR = $(COCOS_ROOT)/external
|
2013-03-03 10:30:39 +08:00
|
|
|
ifeq ($(LBITS),64)
|
2013-10-22 18:01:56 +08:00
|
|
|
POSTFIX = 64-bit
|
2013-03-03 10:30:39 +08:00
|
|
|
else
|
2013-10-22 18:01:56 +08:00
|
|
|
POSTFIX = 32-bit
|
2013-03-03 10:30:39 +08:00
|
|
|
endif
|
2013-10-22 18:01:56 +08:00
|
|
|
STATICLIBS = $(STATICLIBS_DIR)/freetype2/prebuilt/linux/$(POSTFIX)/libfreetype.a \
|
|
|
|
$(STATICLIBS_DIR)/jpeg/prebuilt/linux/$(POSTFIX)/libjpeg.a \
|
|
|
|
$(STATICLIBS_DIR)/tiff/prebuilt/linux/$(POSTFIX)/libtiff.a \
|
|
|
|
$(STATICLIBS_DIR)/webp/prebuilt/linux/$(POSTFIX)/libwebp.a
|
2013-03-03 10:30:39 +08:00
|
|
|
|
2013-03-28 18:53:20 +08:00
|
|
|
ifneq ($(OPENAL),1)
|
2013-03-03 10:30:39 +08:00
|
|
|
ifeq ($(LBITS),64)
|
2013-10-22 18:01:56 +08:00
|
|
|
FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/lib64/api/lib
|
2013-03-03 10:30:39 +08:00
|
|
|
SHAREDLIBS += -lfmodex64
|
|
|
|
else
|
2013-10-22 18:01:56 +08:00
|
|
|
FMOD_LIBDIR = $(COCOS_ROOT)/cocos/audio/third-party/fmod/api/lib
|
2013-03-03 10:30:39 +08:00
|
|
|
SHAREDLIBS += -lfmodex
|
|
|
|
endif
|
2013-03-28 18:53:20 +08:00
|
|
|
endif
|
2013-03-03 10:30:39 +08:00
|
|
|
|
2013-09-17 13:39:16 +08:00
|
|
|
SHAREDLIBS += -lGLEW -lfontconfig -lpthread -lGL -lpng `pkg-config --libs glfw3`
|
2013-03-16 23:58:29 +08:00
|
|
|
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
|
|
|
|
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))
|
2013-04-10 14:17:23 +08:00
|
|
|
|
2013-05-25 02:29:23 +08:00
|
|
|
LIBS = -lrt -lz -lX11
|
2013-03-03 10:30:39 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJ_DIR)
|
|
|
|
rm -f $(TARGET) core
|
|
|
|
|
|
|
|
.PHONY: all clean
|
2013-03-09 02:00:21 +08:00
|
|
|
|
|
|
|
# If the parent Makefile defines $(EXECUTABLE) then define this as the target
|
|
|
|
# and create a 'make run' rule to run the app.
|
|
|
|
ifdef EXECUTABLE
|
|
|
|
TARGET := $(BIN_DIR)/$(EXECUTABLE)
|
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
run: $(TARGET)
|
|
|
|
cd $(dir $^) && ./$(notdir $^)
|
|
|
|
|
|
|
|
.PHONY: run
|
|
|
|
endif
|