Merge pull request #2126 from sbc100/make_run_for_linux

fixed #1820: Adding 'make run' target for linux projects.
This commit is contained in:
James Chen 2013-03-10 20:04:40 -07:00
commit 30e304961f
22 changed files with 108 additions and 284 deletions

View File

@ -9,6 +9,7 @@ define MAKE_TARGET
+$(MAKE) -C scripting/lua/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/HelloCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/SimpleGame/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Lua/HelloLua/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Lua/TestLua/proj.$(PLATFORM) $@
endef

View File

@ -99,3 +99,16 @@ clean:
rm -f $(TARGET) core
.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)
all: $(TARGET)
run: $(TARGET)
cd $(dir $^) && ./$(notdir $^)
.PHONY: run
endif

View File

@ -1,6 +1,6 @@
TARGET = HelloCpp
EXECUTABLE = HelloCpp
INCLUDES = -I.. -I../Classes
INCLUDES = -I.. -I../Classes
SOURCES = main.cpp \
../Classes/AppDelegate.cpp \
@ -12,10 +12,6 @@ include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
SHAREDLIBS += -lcocos2d
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so
TARGET := $(BIN_DIR)/$(TARGET)
all: $(TARGET)
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)

View File

@ -1,8 +1,6 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

View File

@ -1,7 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
// C RunTime Header Files
#include "CCStdC.h"
#endif // __MAIN_H__

View File

@ -0,0 +1,27 @@
EXECUTABLE = SimpleGame
INCLUDES = -I.. -I../Classes
SOURCES = main.cpp \
../Classes/AppDelegate.cpp \
../Classes/HelloWorldScene.cpp \
../Classes/GameOverScene.cpp
COCOS_ROOT = ../../../..
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
SHAREDLIBS += -lcocos2d -lcocosdenshion
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so
INCLUDES += -I$(COCOS_ROOT)/CocosDenshion/include
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

View File

@ -0,0 +1,20 @@
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string>
USING_NS_CC;
int main(int argc, char **argv)
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setFrameSize(800, 480);
return CCApplication::sharedApplication()->run();
}

View File

@ -1,4 +1,4 @@
TARGET = TestCpp
EXECUTABLE = TestCpp
SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \
../Classes/ActionManagerTest/ActionManagerTest.cpp \
@ -111,9 +111,6 @@ STATICLIBS += \
DEFINES += -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
TARGET := $(BIN_DIR)/$(TARGET)
all: $(TARGET)
####### Build rules
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)

View File

@ -1,5 +1,3 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include "CCEGLView.h"
@ -12,7 +10,7 @@
USING_NS_CC;
int main(int argc, char **argv)
{
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();

View File

@ -1,13 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
//#include <windows.h>
//#include <tchar.h>
// C RunTime Header Files
#include "CCStdC.h"
#endif // __MAIN_H__

View File

@ -1,4 +1,4 @@
TARGET = HelloLua
EXECUTABLE = HelloLua
COCOS_ROOT = ../../../..
INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/CocosDenshion/include \
@ -11,13 +11,8 @@ SOURCES = main.cpp ../Classes/AppDelegate.cpp
SHAREDLIBS += -lcocos2d -lcocosdenshion -llua
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
TARGET := $(BIN_DIR)/$(TARGET)
all: $(TARGET)
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS)

View File

@ -1,8 +1,6 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@ -11,7 +9,7 @@
USING_NS_CC;
int main(int argc, char **argv)
{
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();

View File

@ -1,7 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
// C RunTime Header Files
#include "CCStdC.h"
#endif // __MAIN_H__

View File

@ -1,4 +1,4 @@
TARGET = TestLua
EXECUTABLE = TestLua
COCOS_ROOT = ../../../..
INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/CocosDenshion/include \
@ -13,10 +13,6 @@ COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
TARGET := $(BIN_DIR)/$(TARGET)
all: $(TARGET)
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
cp -R -n ../../../../samples/Cpp/TestCpp/Resources ../../../../samples/Lua/TestLua

View File

@ -1,5 +1,3 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include "CCEGLView.h"
@ -12,7 +10,7 @@
USING_NS_CC;
int main(int argc, char **argv)
{
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();

View File

@ -1,13 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
//#include <windows.h>
//#include <tchar.h>
// C RunTime Header Files
#include "CCStdC.h"
#endif // __MAIN_H__

View File

@ -1,101 +1,25 @@
CC = gcc
CXX = g++
TARGET = HelloCpp
CCFLAGS = -Wall
CXXFLAGS = -Wall
VISIBILITY =
LIBS =
EXECUTABLE = HelloCpp
COCOS2DX_PATH = ../../../cocos2dx
INCLUDES = -I../ \
-I../../ \
-I../Classes \
-I$(COCOS2DX_PATH) \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libfreetype2 \
-I$(COCOS2DX_PATH)/cocoa \
-I$(COCOS2DX_PATH)/include \
-I$(COCOS2DX_PATH)/kazmath/include \
-I$(COCOS2DX_PATH)/platform \
-I$(COCOS2DX_PATH)/platform/linux \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libxml2 \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libjpeg \
-I../../../CocosDenshion/include \
-I../../../extensions/ \
-I../../../external/ \
-I../../../external/chipmunk/include/chipmunk \
INCLUDES = -I.. -I../Classes
SOURCES = main.cpp \
../Classes/AppDelegate.cpp \
../Classes/HelloWorldScene.cpp
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
INCLUDES += -I$(COCOS2DX_PATH)/platform/third_party/linux/include64
else
INCLUDES += -I$(COCOS2DX_PATH)/platform/third_party/linux
endif
COCOS_ROOT = ../../..
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
DEFINES = -DLINUX
SHAREDLIBS += -lcocos2d
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so
OBJECTS = ../Classes/AppDelegate.o \
../Classes/HelloWorldScene.o \
./main.o
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)
ifeq ($(LBITS),64)
STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries/lib64
else
STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries
endif
STATICLIBS =
STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \
$(STATICLIBS_DIR)/libcurl.a \
$(STATICLIBS_DIR)/libxml2.a \
$(STATICLIBS_DIR)/libpng.a \
$(STATICLIBS_DIR)/libjpeg.a \
$(STATICLIBS_DIR)/libtiff.a \
../../../lib/linux/Debug/libextension.a \
../../../lib/linux/Debug/libbox2d.a \
../../../lib/linux/Debug/libchipmunk.a
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
SHAREDLIBS =
ifeq ($(LBITS),64)
SHAREDLIBS_DIR = ../../../CocosDenshion/third_party/fmod/lib64/api/lib
SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex64
else
SHAREDLIBS_DIR = ../../../CocosDenshion/third_party/fmod/api/lib
SHAREDLIBS = -L$(SHAREDLIBS_DIR) -lfmodex
endif
SHAREDLIBS += -Wl,-rpath,../../$(SHAREDLIBS_DIR)
SHAREDLIBS += -lglfw -lGLEW -lcurl
BIN_DIR_ROOT=bin
BIN_DIR = BIN_DIR_ROOT
debug: SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../../lib/linux/Debug
debug: CCFLAGS += -g3 -O0
debug: CXXFLAGS += -g3 -O0
debug: DEFINES += -DDEBUG -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -DCOCOS2D_DEBUG=1
debug: BIN_DIR = $(BIN_DIR_ROOT)/debug
debug: $(TARGET)
release: SHAREDLIBS += -L../../../lib/linux/Release -lcocos2d -lrt -lz -lcocosdenshion -Wl,-rpath,../../../../../lib/linux/Release
release: CCFLAGS += -O3
release: CXXFLAGS += -O3
release: DEFINES += -DNDEBUG -DCC_ENABLE_CHIPMUNK_INTEGRATION=1
release: BIN_DIR = $(BIN_DIR_ROOT)/release
release: $(TARGET)
####### Build rules
$(TARGET): $(OBJECTS)
mkdir -p $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS) $(LIBS)
####### Compile
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
%.o: %.c
$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
clean:
rm -f $(OBJECTS) $(TARGET) core
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

View File

@ -1,5 +1,3 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include "CCEGLView.h"
@ -12,7 +10,7 @@
USING_NS_CC;
int main(int argc, char **argv)
{
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();

View File

@ -1,13 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
//#include <windows.h>
//#include <tchar.h>
// C RunTime Header Files
#include "CCStdC.h"
#endif // __MAIN_H__

View File

@ -1,93 +1,26 @@
CC = gcc
CXX = g++
TARGET = HelloLua
CCFLAGS = -Wall
CXXFLAGS = -Wall
VISIBILITY =
EXECUTABLE = HelloLua
COCOS2DX_PATH = ../../../cocos2dx
INCLUDES = -I../ \
-I../Classes \
-I$(COCOS2DX_PATH) \
-I$(COCOS2DX_PATH)/platform/third_party/linux \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libfreetype2 \
-I$(COCOS2DX_PATH)/cocoa \
-I$(COCOS2DX_PATH)/include \
-I$(COCOS2DX_PATH)/platform \
-I$(COCOS2DX_PATH)/platform/linux \
-I$(COCOS2DX_PATH)/kazmath/include \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libxml2 \
-I$(COCOS2DX_PATH)/platform/third_party/linux/libjpeg \
-I../../../CocosDenshion/include \
-I../../../scripting/lua/lua \
-I../../../scripting/lua/tolua \
-I../../../scripting/lua/cocos2dx_support
COCOS_ROOT = ../../..
INCLUDES = -I../ -I../Classes -I$(COCOS_ROOT)/CocosDenshion/include \
-I$(COCOS_ROOT)/scripting/lua/lua \
-I$(COCOS_ROOT)/scripting/lua/tolua \
-I$(COCOS_ROOT)/scripting/lua/cocos2dx_support
SOURCES = main.cpp ../Classes/AppDelegate.cpp
DEFINES = -DLINUX
SHAREDLIBS += -lcocos2d -lcocosdenshion -llua
COCOS_LIBS = $(LIB_DIR)/libcocos2d.so $(LIB_DIR)/libcocosdenshion.so $(LIB_DIR)/liblua.so
OBJECTS = ./main.o \
../Classes/AppDelegate.o
include $(COCOS_ROOT)/cocos2dx/proj.linux/cocos2dx.mk
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries/lib64
else
STATICLIBS_DIR = ../../../cocos2dx/platform/third_party/linux/libraries
endif
$(TARGET): $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS) $(LIBS)
STATICLIBS = $(STATICLIBS_DIR)/libfreetype.a \
$(STATICLIBS_DIR)/libcurl.a \
$(STATICLIBS_DIR)/libxml2.a \
$(STATICLIBS_DIR)/libpng.a \
$(STATICLIBS_DIR)/libjpeg.a \
$(STATICLIBS_DIR)/libtiff.a \
# $(STATICLIBS_DIR)/libGLEW.a \
../../../lib/linux/Debug/libbox2d.a \
../../../lib/linux/Debug/libchipmunk.a
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
SHAREDLIBS += -lglfw -lcurl -llua -lGLEW
SHAREDLIBS += -Wl,-rpath,../../../../lib/linux/Debug
ifeq ($(LBITS),64)
SHAREDLIBS += -L../../../CocosDenshion/third_party/fmod/lib64/api/lib -lfmodex64 -Wl,-rpath,../../../../CocosDenshion/third_party/fmod/lib64/api/lib
else
SHAREDLIBS += -L../../../CocosDenshion/third_party/fmod/api/lib -lfmodex -Wl,-rpath,../../../../CocosDenshion/third_party/fmod/api/lib
endif
#$(shell ../../build-linux.sh $<)
BIN_DIR_ROOT=bin
BIN_DIR = $(BIN_DIR_ROOT)
debug: BIN_DIR = $(BIN_DIR_ROOT)/debug
debug: CCFLAGS += -g3 -O0
debug: CXXFLAGS += -g3 -O0
debug: SHAREDLIBS += -L../../../lib/linux/Debug -lcocos2d -lrt -lz -lcocosdenshion
debug: SHAREDLIBS += -Wl,-rpath,../../../../lib/linux/Debug/
debug: DEFINES += -DDEBUG
debug: $(TARGET)
release: BIN_DIR = $(BIN_DIR_ROOT)/release
release: CCFLAGS += -O3
release: CXXFLAGS += -O3
release: SHAREDLIBS += -L../../../lib/linux/Release -lcocos2d -lrt -lz -lcocosdenshion
release: SHAREDLIBS += -Wl,-rpath,../../../../lib/linux/Release/
release: DEFINES += -DNDEBUG
release: $(TARGET)
####### Build rules
$(TARGET): $(OBJECTS)
mkdir -p $(BIN_DIR)
cp -R -n ../../../samples/Cpp/TestCpp/Resources ../../../samples/Lua/HelloLua
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(OBJECTS) -o $(BIN_DIR)/$(TARGET) $(SHAREDLIBS) $(STATICLIBS)
####### Compile
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
%.o: %.c
$(CC) $(CCFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@
clean:
rm -f $(OBJECTS) $(TARGET) core
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEFINES) $(VISIBILITY) -c $< -o $@

View File

@ -1,5 +1,3 @@
#include "main.h"
#include "../Classes/AppDelegate.h"
#include "cocos2d.h"
#include "CCEGLView.h"
@ -12,7 +10,7 @@
USING_NS_CC;
int main(int argc, char **argv)
{
{
// create the application instance
AppDelegate app;
CCEGLView* eglView = CCEGLView::sharedOpenGLView();

View File

@ -1,13 +0,0 @@
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
//#include <windows.h>
//#include <tchar.h>
// C RunTime Header Files
#include "CCStdC.h"
#endif // __MAIN_H__