summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Noble <pixel@Shinji.local>2008-12-03 04:34:51 -0800
committerNicolas Noble <pixel@Shinji.local>2008-12-03 04:34:51 -0800
commit218bc9c15cd75afa0165b453243f2b706142af9b (patch)
treef61193bd36c8472aa8e29255c26015984c2c9879
parentc9d980fd1e4cec1973ea3e7d54ae7057e9c29e08 (diff)
Fixing module system for Darwin.
-rw-r--r--Makefile19
-rw-r--r--src/lua-interface-main.c5
-rw-r--r--src/lua-interface-win32-main.c5
-rw-r--r--src/lua-interface.cpp5
4 files changed, 22 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 59f9a12..e4e66b5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,18 @@
SYSTEM=$(shell uname)
ifeq ($(SYSTEM),Darwin)
-ARCH_FLAGS=-m64
-LDFLAGS_MESA=-all-load ../Mesa-7.2/lib/libGLU.a ../Mesa-7.2/lib/libOSMesa.a
+ARCH_FLAGS=
+LDFLAGS_MESA=-all_load ../Mesa-7.2/lib/libGLU.a ../Mesa-7.2/lib/libOSMesa.a
CPPFLAGS_READLINE=
LDFLAGS_READLINE=-lreadline -lncurses
+SHARED_FLAGS=-dynamiclib
+SHARED_EXT=dylib
else
ARCH_FLAGS=-march=i686
LDFLAGS_MESA=-u gluNewTess -Wl,--whole-archive ../Mesa-7.2/lib/libGLU.a ../Mesa-7.2/lib/libOSMesa.a -Wl,--no-whole-archive
CPPFLAGS_READLINE=-DREADLINE_STATIC
LDFLAGS_READLINE=/usr/lib/libreadline.a /usr/lib/libncurses.a
+SHARED_FLAGS=-shared
+SHARED_EXT=so
endif
CC = gcc
CXX = g++
@@ -30,9 +34,11 @@ INCLUDES = \
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
+LIBS = -lz -ldl -lpthread -liconv
+
CPPFLAGS += $(INCLUDES) -g -DSTDC_HEADERS $(CPPFLAGS_READLINE) -DHOOK_STDS -fexceptions -DWORDS_LITTLEENDIAN -fexceptions $(ARCH_FLAGS) $(HAVES) -DUSE_MPQLIB
-BASIC_LDFLAGS = $(ARCH_FLAGS) -rdynamic -g -fexception -lz -ldl -lpthread -liconv
+BASIC_LDFLAGS = $(ARCH_FLAGS) $(LIBS)
LDFLAGS += $(BASIC_LDFLAGS) $(LDFLAGS_READLINE) -L/usr/lib/oracle/11.1.0.1/client/lib $(LDFLAGS_MESA)
@@ -208,8 +214,11 @@ dep: $(ALL_DEPS)
luac: $(LUAC_OBJECTS)
$(LD) -o luac $(LUAC_OBJECTS) $(BASIC_LDFLAGS)
-lua-interface: $(ALL_OBJECTS)
- $(LD) -o lua-interface $(ALL_OBJECTS) $(LDFLAGS)
+lua-interface.$(SHARED_EXT): $(ALL_OBJECTS)
+ $(LD) $(SHARED_FLAGS) -o lua-interface.$(SHARED_EXT) $(ALL_OBJECTS) $(LDFLAGS)
+
+lua-interface: lua-interface.$(SHARED_EXT) lua-interface-main.o
+ $(LD) -o lua-interface ./lua-interface.$(SHARED_EXT) lua-interface-main.o
lua-interface-dbg: $(ALL_OBJECTS) $(DEBUG_OBJECTS)
$(LD) -o lua-interface-dbg $(ALL_OBJECTS) $(DEBUG_OBJECTS) $(LDFLAGS) -lfreetype -lftgl ../Mesa-7.0.3/lib/libGLU.a ../Mesa-7.0.3/lib/libOSMesa.a /usr/lib/libmysqlclient.a -locci -lclntsh `Magick++-config --libs`
diff --git a/src/lua-interface-main.c b/src/lua-interface-main.c
new file mode 100644
index 0000000..35579db
--- /dev/null
+++ b/src/lua-interface-main.c
@@ -0,0 +1,5 @@
+int dll_main(int argc, char ** argv);
+
+int main(int argc, char ** argv) {
+ dll_main(argc, argv);
+}
diff --git a/src/lua-interface-win32-main.c b/src/lua-interface-win32-main.c
deleted file mode 100644
index e268432..0000000
--- a/src/lua-interface-win32-main.c
+++ /dev/null
@@ -1,5 +0,0 @@
-int win32_dll_main(int argc, char ** argv);
-
-int main(int argc, char ** argv) {
- win32_dll_main(argc, argv);
-}
diff --git a/src/lua-interface.cpp b/src/lua-interface.cpp
index 79307a6..0765f4c 100644
--- a/src/lua-interface.cpp
+++ b/src/lua-interface.cpp
@@ -74,11 +74,12 @@ extern void luaosmesa_init(Lua * L) WEAK;
}
-#ifdef _WIN32
#ifndef NO_DLL
-#define main win32_dll_main
+#define main dll_main
#endif
+#ifdef _WIN32
+
#include <windows.h>
#include <ctype.h>
#include <conio.h>