From 29b31f7584d80c9e4c500b76d72215e5c059446e Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 23 Mar 2009 11:00:44 -0700 Subject: Adding better OpenGL glue. --- Makefile | 31 ++++++++++++++++++++++++------- Makefile.mingw32 | 8 ++++++++ src/generate-gl-glue.sh | 24 ++++++++++++++++++++++-- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 5d024ae..568a06d 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ SHARED_FLAGS=-dynamiclib SHARED_EXT=dylib LIBS=-liconv LD = g++ +LDFLAGS_GL = -L/usr/X11/lib -lGLU -lGL -X11 -dylib_file \ +/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\ +/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib else ARCH_FLAGS=-march=i686 -m32 LDFLAGS_MESA=-u gluNewTess -Wl,--whole-archive ../Mesa-7.2/lib/libGLU.a ../Mesa-7.2/lib/libOSMesa.a -Wl,--no-whole-archive @@ -16,6 +19,7 @@ LDFLAGS_READLINE=/usr/lib/libreadline.a /usr/lib/libncurses.a SHARED_FLAGS=-shared SHARED_EXT=so LD = g++ -m32 +LDFLAGS_GL = -lGLU -lGL endif CC = gcc CXX = g++ @@ -42,7 +46,7 @@ CPPFLAGS += $(INCLUDES) -g -DSTDC_HEADERS $(CPPFLAGS_READLINE) -DHOOK_STDS -fexc BASIC_LDFLAGS = $(ARCH_FLAGS) $(LIBS) -LDFLAGS += $(BASIC_LDFLAGS) $(LDFLAGS_READLINE) -L/usr/lib/oracle/11.1.0.1/client/lib $(LDFLAGS_MESA) +LDFLAGS += $(BASIC_LDFLAGS) $(LDFLAGS_READLINE) -L/usr/lib/oracle/11.1.0.1/client/lib vpath %.c ../Baltisot/lib:../Baltisot/src:../Baltisot/lib/zlib/src:../Baltisot/lib/lua/src:../Baltisot/lib/lua/src/LuaLib:src:../paperIdol/src:../mogltk/lib:../tinyxml:../lua-modules/src vpath %.cc ../Baltisot/lib:../Baltisot/src:../Baltisot/lib/zlib/src:../Baltisot/lib/lua/src:../Baltisot/lib/lua/src/LuaLib:src:../paperIdol/src:../mogltk/lib:../tinyxml:../lua-modules/src @@ -199,7 +203,7 @@ httplib.lua \ plugin-luaosmesa.cc \ dds.c -WHOLE_SOURCES = $(BALTISOT_SOURCES) $(LUA_SOURCES) $(LUAINTERFACE_SOURCES) +WHOLE_SOURCES = $(BALTISOT_SOURCES) $(LUA_SOURCES) $(LUAINTERFACE_SOURCES) gl-glue.s DEBUG_SOURCES = $(DEBUG_MODULES) LUAINTERFACE_OBJECTS = $(addsuffix .o, $(notdir $(basename $(LUAINTERFACE_SOURCES)))) @@ -216,17 +220,24 @@ dep: $(ALL_DEPS) luac: $(LUAC_OBJECTS) $(LD) -o luac $(LUAC_OBJECTS) $(BASIC_LDFLAGS) -lua-interface.$(SHARED_EXT): $(ALL_OBJECTS) - $(LD) $(SHARED_FLAGS) -o lua-interface.$(SHARED_EXT) $(ALL_OBJECTS) $(LDFLAGS) +lua-interface-mesa.$(SHARED_EXT): $(ALL_OBJECTS) + $(LD) $(SHARED_FLAGS) -o lua-interface.$(SHARED_EXT) $(ALL_OBJECTS) $(LDFLAGS) $(LDFLAGS_MESA) + mv lua-interface.$(SHARED_EXT) $@ + ln -sf $@ lua-interface.$(SHARED_EXT) -lua-interface: lua-interface.$(SHARED_EXT) lua-interface-main.o - $(LD) -o lua-interface ./lua-interface.$(SHARED_EXT) lua-interface-main.o +lua-interface-gl.$(SHARED_EXT): $(ALL_OBJECTS) + $(LD) $(SHARED_FLAGS) -o lua-interface.$(SHARED_EXT) $(ALL_OBJECTS) $(LDFLAGS) $(LDFLAGS_GL) + mv lua-interface.$(SHARED_EXT) $@ + ln -sf $@ lua-interface.$(SHARED_EXT) + +lua-interface: lua-interface-mesa.$(SHARED_EXT) lua-interface-main.o + $(LD) -o $@ ./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` clean: - rm -f lua-interface luac *.o *.dep *.so *.dylib + rm -f lua-interface-mesa lua-interface-gl luac *.o *.dep *.so *.dylib %.dep : %.c $(CC) $(CPPFLAGS) -M -MF $@ $< @@ -243,4 +254,10 @@ clean: %.clua : %.lua ./luac -o $@ $< +gl-glue.dep: + touch gl-glue.dep + +gl-glue.s: + src/generate-gl-glue.sh > gl-glue.s + -include $(ALL_DEPS) diff --git a/Makefile.mingw32 b/Makefile.mingw32 index ce41902..b196de2 100644 --- a/Makefile.mingw32 +++ b/Makefile.mingw32 @@ -1,7 +1,15 @@ +SYSTEM=$(shell uname) +ifeq ($(SYSTEM),Darwin) +CC = i386-mingw32-gcc +CXX = i386-mingw32-g++ +LD = i386-mingw32-g++ +STRIP = i386-mingw32-strip +else CC = i586-mingw32msvc-gcc CXX = i586-mingw32msvc-g++ LD = i586-mingw32msvc-g++ STRIP = i586-mingw32msvc-strip +endif INCLUDES = \ -I../mogltk/include \ diff --git a/src/generate-gl-glue.sh b/src/generate-gl-glue.sh index b5ba951..f6abf2a 100755 --- a/src/generate-gl-glue.sh +++ b/src/generate-gl-glue.sh @@ -4,7 +4,13 @@ base="/Users/pixel/sources/Mesa-7.2/include/GL" files="gl.h glu.h" -os=`uname` +if [ "$1" != "" ] ; then + os=$1 +fi + +if [ "$os" == "" ] ; then + os=`uname` +fi for f in $files ; do cat $base/$f ; done | grep ^GLAPI.*ENTRY | @@ -33,15 +39,29 @@ done echo ".subsections_via_symbols" -else +elif [ "$os" == "Linux" ] ; then cat tmp-symbol-list.txt | while read symbol ; do echo ".globl m$symbol" echo ".type m$symbol, @function" + echo "m$symbol:" echo "jmp $symbol" echo ".size m$symbol, .-m$symbol" done +elif [ "$os" == "mingw32" ] ; then + +cat tmp-symbol-list.txt | while read symbol do + echo ".globl _m$symbol" + echo ".def _m$symbol; .scl 2; .type 32; .endef;" + echo "_m$symbol:" + echo "jmp _$symbol" +done + +cat tmp-symbol-list.txt | while read symbol do + echo ".def _$symbol; .scl 2; .type 32; .endef;" +done + fi rm tmp-symbol-list.txt -- cgit v1.2.3