[Bf-committers] [PATCH] automatically locating mxTextTools.so for linkage

LarstiQ bf-committers@blender.org
Tue, 12 Nov 2002 01:29:29 +0100


--/9DWx/yDrRhgMJTb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello list,

the attached patch adds two variables to source/nan_definitions.mk,
namely NAN_PYTHON_BINARY and NAN_MXTEXTTOOLS. There is also some logic
involved to guess the location of mxTextTools.so.
The NAN_MXTEXTTOOLS result is only used on freebsd, irix, linux and
solaris.
It depends on a working python binary and that the mxTextTools package
is installed, if that is not the case you might see funny errors like:
	g++-3.2: /TextTools/mxTextTools/mxTextTools.so: No such file or
	directory

There is no logic to fall back to different versions of python or that
you might execute the test from the place where mx is installed (in
which case it returns just 'mx' as Chris Want found out), instead
provided are defaults that should work on most systems, and can be
overridden by the user if needed.

It makes a guess on where the correct python binary is by combining
NAN_PYTHON and NAN_PYTHON_VERSION. It then executes a small bit of
python code to find out where the mx package is installed.
People who have multiple python binaries or want to keep linking with
libmxtexttools.a if they have it can override one of the introduced
variables to that end.

The issue this tries to solve is that in the default distribution of
mxTextTools (and distributions based on that, at least the Debian one)
don't contain a libmxtexttool.a, the NaN Makefile does want to link
against that tho. First I made a static library myself, but that is
suboptimal. That would either require people to build it themselves, or
the Blender Foundation would have to distribute a static lib apart from
the official mxTextTools. The package also does come with a file named
mxTextTools.so, without the lib prefix because it isn't really a shared
library meant to be linked against, but rather a python module.

The patch changes source/Makefile and source/nan_definitions.mk so that
mxTextTools.so is directly linked in, without letting the linker help.
That's rather bad, but it does get blender compiled and running.

Optimally this getting-around-ld wouldn't be needed, but importing mx
and just trusting on the python installation
(/usr/lib/python2.2/site-packages/mx/ for me, or
$(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/site-packages/mx/)
or somehow compiled statically for a static blender version.


Comments would be very welcome, the #blendersauce collective isn't
entirely sure what mxTextTools does in blender and if it is really needed
(commenting it out does work, but importing vrml borks in that case).

Concluding my first post I would like to thank Chris Want (Hos) for stepping
up and asking for new blood :) 

	Wouter van Heyst

--/9DWx/yDrRhgMJTb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mxtexttools.diff"

Index: source/Makefile
===================================================================
RCS file: /cvs01/blender/source/Makefile,v
retrieving revision 1.11
diff -u -b -B -r1.11 Makefile
--- Makefile	2002/11/08 10:16:47	1.11
+++ Makefile	2002/11/11 17:43:28
@@ -312,7 +317,7 @@
   endif
   endif
     PYLIB = $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a
-    PYLIB += $(NAN_PYTHON)/mxTextTools/libmxtexttools.a
+    PYLIB += $(NAN_MXTEXTTOOLS) 
 endif
 
 ifeq ($(OS),irix)
@@ -321,7 +326,7 @@
     BINTARGETS += blenderplayer
     BINTARGETS += plugin
     PYLIB = $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a
-    PYLIB += $(NAN_PYTHON)/mxTextTools/libmxtexttools.a
+    PYLIB += $(NAN_MXTEXTTOOLS)
 endif
 
 ifeq ($(OS),linux)
@@ -344,7 +349,7 @@
     BINTARGETS += blenderpublisher
   endif
     PYLIB = $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a
-    PYLIB += $(NAN_PYTHON)/mxTextTools/libmxtexttools.a
+    PYLIB += $(NAN_MXTEXTTOOLS)
 endif
 
 ifeq ($(OS),openbsd)
@@ -361,7 +366,7 @@
     BINTARGETS += blenderssr
   endif
     PYLIB = $(NAN_PYTHON)/lib/python$(NAN_PYTHON_VERSION)/config/libpython$(NAN_PYTHON_VERSION).a
-    PYLIB += $(NAN_PYTHON)/mxTextTools/libmxtexttools.a
+    PYLIB += $(NAN_MXTEXTTOOLS)
     PYLIB += $(NAN_ZLIB)/lib/libz.a
 
     BCLIB += $(NAN_ZLIB)/lib/libz.a
Index: source/nan_definitions.mk
===================================================================
RCS file: /cvs01/blender/source/nan_definitions.mk,v
retrieving revision 1.6
diff -u -b -B -r1.6 nan_definitions.mk
--- nan_definitions.mk	2002/11/05 20:20:50	1.6
+++ nan_definitions.mk	2002/11/11 17:43:28
@@ -46,6 +46,8 @@
     export NAN_OBJDIR ?= $(NANBLENDERHOME)/obj
     export NAN_PYTHON ?= $(LCGDIR)/python
     export NAN_PYTHON_VERSION ?= 2.0
+    export NAN_PYTHON_BINARY ?= $(NAN_PYTHON)/bin/python$(NAN_PYTHON_VERSION)
+    export NAN_MXTEXTTOOLS ?= $(shell $(NAN_PYTHON_BINARY) -c 'import mx; print mx.__path__[0]')/TextTools/mxTextTools/mxTextTools.so 
     export NAN_OPENAL ?= $(LCGDIR)/openal
     export NAN_FMOD ?= $(LCGDIR)/fmod
     export NAN_JPEG ?= $(LCGDIR)/jpeg

--/9DWx/yDrRhgMJTb--