summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Noble <pixel@Shinji.local>2008-12-03 04:36:07 -0800
committerNicolas Noble <pixel@Shinji.local>2008-12-03 04:36:07 -0800
commit67e09363f365d5f0924b78c07993519095901d1e (patch)
tree5ea4e536265292fe07c34790096f2d4850f00b70
parente0402b2b38cb866885f0c21282da5b42cc4188b6 (diff)
Implementing Darwin support.
-rw-r--r--Makefile85
-rw-r--r--src/lua-plugin.cc14
2 files changed, 62 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 7c0ae39..ef61335 100644
--- a/Makefile
+++ b/Makefile
@@ -1,24 +1,45 @@
+SYSTEM=$(shell uname)
+ifeq ($(SYSTEM),Darwin)
+ARCH_FLAGS=
+SHARED_FLAGS=-dynamiclib
+SHARED_EXT=dylib
+SQL_LIBS=/sw/lib/mysql/libmysqlclient.a -lz
+OSMESA_LIBS = -lMagick++ -lMagick -lWand -lMagick
+CPPFLAGS = -dynamic
+else
+ARCH_FLAGS=-march=i686
+SHARED_FLAGS=-shared
+SHARED_EXT=so
+SQL_LIBS=/usr/lib/libmysqlclient.a
+OSMESA_LIBS = `Magick++-config --libs`
+endif
CC = gcc
CXX = g++
LD = g++
STRIP = strip
INCLUDES = \
--I ../Mesa-7.0.3/include \
+-I ../Mesa-7.2/include \
-I../mogltk/include \
-I../Baltisot/include \
-I../Baltisot/lib/zlib/include \
-I../Baltisot/lib/lua/include -I../Baltisot/lib/lua/includes \
-I ../tinyxml \
+-I /sw/include/mysql \
-I /usr/include/mysql \
--I /usr/include/FTGL -I /usr/include/freetype2 \
--I /usr/include/oracle/11.1.0.1/client/
+-I /usr/include/FTGL \
+-I /usr/local/include/FTGL \
+-I /usr/include/freetype2 \
+-I /sw/include \
+-I /usr/local/instantclient/sdk/include \
+-I /usr/X11/include/freetype2 -I /usr/X11/include \
+-I /usr/include/oracle/11.1.0.1/client
HAVES = -DHAVE_VSSCANF -DHAVE_LIBJPEG -DHAVE_FCNTL -DHAVE_MYSQL -DHAVE_UNISTD_H -DHAVE_FORK -DHAVE_PIPE -DHAVE_FSYNC -DHAVE_MALLOC_H -DHAVE_ASPRINTF -DHAVE_BYTESWAP_H
-CPPFLAGS += $(INCLUDES) -O4 -fexceptions -DSTDC_HEADERS -DREADLINE_STATIC -DHOOK_STDS -DWORDS_LITTLEENDIAN -march=i686 $(HAVES) -DUSE_OSMESA
+CPPFLAGS += $(INCLUDES) -O4 -fexceptions -DSTDC_HEADERS -DREADLINE_STATIC -DHOOK_STDS -DWORDS_LITTLEENDIAN $(ARCH_FLAGS) $(HAVES) -DUSE_OSMESA
-LDFLAGS += -O4 -fexceptions -shared -fPIC -L/usr/lib/oracle/11.1.0.1/client/lib
+LDFLAGS += $(ARCH_FLAGS) $(SHARED_FLAGS) -L/usr/lib/oracle/11.1.0.1/client/lib -L/usr/X11/lib -L/sw/lib -L/usr/local/instantclient ./lua-interface.dylib
vpath %.c ../Baltisot/lib:../Baltisot/src:../Baltisot/lib/zlib/src:../Baltisot/lib/lua/src:../Baltisot/lib/lua/src/LuaLib:src:../mogltk/lib:../tinyxml
vpath %.cc ../Baltisot/lib:../Baltisot/src:../Baltisot/lib/zlib/src:../Baltisot/lib/lua/src:../Baltisot/lib/lua/src/LuaLib:src:../mogltk/lib:../tinyxml
@@ -74,8 +95,6 @@ plugin-luasql.cc \
SQL.cc \
LuaSQL.cc \
-SQL_LIBS = /usr/lib/libmysqlclient.a
-
LUALIBS_SOURCES = \
plugin-lualibs.cc \
loadlualibs.cc \
@@ -105,8 +124,6 @@ OSMESA_SOURCES = \
plugin-luaosmesa.cc \
dds.c
-OSMESA_LIBS = `Magick++-config --libs`
-
WHOLE_SOURCES = \
$(CONFIGFILES_SOURCES) \
$(XML_SOURCES) \
@@ -122,18 +139,18 @@ $(FTGL_SOURCES) \
$(OSMESA_SOURCES) \
MODULES_LIST = \
-luaconfigfiles.so \
-luaxml.so \
-luaocci.so \
-luahandle.so \
-luahttp.so \
-luaregex.so \
-luatask.so \
-luasql.so \
-luagl.so \
-luaftgl.so \
-lualibs.so \
-luaosmesa.so \
+luaconfigfiles.$(SHARED_EXT) \
+luaxml.$(SHARED_EXT) \
+luaocci.$(SHARED_EXT) \
+luahandle.$(SHARED_EXT) \
+luahttp.$(SHARED_EXT) \
+luaregex.$(SHARED_EXT) \
+luatask.$(SHARED_EXT) \
+luasql.$(SHARED_EXT) \
+luagl.$(SHARED_EXT) \
+luaftgl.$(SHARED_EXT) \
+lualibs.$(SHARED_EXT) \
+luaosmesa.$(SHARED_EXT) \
ALL_OBJECTS = $(addsuffix .o, $(notdir $(basename $(WHOLE_SOURCES) $(LUA_LIB))))
ALL_DEPS = $(addsuffix .dep, $(notdir $(basename $(WHOLE_SOURCES))))
@@ -144,44 +161,44 @@ modules: $(MODULES_LIST)
dep: $(ALL_DEPS)
-luaconfigfiles.so: $(addsuffix .o, $(notdir $(basename $(CONFIGFILES_SOURCES))))
+luaconfigfiles.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(CONFIGFILES_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(CONFIGFILES_LIBS)
-luaxml.so: $(addsuffix .o, $(notdir $(basename $(XML_SOURCES))))
+luaxml.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(XML_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(XML_LIBS)
-luaocci.so: $(addsuffix .o, $(notdir $(basename $(OCCI_SOURCES))))
+luaocci.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(OCCI_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(OCCI_LIBS)
-luahandle.so: $(addsuffix .o, $(notdir $(basename $(HANDLE_SOURCES))))
+luahandle.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(HANDLE_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(HANDLE_LIBS)
-luahttp.so: $(addsuffix .o, $(notdir $(basename $(HTTP_SOURCES))))
+luahttp.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(HTTP_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(HTTP_LIBS)
-luaregex.so: $(addsuffix .o, $(notdir $(basename $(REGEX_SOURCES))))
+luaregex.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(REGEX_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(REGEX_LIBS)
-luatask.so: $(addsuffix .o, $(notdir $(basename $(TASK_SOURCES))))
+luatask.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(TASK_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(TASK_LIBS)
-luasql.so: $(addsuffix .o, $(notdir $(basename $(SQL_SOURCES))))
+luasql.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(SQL_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(SQL_LIBS)
-luagl.so: $(addsuffix .o, $(notdir $(basename $(GL_SOURCES))))
+luagl.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(GL_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(GL_LIBS)
-luaftgl.so: $(addsuffix .o, $(notdir $(basename $(FTGL_SOURCES))))
+luaftgl.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(FTGL_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(FTGL_LIBS)
-lualibs.so: $(addsuffix .o, $(notdir $(basename $(LUALIBS_SOURCES) $(LUA_LIB))))
+lualibs.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(LUALIBS_SOURCES) $(LUA_LIB))))
$(LD) $(LDFLAGS) -o $@ $+ $(LUALIBS_LIBS)
-luaosmesa.so: $(addsuffix .o, $(notdir $(basename $(OSMESA_SOURCES))))
+luaosmesa.$(SHARED_EXT): $(addsuffix .o, $(notdir $(basename $(OSMESA_SOURCES))))
$(LD) $(LDFLAGS) -o $@ $+ $(OSMESA_LIBS)
clean:
- rm -f *.o *.dep *.so
+ rm -f *.o *.dep *.so *.dylib
%.dep : %.c
$(CC) $(CPPFLAGS) -M -MF $@ $<
diff --git a/src/lua-plugin.cc b/src/lua-plugin.cc
index 817c35b..e80f0f8 100644
--- a/src/lua-plugin.cc
+++ b/src/lua-plugin.cc
@@ -1,13 +1,21 @@
#include <lua-plugin.h>
+#if defined(_WIN32)
+#define SHARED_EXT "dll"
+#elif defined(__APPLE__)
+#define SHARED_EXT "dylib"
+#else
+#define SHARED_EXT "so"
+#endif
+
typedef void(*init_ptr_t)(Lua *);
-#ifdef _WIN32
+#if defined(_WIN32)
#include <windows.h>
void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) {
HMODULE handle;
- String fname = _fname + ".dll";
+ String fname = _fname + "." SHARED_EXT;
Base::printm(M_INFO, "Loading library " + fname + "\n");
@@ -30,7 +38,7 @@ void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) {
#include <dlfcn.h>
void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException) {
- void * handle = dlopen(("./" + fname + ".so").to_charp(), RTLD_NOW | RTLD_GLOBAL);
+ void * handle = dlopen(("./" + fname + "." SHARED_EXT).to_charp(), RTLD_NOW | RTLD_GLOBAL);
Base::printm(M_INFO, "Loading library " + fname + "\n");