Skip to content

Commit

Permalink
Merge pull request cocos2d#3332 from azmeuk/clang
Browse files Browse the repository at this point in the history
Clang support for Linux
  • Loading branch information
minggo committed Jul 31, 2013
2 parents 786e7ea + aaba34e commit b206e2e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cocos2dx/proj.emscripten/cocos2dx.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ LBITS := $(shell getconf LONG_BIT)
INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux

ifeq ($(DEBUG), 1)
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
CCFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0 -g
CXXFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0 -g
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1 -DCP_USE_DOUBLES=0
OBJ_DIR := $(OBJ_DIR)/debug
LIB_DIR := $(LIB_DIR)/debug
Expand Down
30 changes: 26 additions & 4 deletions cocos2dx/proj.linux/cocos2dx.mk
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
################################################################################
#
# 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.
#
################################################################################

all:

CC = gcc
CXX = g++
# Remove -Wall, because it enables -Wunused-function, and this warning exists in webp.h
# when enable c++11. I don't know why.
# 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).
CCFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC
CXXFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC -std=gnu++0x
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

ARFLAGS = cr

DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
Expand Down
9 changes: 4 additions & 5 deletions external/Box2D/proj.emscripten/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ include ../../../cocos2dx/proj.emscripten/cocos2dx.mk

INCLUDES = -I../..

# Unfortunetly Box2D doesn't compiler cleanly without these
CXXFLAGS += -Qunused-variable
CXXFLAGS += -Wno-uninitialized
# Cocos2d is not responsible for warnings in external projects
CXXFLAGS += -w

ifeq ($(DEBUG), 1)
DEFINES = -D_DEBUG
DEFINES += -D_DEBUG
else
DEFINES =
DEFINES +=
endif

TARGET := $(LIB_DIR)/$(TARGET)
Expand Down
5 changes: 2 additions & 3 deletions external/Box2D/proj.linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ include ../../../cocos2dx/proj.linux/cocos2dx.mk

INCLUDES = -I../..

# Unfortunetly Box2D doesn't compiler cleanly without these
CXXFLAGS += -Wno-unused-but-set-variable
CXXFLAGS += -Wno-uninitialized
# Cocos2d is not responsible for warnings in external projects
CXXFLAGS += -w

ifeq ($(DEBUG), 1)
DEFINES = -D_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion samples/Cpp/HelloCpp/proj.emscripten/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char **argv)
// create the application instance
AppDelegate app;

EGLView* eglView = EGLView::getInstance();
EGLView::getInstance();

return Application::getInstance()->run();
}

0 comments on commit b206e2e

Please sign in to comment.