2013-04-04 09:26:55 +08:00
|
|
|
all:
|
|
|
|
|
|
|
|
DEFINES += -DEMSCRIPTEN
|
|
|
|
|
|
|
|
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
|
|
|
ifndef COCOS_ROOT
|
|
|
|
COCOS_ROOT ?= $(realpath $(dir $(THIS_MAKEFILE))/../..)
|
|
|
|
else
|
|
|
|
RPATH_REL = ../..
|
|
|
|
endif
|
|
|
|
COCOS_SRC = $(COCOS_ROOT)/cocos2dx
|
|
|
|
OBJ_DIR ?= obj
|
|
|
|
|
2013-05-07 11:34:15 +08:00
|
|
|
EMSCRIPTEN_ROOT := $(realpath $(COCOS_ROOT)/external/emscripten)
|
|
|
|
PACKAGER := $(EMSCRIPTEN_ROOT)/tools/file_packager.py
|
|
|
|
CC := EMSCRIPTEN=$(EMSCRIPTEN_ROOT) $(COCOS_ROOT)/external/emscripten/emcc
|
|
|
|
CXX := EMSCRIPTEN=$(EMSCRIPTEN_ROOT) $(COCOS_ROOT)/external/emscripten/em++
|
|
|
|
AR := EMSCRIPTEN=$(EMSCRIPTEN_ROOT) $(COCOS_ROOT)/external/emscripten/emar
|
2013-06-14 17:32:07 +08:00
|
|
|
CCFLAGS += -MMD -Wall -fPIC -Qunused-arguments -Wno-overloaded-virtual -Qunused-variable -s TOTAL_MEMORY=268435456 -s VERBOSE=1 -U__native_client__ -Wno-deprecated-declarations
|
|
|
|
CXXFLAGS += -MMD -Wall -fPIC -Qunused-arguments -Wno-overloaded-virtual -Qunused-variable -s TOTAL_MEMORY=268435456 -s VERBOSE=1 -U__native_client__ -std=c++11 -Wno-deprecated-declarations
|
2013-04-04 09:26:55 +08:00
|
|
|
ARFLAGS = cr
|
|
|
|
|
2013-04-09 12:09:53 +08:00
|
|
|
LIB_DIR = $(COCOS_SRC)/lib/emscripten
|
2013-04-04 09:26:55 +08:00
|
|
|
BIN_DIR = bin
|
|
|
|
|
|
|
|
INCLUDES += \
|
2013-05-07 11:34:15 +08:00
|
|
|
-I$(EMSCRIPTEN_ROOT)/system/include \
|
2013-04-04 09:26:55 +08:00
|
|
|
-I$(COCOS_ROOT)/external/emscripten/system/include \
|
|
|
|
-I$(COCOS_SRC) \
|
|
|
|
-I$(COCOS_SRC)/cocoa \
|
|
|
|
-I$(COCOS_SRC)/include \
|
|
|
|
-I$(COCOS_SRC)/kazmath/include \
|
|
|
|
-I$(COCOS_SRC)/platform/emscripten \
|
2013-04-09 10:14:25 +08:00
|
|
|
-I$(COCOS_SRC)/platform/third_party/emscripten/libpng \
|
|
|
|
-I$(COCOS_SRC)/platform/third_party/emscripten/libz \
|
2013-04-24 13:45:05 +08:00
|
|
|
-I$(COCOS_SRC)/platform/third_party/emscripten/libtiff/include \
|
2013-05-07 13:28:13 +08:00
|
|
|
-I$(COCOS_SRC)/platform/third_party/emscripten/libjpeg \
|
2013-05-08 08:24:24 +08:00
|
|
|
-I$(COCOS_SRC)/platform/third_party/emscripten/libwebp
|
2013-04-04 09:26:55 +08:00
|
|
|
|
|
|
|
LBITS := $(shell getconf LONG_BIT)
|
|
|
|
INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux
|
|
|
|
|
|
|
|
ifeq ($(DEBUG), 1)
|
2013-05-15 06:26:48 +08:00
|
|
|
CCFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0
|
|
|
|
CXXFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0
|
2013-04-30 11:54:36 +08:00
|
|
|
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1 -DCP_USE_DOUBLES=0
|
2013-04-04 09:26:55 +08:00
|
|
|
OBJ_DIR := $(OBJ_DIR)/debug
|
|
|
|
LIB_DIR := $(LIB_DIR)/debug
|
|
|
|
BIN_DIR := $(BIN_DIR)/debug
|
|
|
|
else
|
2013-05-09 05:59:48 +08:00
|
|
|
CCFLAGS += -O2 --jcache -s GL_UNSAFE_OPTS=0 -s ASM_JS=1
|
|
|
|
CXXFLAGS += -O2 --jcache -s GL_UNSAFE_OPTS=0 -s ASM_JS=1
|
2013-04-30 11:54:36 +08:00
|
|
|
DEFINES += -DNDEBUG -DCP_USE_DOUBLES=0
|
2013-04-04 09:26:55 +08:00
|
|
|
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-04-04 12:43:31 +08:00
|
|
|
STATICLIBS_DIR = $(COCOS_SRC)/platform/third_party/emscripten/libraries
|
2013-05-17 08:34:33 +08:00
|
|
|
STATICLIBS = \
|
2013-04-04 09:26:55 +08:00
|
|
|
$(STATICLIBS_DIR)/libpng.a \
|
2013-05-15 06:26:48 +08:00
|
|
|
$(STATICLIBS_DIR)/libz.a \
|
2013-05-07 13:28:13 +08:00
|
|
|
$(STATICLIBS_DIR)/libtiff.a \
|
2013-05-08 08:24:24 +08:00
|
|
|
$(STATICLIBS_DIR)/libjpeg.a \
|
2013-04-04 09:26:55 +08:00
|
|
|
$(STATICLIBS_DIR)/libwebp.a
|
|
|
|
|
|
|
|
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR)
|
|
|
|
LIBS = -lrt -lz
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJ_DIR)
|
2013-04-05 13:19:39 +08:00
|
|
|
rm -f $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR)/index.html core
|
2013-04-04 09:26:55 +08:00
|
|
|
|
|
|
|
.PHONY: all clean
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2013-04-05 13:19:39 +08:00
|
|
|
all: $(TARGET).js $(TARGET).data $(BIN_DIR)/index.html
|
2013-04-04 09:26:55 +08:00
|
|
|
|
|
|
|
run: $(TARGET)
|
|
|
|
cd $(dir $^) && ./$(notdir $^)
|
|
|
|
|
|
|
|
.PHONY: run
|
|
|
|
endif
|