Hello,
Here's an updated patch to run Inventor on Darwin/MacOS X systems. Just save
this email to a text file named 'inventor-2.1.5.9-darwin-v2.patch' and note the
documentation below. This patch should be applied to a clean checkout of the
inventor source code.
Inventor 2.1.5.9 Darwin/MacOS X Patch v2
- Chris Scharver, scharver@xxxxxxxxxxx
June 21, 2003
This patch allows building SGI's Open Inventor library on
darwin/MacOS X systems with Apple's X11 installed. It should work
with XDarwin as well, but I haven't tested it. This version
includes support for dynamic loading of nodes. All components of
the default build process will complete properly. Compiling some
programs within apps/examples will require modifying them to
conform to the ANSI C definition of main returning int rather
than void. Also, because of issues related to the
case-insensitivity of the HFS+ file system, you will need to set
the IVPREFIX environment variable to something other than "/"
before starting the build process. The file /usr/lib/libfl.a will
cause a build error otherwise.
The following third-party libraries are required for everything
to build on MacOS X 10.2.6:
dlcompat <http://www.opendarwin.org/projects/dlcompat/>
lesstif <http://www.lesstif.org/>
libiconv <http://www.gnu.org/software/libiconv/>
libjpeg <http://freshmeat.net/projects/libjpeg/>
To apply this patch:
cd inventor/
patch -p0 < inventor-2.1.5.9-darwin-v2.patch
Once everything has been built, you will need to add the
resulting install path to your DYLD_LIBRARY_PATH environment
variable. This path is the one used to locate dynamic shared
libraries at execution time.
Thanks to Nicolas Holzschuch <Nicolas.Holzschuch@xxxxxxx> for
doing most of the dirty work in previously getting the code up
and running on OS X. Thanks also to Jonathan Lim <jlim@xxxxxxx>
who has helped to clean up a lot of the messier problems from the
first version of this patch.
* apps/demos/textomatic/textomatic.c++
- Included libcharset.h, part of GNU libiconv, since nl_types.h and
langinfo.h are not present on darwin systems.
- (main) Added __APPLE__ call for locale_charset() to determine the
current language encoding. Part of GNU libiconv, this call is
equivalent to nl_langinfo(CODESET).
* lib/database/include/machine.h
- Added MACHINE_WORD_FORMAT and MACHINE_FLOAT_FORMAT settings for
Apple hardware.
* lib/database/src/sb/SbTime.c++
- (SbTime::formatDate) Added __APPLE__ check for calling localtime.
* lib/database/src/so/SoType.c++
- (SoType::fromName) __GNUC_MINOR__ checks for >= 1 since Apple's
gcc 3.1 uses the same C++ ABI name mangling as gcc 3.2. (Possibly
conflicts with fsf gcc 3.1?)
* lib/database/src/so/engines/SoCalcParse.y
- Included float.h and limits.h for __APPLE__. Darwin does not have
values.h.
- Changed MINFLOAT to FLT_MIN for __APPLE__ since MINFLOAT is not
defined in system headers.
* lib/database/src/so/nodes/nurbs/head/mymath.h
- Added define for sqrtf if using _DOUBLE_MATH_ONLY. Darwin does
not define sqrtf() even through it has a man page.
* lib/database/src/so/sensors/SoSensorMgr.c++
- Included unistd.h for __APPLE__ since it defines select() and
FD_ZERO().
* libFL/ang/GNUmakefile
- Adds freetype2 included with X11INCDIR to the LCINCS for
compilation.
* libFL/ang/fl.c
- (_flDestroyFont) Calling CHECK() works on __APPLE__.
* make/ivcommondefs
- Adds MATHDEFS for darwin to LCXXDEFS and LCDEFS.
- Added Darwin build options.
- ARFLAGS are set such that ranlib is not needed.
- LOCALRULES includes make/localrules.apple.
* make/ivcommonrules
- Added $(BUNDLE) to all_ivbin and TARGETS targets.
* make/system
- Defined usingDarwin as the system check flag.
* make/localrules.apple
- Renames .LIBDSO targets from .so to .dylib.
- LLDLIBS includes X11 libraries in the proper order and also adds
-licov for text encoding with GNU libiconv; -ldl for the dlcompat
library; and -lcc_dynamic and -lstdc++ for C++ dynamic linking.
- BUNDLE defined as DSO targets. Builds shared objects--"bundles"
in mach-o terminology--with the C++ compiler and the appropriate
flags. After being built, the bundles are renamed to have the
common .so suffix.
Index: apps/demos/textomatic/textomatic.c++
===================================================================
RCS file: /cvs/inventor/apps/demos/textomatic/textomatic.c++,v
retrieving revision 1.6
diff -u -r1.6 textomatic.c++
--- apps/demos/textomatic/textomatic.c++ 1 Jun 2002 02:22:21 -0000
1.6
+++ apps/demos/textomatic/textomatic.c++ 27 Jun 2003 18:06:20 -0000
@@ -42,8 +42,12 @@
#include <string.h>
#include <unistd.h>
#include <iconv.h>
+#ifdef __APPLE__
+#include <libcharset.h>
+#else
#include <nl_types.h>
#include <langinfo.h>
+#endif
#include <Inventor/Xt/SoXt.h>
#include <Inventor/SoDB.h>
#include <Inventor/Xt/SoXtRenderArea.h>
@@ -410,7 +414,11 @@
Widget w = SoXt::init(argv[0],"Textomatic");
if (w == NULL) exit(1);
+#ifdef __APPLE__
+ const char *nl_encord = locale_charset();
+#else
char *nl_encord = nl_langinfo( CODESET );
+#endif
if ( (global_iconvCodeL2 = iconv_open( "UCS-2", nl_encord ))==(iconv_t)-1
) {
fprintf( stderr, "textomatic: iconv_open error.\n" );
}
Index: lib/database/include/machine.h
===================================================================
RCS file: /cvs/inventor/lib/database/include/machine.h,v
retrieving revision 1.4
diff -u -r1.4 machine.h
--- lib/database/include/machine.h 25 Sep 2001 00:45:32 -0000 1.4
+++ lib/database/include/machine.h 27 Jun 2003 18:06:20 -0000
@@ -145,10 +145,22 @@
#if __i386__ || __ia64__
-#define MACHINE_WORD_FORMAT DGL_LITTLE_ENDIAN
-#define MACHINE_FLOAT_FORMAT DGL_NON_IEEE
+#define MACHINE_WORD_FORMAT DGL_LITTLE_ENDIAN
+#define MACHINE_FLOAT_FORMAT DGL_NON_IEEE
#endif /* __i386__ || __ia64__ */
+
+
+/*
+ * Apple Darwin (Mac OS X) machine dependent setup
+ */
+
+#ifdef __APPLE__
+
+#define MACHINE_WORD_FORMAT DGL_BIG_ENDIAN
+#define MACHINE_FLOAT_FORMAT DGL_BIG_IEEE
+
+#endif /* __APPLE__ */
/*
Index: lib/database/src/sb/SbTime.c++
===================================================================
RCS file: /cvs/inventor/lib/database/src/sb/SbTime.c++,v
retrieving revision 1.5
diff -u -r1.5 SbTime.c++
--- lib/database/src/sb/SbTime.c++ 6 Mar 2002 00:00:54 -0000 1.5
+++ lib/database/src/sb/SbTime.c++ 27 Jun 2003 18:06:20 -0000
@@ -264,7 +264,7 @@
{
char buf[200];
-#if (_MIPS_SZLONG == 64 || __ia64)
+#if (_MIPS_SZLONG == 64 || __ia64 || __APPLE__)
int seconds;
seconds = (int) t.tv_sec;
strftime(buf, sizeof(buf), fmt, localtime((const time_t *) &seconds));
Index: lib/database/src/so/SoType.c++
===================================================================
RCS file: /cvs/inventor/lib/database/src/so/SoType.c++,v
retrieving revision 1.5
diff -u -r1.5 SoType.c++
--- lib/database/src/so/SoType.c++ 1 May 2003 22:33:22 -0000 1.5
+++ lib/database/src/so/SoType.c++ 27 Jun 2003 18:06:20 -0000
@@ -295,7 +295,7 @@
if (dsoHandle == NULL)
return SoType::badType();
-#if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))
+#if ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define DUMMY_FUNC "_ZN%d%s9initClassEv"
#else
#define DUMMY_FUNC "initClass__%d%s%s"
Index: lib/database/src/so/engines/SoCalcParse.y
===================================================================
RCS file: /cvs/inventor/lib/database/src/so/engines/SoCalcParse.y,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 SoCalcParse.y
--- lib/database/src/so/engines/SoCalcParse.y 15 Aug 2000 12:56:18 -0000
1.1.1.1
+++ lib/database/src/so/engines/SoCalcParse.y 27 Jun 2003 18:06:20 -0000
@@ -20,7 +20,12 @@
#include <Inventor/errors/SoDebugError.h>
#include "SoCalcExpr.h"
#include <stdio.h>
+#ifdef __APPLE__
+#include <float.h>
+#include <limits.h>
+#else
#include <values.h>
+#endif
#include <math.h>
#include <ctype.h>
#include <strings.h>
@@ -38,7 +43,11 @@
float val;
} Constants[] = {
{ "MAXFLOAT", MAXFLOAT },
+#ifdef __APPLE__
+ { "MINFLOAT", FLT_MIN },
+#else
{ "MINFLOAT", MINFLOAT },
+#endif
{ "M_E", M_E },
{ "M_LOG2E", M_LOG2E },
{ "M_LOG10E", M_LOG10E },
Index: lib/database/src/so/nodes/nurbs/head/mymath.h
===================================================================
RCS file: /cvs/inventor/lib/database/src/so/nodes/nurbs/head/mymath.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mymath.h
--- lib/database/src/so/nodes/nurbs/head/mymath.h 15 Aug 2000 12:56:22
-0000 1.1.1.1
+++ lib/database/src/so/nodes/nurbs/head/mymath.h 27 Jun 2003 18:06:20
-0000
@@ -61,4 +61,8 @@
#include <math.h>
#endif
+#ifdef _DOUBLE_MATH_ONLY
+#define sqrtf sqrt
+#endif
+
#endif /* __glumymath_h_ */
Index: lib/database/src/so/sensors/SoSensorMgr.c++
===================================================================
RCS file: /cvs/inventor/lib/database/src/so/sensors/SoSensorMgr.c++,v
retrieving revision 1.2
diff -u -r1.2 SoSensorMgr.c++
--- lib/database/src/so/sensors/SoSensorMgr.c++ 14 Oct 2000 10:46:08 -0000
1.2
+++ lib/database/src/so/sensors/SoSensorMgr.c++ 27 Jun 2003 18:06:20 -0000
@@ -57,6 +57,9 @@
#ifdef __sgi
#include <osfcn.h>
#endif // __sgi
+#ifdef __APPLE__
+#include <unistd.h>
+#endif // __APPLE__
#ifdef DEBUG
#include <SoDebug.h>
Index: libFL/ang/GNUmakefile
===================================================================
RCS file: /cvs/inventor/libFL/ang/GNUmakefile,v
retrieving revision 1.1
diff -u -r1.1 GNUmakefile
--- libFL/ang/GNUmakefile 24 Mar 2001 02:34:24 -0000 1.1
+++ libFL/ang/GNUmakefile 27 Jun 2003 18:06:20 -0000
@@ -3,7 +3,11 @@
ARCHIVE = libFL.a
+ifeq ($(usingDarwin), 1)
+LCINCS += -I$(X11INCDIR)/freetype2
+else
LCINCS += -I/usr/include/freetype2
+endif
CFILES = fl.c flclient.c flfreetype.c
Index: libFL/ang/fl.c
===================================================================
RCS file: /cvs/inventor/libFL/ang/fl.c,v
retrieving revision 1.2
diff -u -r1.2 fl.c
--- libFL/ang/fl.c 1 Jun 2002 02:16:10 -0000 1.2
+++ libFL/ang/fl.c 27 Jun 2003 18:06:20 -0000
@@ -245,7 +245,7 @@
_flDestroyFont(FLfontStruct *fs)
{
FLfontImpl *impl = _flGetFontImpl();
-#ifdef WIN32
+#if defined(WIN32) || defined(__APPLE__)
CHECK(fs, impl, destroyFont, NULL);
#else
CHECK(fs, impl, destroyFont, /* nothing to return */);
Index: make/ivcommondefs
===================================================================
RCS file: /cvs/inventor/make/ivcommondefs,v
retrieving revision 1.9
diff -u -r1.9 ivcommondefs
--- make/ivcommondefs 1 Jun 2002 02:16:10 -0000 1.9
+++ make/ivcommondefs 27 Jun 2003 18:06:20 -0000
@@ -9,9 +9,13 @@
# Settings for systems without single-precision math functions.
#
-# MATHDEFS = -D_DOUBLE_MATH_ONLY
-# LCXXDEFS += $(MATHDEFS)
-# LCDEFS += $(MATHDEFS)
+ifeq ($(usingDarwin), 1)
+
+MATHDEFS = -D_DOUBLE_MATH_ONLY
+LCXXDEFS += $(MATHDEFS)
+LCDEFS += $(MATHDEFS)
+
+endif
@@ -91,6 +95,40 @@
#
+# Settings for Apple Darwin (Mac OS X) systems.
+#
+
+ifeq ($(usingDarwin), 1)
+
+FREETYPE = 1
+
+CC = /usr/bin/gcc
+C++ = /usr/bin/g++
+LD = /usr/bin/libtool
+
+ARFLAGS = srv
+INSTALL = /usr/bin/install
+
+DARWINOPTS = -dynamic -fno-common -D_DOUBLE_MATH_ONLY
+LCXXOPTS += $(DARWINOPTS)
+LCOPTS += $(DARWINOPTS)
+
+X11DIR = /usr/X11R6
+X11INCDIR = $(X11DIR)/include
+X11LIBDIR = $(X11DIR)/lib
+
+LCXXINCS += -I$(X11INCDIR)
+LCINCS += -I$(X11INCDIR)
+
+LDDSOOPTS += -dynamic -all_load -L$(X11LIBDIR)
+LDOPTS += -multiply_defined suppress -L$(X11LIBDIR)
+LOCALRULES = $(IVDEPTH)/make/localrules.apple
+
+endif
+
+
+
+#
# Determine optimization from LIBTYPE.
#
@@ -172,7 +210,9 @@
ifneq (, $(findstring debug, $(LIBTYPE)))
LLDDSOOPTS += -L$(IVDLIBDIR)
LLDOPTS += -L$(IVDLIBDIR)
+CXXDSOOPTS += -L$(IVDLIBDIR)
else
LLDDSOOPTS += -L$(IVLIBDIR)
LLDOPTS += -L$(IVLIBDIR)
+CXXDSOOPTS += -L$(IVLIBDIR)
endif
Index: make/ivcommonrules
===================================================================
RCS file: /cvs/inventor/make/ivcommonrules,v
retrieving revision 1.4
diff -u -r1.4 ivcommonrules
--- make/ivcommonrules 1 Jun 2002 02:16:10 -0000 1.4
+++ make/ivcommonrules 27 Jun 2003 18:06:20 -0000
@@ -128,7 +128,8 @@
# Convenience assignments. TARGETS are removed by 'make clobber'.
#
-all_ivbin: $(LIBDSO) $(PROGRAM) $(PROGRAMS_1) $(PROGRAMS_2) $(ARCHIVE) $(DSO)
+all_ivbin: $(LIBDSO) $(PROGRAM) $(PROGRAMS_1) $(PROGRAMS_2) $(ARCHIVE) \
+ $(DSO) $(BUNDLE)
TARGETS += $(LIBDSO) $(PROGRAM) $(PROGRAMS_1) $(PROGRAMS_2) $(PROGRAMS_EXT) \
- $(ARCHIVE) $(DSO)
+ $(ARCHIVE) $(DSO) $(BUNDLE)
Index: make/localrules.apple
===================================================================
diff -uN make/localrules.apple
--- make/localrules.apple Wed Dec 31 18:00:00 1969
+++ make/localrules.apple Fri Jun 20 14:08:52 2003
@@ -0,0 +1,17 @@
+# Rename shared object and specify additional libraries
+# for Apple Darwin (Mac OS X) systems.
+
+ifeq ($(usingDarwin), 1)
+
+LIBDSO := $(LIBDSO:.so=.dylib)
+LLDLIBS += -lXm -lXt -lX11 -lGLU -lGL -liconv -ldl -lcc_dynamic -lstdc++
+
+BUNDLE := $(DSO:.so=.bundle)
+DSO :=
+CXXDSOOPTS += -bundle -flat_namespace -undefined suppress -L$(X11LIBDIR)
+
+$(BUNDLE): $(OBJECTS)
+ $(CXX) $(CXXDSOOPTS) $(OBJECTS) $(LDLIBS) -o $@
+ mv $@ $(@:.bundle=.so)
+
+endif
Index: make/system
===================================================================
RCS file: /cvs/inventor/make/system,v
retrieving revision 1.4
diff -u -r1.4 system
--- make/system 25 Sep 2001 00:45:57 -0000 1.4
+++ make/system 27 Jun 2003 18:06:20 -0000
@@ -1,6 +1,7 @@
usingIrix = 0
usingLinux = 0
usingFreeBSD = 0
+usingDarwin = 0
UNAME = $(shell uname | tr '[:upper:]' '[:lower:]')
@@ -14,4 +15,8 @@
ifneq (, $(findstring freebsd, $(UNAME)))
usingFreeBSD = 1
+endif
+
+ifneq (, $(findstring darwin, $(UNAME)))
+usingDarwin = 1
endif
|