Linux project fixes.

This commit is contained in:
bkaradzic 2012-06-02 12:44:37 -07:00
parent 3375076bea
commit a134ea9d1a
6 changed files with 126 additions and 49 deletions

View file

@ -0,0 +1,17 @@
/*
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bx/bx.h>
#if BX_PLATFORM_LINUX
extern int _main_(int _argc, char** _argv);
int main(int _argc, char** _argv)
{
return _main_(_argc, _argv);
}
#endif // BX_PLATFORM_LINUX

View file

@ -4,21 +4,16 @@ project "bgfx"
includedirs { includedirs {
BGFX_DIR .. "../bx/include", BGFX_DIR .. "../bx/include",
BGFX_DIR .. "3rdparty/glext",
} }
configuration { "nacl" } buildoptions {
buildoptions { "-Wall",
"-Wall", }
}
configuration { "windows" }
includedirs {
BGFX_DIR .. "3rdparty/glext",
}
defines { defines {
-- "BGFX_CONFIG_RENDERER_OPENGL=1", -- "BGFX_CONFIG_RENDERER_OPENGL=1",
} }
configuration "Debug" configuration "Debug"
defines { defines {

View file

@ -26,3 +26,9 @@ project "helloworld"
"@echo Stripping symbols.", "@echo Stripping symbols.",
"@$(NACL)/bin/x86_64-nacl-strip -s \"$(TARGET)\"" "@$(NACL)/bin/x86_64-nacl-strip -s \"$(TARGET)\""
} }
configuration { "linux" }
links {
"GL",
"pthread",
}

View file

@ -22,6 +22,7 @@ newoption {
value = "GCC", value = "GCC",
description = "Choose GCC flavor", description = "Choose GCC flavor",
allowed = { allowed = {
{ "linux", "Linux" },
{ "mingw", "MinGW" }, { "mingw", "MinGW" },
{ "nacl", "Google Native Client" }, { "nacl", "Google Native Client" },
} }
@ -39,21 +40,30 @@ if not XEDK then XEDK = "<you must install XBOX SDK>" end
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION) location (BGFX_BUILD_DIR .. "projects/" .. _ACTION)
if _ACTION == "clean" then
os.rmdir(BUILD_DIR)
end
if _ACTION == "gmake" then if _ACTION == "gmake" then
if nil == _OPTIONS["gcc"] then
print("GCC flavor must be specified!")
os.exit(1)
end
flags { flags {
"ExtraWarnings", "ExtraWarnings",
} }
if "linux" ~= os.get() and nil == _OPTIONS["gcc"] then if "linux" == _OPTIONS["gcc"] then
print("GCC flavor must be specified!") location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-linux")
os.exit(1)
end end
if "mingw" == _OPTIONS["gcc"] then if "mingw" == _OPTIONS["gcc"] then
premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc" premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc"
premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++" premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++"
premake.gcc.ar = "$(MINGW)/bin/ar" premake.gcc.ar = "$(MINGW)/bin/ar"
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-mingw")
end end
if "nacl" == _OPTIONS["gcc"] then if "nacl" == _OPTIONS["gcc"] then
@ -80,6 +90,12 @@ flags {
"Symbols", "Symbols",
} }
defines {
"__STDC_LIMIT_MACROS",
"__STDC_FORMAT_MACROS",
"__STDC_CONSTANT_MACROS",
}
configuration "Debug" configuration "Debug"
targetsuffix "Debug" targetsuffix "Debug"
@ -90,47 +106,91 @@ configuration "Release"
targetsuffix "Release" targetsuffix "Release"
configuration { "vs*" } configuration { "vs*" }
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/msvc" }
defines { defines {
"WIN32",
"_WIN32",
"_HAS_EXCEPTIONS=0", "_HAS_EXCEPTIONS=0",
"_HAS_ITERATOR_DEBUGGING=0", "_HAS_ITERATOR_DEBUGGING=0",
"_SCL_SECURE=0", "_SCL_SECURE=0",
"_SECURE_SCL=0",
"_SCL_SECURE_NO_WARNINGS",
"_CRT_SECURE_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS",
"_CRT_SECURE_NO_DEPRECATE", "_CRT_SECURE_NO_DEPRECATE",
"__STDC_LIMIT_MACROS", }
"__STDC_FORMAT_MACROS", buildoptions {
"__STDC_CONSTANT_MACROS", "/Oy-", -- Suppresses creation of frame pointers on the call stack.
"/Ob2", -- The Inline Function Expansion
} }
configuration { "x32", "vs*" } configuration { "x32", "vs*" }
defines { "WIN32" }
targetdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/bin") targetdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/bin")
objdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/obj") objdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/obj")
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/msvc" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win32_" .. _ACTION }
configuration { "x64", "vs*" } configuration { "x64", "vs*" }
defines { "WIN32" } defines { "_WIN64" }
targetdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/bin") targetdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/bin")
objdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/obj") objdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/obj")
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/msvc" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win64_" .. _ACTION }
configuration { "mingw" }
defines { "WIN32" }
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/mingw" }
buildoptions {
"-std=c++0x",
"-U__STRICT_ANSI__",
"-Wunused-value",
"-fdata-sections",
"-ffunction-sections",
-- "-fmerge-all-constants"
}
linkoptions {
"-Wl,--gc-sections",
}
configuration { "x32", "mingw" } configuration { "x32", "mingw" }
defines { "WIN32" }
targetdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/bin") targetdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/bin")
objdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/obj") objdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/obj")
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/mingw" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win32_mingw" }
buildoptions { "-m32" }
configuration { "x64", "mingw" } configuration { "x64", "mingw" }
defines { "WIN32" }
targetdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/bin") targetdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/bin")
objdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/obj") objdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/obj")
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/mingw" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/win64_mingw" }
buildoptions { "-m64" }
configuration { "linux" }
buildoptions {
"-std=c++0x",
"-U__STRICT_ANSI__",
"-Wunused-value",
"-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
"-msse2",
}
linkoptions {
"-Wl,--gc-sections",
}
configuration { "linux", "x32" }
targetdir (BGFX_BUILD_DIR .. "linux32_gcc" .. "/bin")
objdir (BGFX_BUILD_DIR .. "linux32_gcc" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/linux32_gcc" }
buildoptions {
"-m32",
}
configuration { "linux", "x64" }
targetdir (BGFX_BUILD_DIR .. "linux64_gcc" .. "/bin")
objdir (BGFX_BUILD_DIR .. "linux64_gcc" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/linux64_gcc" }
buildoptions {
"-m64",
}
configuration { "nacl" } configuration { "nacl" }
defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600" } defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600" }
links {
"ppapi",
"ppapi_gles2",
}
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/nacl" } includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/nacl" }
buildoptions { buildoptions {
"-std=c++0x", "-std=c++0x",
@ -153,31 +213,23 @@ configuration { "x32", "nacl" }
targetdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/bin") targetdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/bin")
objdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/obj") objdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x86" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x86" }
linkoptions { linkoptions { "-melf32_nacl" }
"-melf32_nacl",
}
configuration { "x64", "nacl" } configuration { "x64", "nacl" }
targetdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/bin") targetdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/bin")
objdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/obj") objdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x64" } libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x64" }
linkoptions { linkoptions { "-melf64_nacl" }
"-melf64_nacl",
}
configuration { "x32", "linux" }
targetdir (BGFX_BUILD_DIR .. "linux32" .. "/bin")
objdir (BGFX_BUILD_DIR .. "linux32" .. "/obj")
configuration { "x64", "linux" }
targetdir (BGFX_BUILD_DIR .. "linux64" .. "/bin")
objdir (BGFX_BUILD_DIR .. "linux64" .. "/obj")
configuration { "Xbox360" } configuration { "Xbox360" }
defines { "_XBOX", "NOMINMAX" }
targetdir (BGFX_BUILD_DIR .. "xbox360" .. "/bin") targetdir (BGFX_BUILD_DIR .. "xbox360" .. "/bin")
objdir (BGFX_BUILD_DIR .. "xbox360" .. "/obj") objdir (BGFX_BUILD_DIR .. "xbox360" .. "/obj")
includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/msvc" } includedirs { BGFX_THIRD_PARTY_DIR .. "compiler/msvc" }
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/xbox360" }
defines {
"NOMINMAX",
"_XBOX",
}
configuration {} -- reset configuration configuration {} -- reset configuration

View file

@ -179,7 +179,7 @@ namespace bgfx
}; };
// Find suitable config // Find suitable config
GLXFBConfig bestconfig; GLXFBConfig bestconfig = NULL;
int nconfigs; int nconfigs;
GLXFBConfig* configs = glXChooseFBConfig(display, DefaultScreen(display), glxAttribs, &nconfigs); GLXFBConfig* configs = glXChooseFBConfig(display, DefaultScreen(display), glxAttribs, &nconfigs);
@ -192,7 +192,7 @@ namespace bgfx
{ {
// Check if meets min spec // Check if meets min spec
bool validconfig = true; bool validconfig = true;
for (int attridx = 0; attridx < countof(glxAttribs) && glxAttribs[attridx] != None; attridx += 2) for (uint32_t attridx = 0; attridx < countof(glxAttribs)-1 && glxAttribs[attridx] != None; attridx += 2)
{ {
int value; int value;
glXGetFBConfigAttrib(display, configs[ii], glxAttribs[attridx], &value); glXGetFBConfigAttrib(display, configs[ii], glxAttribs[attridx], &value);

View file

@ -7,7 +7,15 @@
#define __RENDERER_GL_H__ #define __RENDERER_GL_H__
#if BGFX_CONFIG_RENDERER_OPENGL #if BGFX_CONFIG_RENDERER_OPENGL
# include <GL/gl.h> # if BX_PLATFORM_LINUX
# define GL_PROTOTYPES
# define GL_GLEXT_LEGACY
# include <GL/gl.h>
# include <GL/glx.h>
# undef GL_PROTOTYPES
# else
# include <GL/gl.h>
# endif // BX_PLATFORM_
// remove deprecated from glext.h // remove deprecated from glext.h
# define GL_VERSION_1_2_DEPRECATED # define GL_VERSION_1_2_DEPRECATED
@ -63,7 +71,6 @@
#elif BX_PLATFORM_WINDOWS #elif BX_PLATFORM_WINDOWS
# include <windows.h> # include <windows.h>
#elif BX_PLATFORM_LINUX #elif BX_PLATFORM_LINUX
# include <GL/glx.h>
# include <X11/Xlib.h> # include <X11/Xlib.h>
#endif // BX_PLATFORM_ #endif // BX_PLATFORM_