diff --git a/platform/unix/exclude b/platform/unix/exclude index 1b3e4f3d6..b0b38ef06 100644 --- a/platform/unix/exclude +++ b/platform/unix/exclude @@ -24,3 +24,4 @@ ./modules/thread/sdl/* ./modules/thread/win32/* ./modules/thread/posix/* +./launcher.cpp diff --git a/platform/unix/gen-makefile b/platform/unix/gen-makefile index 62fdede59..928bfd41d 100644 --- a/platform/unix/gen-makefile +++ b/platform/unix/gen-makefile @@ -11,9 +11,13 @@ SUBDIRS = # LÖVE executable bin_PROGRAMS = love #love_LDFLAGS = -#love_LDADD = +love_LDADD = liblove.la +love_SOURCES = launcher.cpp -love_SOURCES = \\" > Makefile.am.tmp +# libLÖVE +lib_LTLIBRARIES = liblove.la +liblove_la_LDFLAGS = -module -export-dynamic \$(LDFLAGS) +liblove_la_SOURCES = \\" > Makefile.am.tmp find . \( \( -iname "*.c" -o -iname "*.cpp" -o -iname "*.h" -o -iname "*.lch" \) \) -exec echo '{}' \\ \; >> Makefile.am.tmp cat Makefile.am.tmp | grep -v -f"../platform/unix/exclude" | head -c -3 > Makefile.am #head -c -3 Makefile.am.tmp > Makefile.am diff --git a/src/launcher.cpp b/src/launcher.cpp new file mode 100644 index 000000000..5a420c22d --- /dev/null +++ b/src/launcher.cpp @@ -0,0 +1,33 @@ +/** +* Copyright (c) 2006-2012 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +**/ + +#include + +extern "C" +{ + extern int lovemain(int argc, char **argv); +} + +#ifdef LOVE_BUILD_EXE +int main(int argc, char **argv) +{ + return lovemain(argc, argv); +} +#endif // LOVE_BUILD_EXE diff --git a/src/love.cpp b/src/love.cpp index c150e0aa8..57a63b45b 100644 --- a/src/love.cpp +++ b/src/love.cpp @@ -284,9 +284,16 @@ _GLIBCXX_END_NAMESPACE #endif // LOVE_LEGENDARY_LIBSTDCXX_HACK -#ifdef LOVE_BUILD_EXE +namespace love +{ + void boot(lua_State *L) + { + if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0) + lua_call(L, 0, 0); + } +} // love -int main(int argc, char ** argv) +extern "C" LOVE_EXPORT int lovemain(int argc, char ** argv) { #ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK int hack_argc = 0; @@ -345,9 +352,7 @@ int main(int argc, char ** argv) } // Boot - if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0) - lua_call(L, 0, 0); - + love::boot(L); lua_close(L); #ifdef LOVE_LEGENDARY_UTF8_ARGV_HACK @@ -361,4 +366,3 @@ int main(int argc, char ** argv) return 0; } -#endif // LOVE_BUILD_EXE