Browse Source

Create liblove

Bart van Strien 13 years ago
parent
commit
7f39fa8c3a
4 changed files with 50 additions and 8 deletions
  1. 1 0
      platform/unix/exclude
  2. 6 2
      platform/unix/gen-makefile
  3. 33 0
      src/launcher.cpp
  4. 10 6
      src/love.cpp

+ 1 - 0
platform/unix/exclude

@@ -24,3 +24,4 @@
 ./modules/thread/sdl/*
 ./modules/thread/win32/*
 ./modules/thread/posix/*
+./launcher.cpp

+ 6 - 2
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

+ 33 - 0
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 <common/config.h>
+
+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

+ 10 - 6
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