info-inventor-dev
[Top] [All Lists]

[PATCH] MacOS X support for Inventor 2.1.5.9

To: info-inventor-dev@xxxxxxxxxxx
Subject: [PATCH] MacOS X support for Inventor 2.1.5.9
From: Chris Scharver <scharver@xxxxxxxxxxx>
Date: Tue, 1 Apr 2003 14:10:45 -0600
Sender: info-inventor-dev-bounce@xxxxxxxxxxx
Inventor 2.1.5.9 Darwin/MacOS X Patch
Chris Scharver, scharver@xxxxxxxxxxx

To apply this patch, first download the Inventor 2.1.5.9 source. You
then need to change to the source directory and use 'patch':

cd inventor/
patch -p0 > inventor-2.1.5.9-macosx.patch

One component that does not work on OS X is the collection of example
dynamically-loaded nodes in apps/nodes. The current build setup works
under the assumption that types for a shared library and a dynamic load
library are the same. Under OS X they are not. Shared libraries will
compile fine, but a loadable library "bundle" must be compiled
differently. Separate build profiles are needed for shared libraries and
loadable bundles.

Some of the programs in apps/samples  and apps/examples will not
work yet due to minor changes required. The OS X gcc compiler requires
that main is defined to return an int rather than void. I'll look at them
in due time, but it's been more important to get the core library
functionality in place.

When using the shared library, one must set the DYLD_LIBRARY_PATH
environment variable and include the directory with the installed Open
Inventor dynamic libraries.

Special 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.

The following changes were made:

* lib/GNUmakefile
    - Changed Darwin LIBDSO to libInventor.dylib.
    - Added extra Darwin link libraries dl, iconv, cc_dynamic, and
      stdc++.
* lib/database/include/machine.h
    - Added settings for Apple hardware.
* lib/database/src/sb/SbTime.c++
    - (SbTime::formatDate()) Added __APPLE__ check for calling
      localtime..
* lib/database/src/so/engines/SoCalcParse.y
    - Included float.h and limits.h for __APPLE__.
    - Changed MINFLOAT to FLT_MIN for __APPLE__.
* lib/database/src/so/nodes/nurbs/clients/softsurfmaps.c++
    - Added define for sqrtf if using _DOUBLE_MATH_ONLY.
* lib/database/src/so/nodes/nurbs/libnurbs/curve.c++
    - Added define for sqrtf if using _DOUBLE_MATH_ONLY.
* lib/database/src/so/sensors/SoSensorMgr.c++
    - Included unistd.h for __APPLE__.
* libFL/ang/GNUmakefile
    - Changed LCINCS path for freetype2.
* libFL/ang/fl.c
    - (_flDestroyFont) Calling CHECK() works on  __APPLE__.
* libSoXt/GNUmakefile
    - Changed Darwin LIBDSO to libInventorXt.dylib.
    - Added extra Darwin link libraries dl, iconv, cc_dynamic, and
      stdc++.
* make/commondefs
    - Changed Darwin INSTALL tool path.
* make/ivcommondefs
    - Added Darwin compile and link settings.
    - Defined _DOUBLE_MATH_ONLY.
    - Added X11 link libraries to LLDOPTS.
    - Enabled FreeType by default.
    - Changed IVPREFIX to /usr/local/OpenInventor. Using /usr creates
      problems because there is a /usr/lib/libfl.a which causes link 
      conflicts by using -lFL. (The default OS X file system is case
      insensitive.) This variable must be changed per-system anyway,
      but on Darwin/OS X a value of /usr has conflicts..
* make/ivcommonrules
    - Added call to RANLIB after making an ARCHIVE on Darwin.
* make/system
    - Added support for Darwin.



Index: lib/GNUmakefile
===================================================================
RCS file: /cvs/inventor/lib/GNUmakefile,v
retrieving revision 1.4
diff -u -r1.4 GNUmakefile
--- lib/GNUmakefile     25 Sep 2001 00:45:32 -0000      1.4
+++ lib/GNUmakefile     28 Mar 2003 18:44:12 -0000
@@ -1,7 +1,11 @@
 IVDEPTH = ..
 include $(IVDEPTH)/make/ivcommondefs
 
+ifeq ($(usingDarwin), 1)
+LIBDSO = libInventor.dylib
+else
 LIBDSO = libInventor.so
+endif
 
 LLDDSOOPTS += -L$(IVDEPTH)/libimage -L$(FLDIR)
 
@@ -9,6 +13,11 @@
        -ljpeg -limage $(FLLIB) \
         -lX11 -lm \
         -lGLU -lGL
+
+ifeq ($(usingDarwin), 1)
+LLDLIBS += \
+        -ldl -liconv -lcc_dynamic -lstdc++
+endif
 
 OBJECTS = \
        ./database/src/sb/projectors/SbProjectors.o \
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      28 Mar 2003 18:44:12 -0000
@@ -138,6 +138,14 @@
 
 #endif /* vax */
 
+/*
+ * Apple Darwin/MacOS X machine dependent setup
+ */
+
+#ifdef __APPLE__
+#define MACHINE_WORD_FORMAT    DGL_BIG_ENDIAN
+#define MACHINE_FLOAT_FORMAT   DGL_BIG_IEEE
+#endif /* __APPLE__ */
 
 /*
  * Linux i386/ia64 machine dependent setup
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++      28 Mar 2003 18:44:13 -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/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   28 Mar 2003 18:44:13 -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/clients/softsurfmaps.c++
===================================================================
RCS file: 
/cvs/inventor/lib/database/src/so/nodes/nurbs/clients/softsurfmaps.c++,v
retrieving revision 1.2
diff -u -r1.2 softsurfmaps.c++
--- lib/database/src/so/nodes/nurbs/clients/softsurfmaps.c++    14 Oct 2000 
10:46:07 -0000      1.2
+++ lib/database/src/so/nodes/nurbs/clients/softsurfmaps.c++    28 Mar 2003 
18:44:13 -0000
@@ -48,6 +48,10 @@
 static float curTexPt[2] = {0.0, 0.0};
 static int validTexCoords = 0;
 
+#ifdef _DOUBLE_MATH_ONLY
+#define sqrtf sqrt
+#endif
+
 void 
 _SoNurbsVertex3SurfaceMap::point( float *v )
 {
Index: lib/database/src/so/nodes/nurbs/libnurbs/curve.c++
===================================================================
RCS file: /cvs/inventor/lib/database/src/so/nodes/nurbs/libnurbs/curve.c++,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 curve.c++
--- lib/database/src/so/nodes/nurbs/libnurbs/curve.c++  15 Aug 2000 12:56:22 
-0000      1.1.1.1
+++ lib/database/src/so/nodes/nurbs/libnurbs/curve.c++  28 Mar 2003 18:44:13 
-0000
@@ -49,6 +49,10 @@
 #include "quilt.h"
 #include "nurbsconsts.h"
 
+#ifdef _DOUBLE_MATH_ONLY
+#define sqrtf sqrt
+#endif
+
 /*--------------------------------------------------------------------------
  * Curve::Curve - copy curve from quilt and transform control points
  *--------------------------------------------------------------------------
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++ 28 Mar 2003 18:44:13 -0000
@@ -63,6 +63,10 @@
 static SbTime startTime;
 #endif
 
+#ifdef __APPLE__
+#include <unistd.h>
+#endif
+
 ////////////////////////////////////////////////////////////////////////
 //
 // Description:
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       28 Mar 2003 18:44:13 -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      28 Mar 2003 18:44:13 -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: libSoXt/GNUmakefile
===================================================================
RCS file: /cvs/inventor/libSoXt/GNUmakefile,v
retrieving revision 1.4
diff -u -r1.4 GNUmakefile
--- libSoXt/GNUmakefile 14 Oct 2000 10:46:08 -0000      1.4
+++ libSoXt/GNUmakefile 28 Mar 2003 18:44:13 -0000
@@ -1,11 +1,19 @@
 IVDEPTH = ..
 include $(IVDEPTH)/make/ivcommondefs
 
+ifeq ($(usingDarwin), 1)
+LIBDSO = libInventorXt.dylib
+else
 LIBDSO = libInventorXt.so
+endif
 
 LLDLIBS = \
        -lXm -lXt -lXext -lXi -lX11 -lm \
        -lInventor -lGLU -lGL
+
+ifeq ($(usingDarwin), 1)
+LLDLIBS += -lcc_dynamic -lstdc++
+endif
 
 LLDLIBS += $(shell [ -e $(X11LIBDIR)/libXp.so ] && echo -lXp)
 
Index: make/commondefs
===================================================================
RCS file: /cvs/inventor/make/commondefs,v
retrieving revision 1.5
diff -u -r1.5 commondefs
--- make/commondefs     15 Jun 2001 23:27:00 -0000      1.5
+++ make/commondefs     28 Mar 2003 18:44:13 -0000
@@ -617,7 +617,11 @@
 #
 # The install command to use.
 #
+ifeq ($(usingDarwin), 1)
+INSTALL        = $(TOOLROOT)/usr/bin/install
+else
 INSTALL        = $(TOOLROOT)/etc/install
+endif
 
 
 #
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   28 Mar 2003 18:44:13 -0000
@@ -13,6 +13,51 @@
 # LCXXDEFS += $(MATHDEFS)
 # LCDEFS += $(MATHDEFS)
 
+#
+# Settings for Darwin/MacOS X systems.
+#
+
+ifeq ($(usingDarwin), 1)
+
+CC = /usr/bin/gcc
+C++ = /usr/bin/g++
+
+MATHDEFS = -D_DOUBLE_MATH_ONLY
+
+DARWINOPTS = -fno-common
+LCXXOPTS += $(DARWINOPTS)
+LCOPTS += $(DARWINOPTS)
+
+LCXXDEFS += -dynamic $(MATHDEFS)
+LCDEFS += -dynamic $(MATHDEFS)
+
+LD = /usr/bin/libtool
+RANLIB = ranlib
+LDDSOOPTS += -dynamic -all_load
+LLDOPTS += -multiply_defined suppress -lXm -lXt -lX11 -lGLU -lGL
+
+# Commented these out since gcc automatically includes them.
+# LCXXINCS += -I/usr/local/include
+# LCINCS += -I/usr/local/include
+
+# LDDSOOPTS += -L/usr/local/lib
+# LDOPTS += -L/usr/local/lib
+
+# Use FreeType by default.
+FREETYPE = 1
+
+# And then X11R6
+X11DIR = /usr/X11R6
+X11INCDIR = $(X11DIR)/include
+X11LIBDIR = $(X11DIR)/lib
+
+LCXXINCS += -I$(X11INCDIR)
+LCINCS += -I$(X11INCDIR)
+
+LDDSOOPTS += -L$(X11LIBDIR)
+LDOPTS += -L$(X11LIBDIR)
+
+endif
 
 
 #
@@ -146,7 +191,7 @@
 # Inventor install directories.
 #
 
-IVPREFIX = /usr
+IVPREFIX = /usr/local/OpenInventor
 LCXXOPTS += -DIVPREFIX=\"$(IVPREFIX)\"
 LCOPTS += -DIVPREFIX=\"$(IVPREFIX)\"
 
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  28 Mar 2003 18:44:13 -0000
@@ -90,6 +90,9 @@
 
 $(ARCHIVE): $(LTARGETS) $(OBJECTS)
        $(AR) $(ARFLAGS) $@ $(OBJECTS)
+ifeq ($(usingDarwin), 1)
+       $(RANLIB) $@
+endif
 
 $(DSO): $(OBJECTS)
        $(LD) $(LDDSOOPTS) $(OBJECTS) $(LDLIBS) $(POST_LDDSOOPTS) -o $@
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 28 Mar 2003 18:44:13 -0000
@@ -1,6 +1,7 @@
 usingIrix = 0
 usingLinux = 0
 usingFreeBSD = 0
+using Darinw = 1
 
 UNAME = $(shell uname | tr '[:upper:]' '[:lower:]')
 
@@ -14,4 +15,8 @@
 
 ifneq (, $(findstring freebsd, $(UNAME)))
 usingFreeBSD = 1
+endif
+
+ifneq (, $(findstring darwin, $(UNAME)))
+usingDarwin = 1
 endif
--
Chris Scharver
Electronic Visualization Laboratory
The University of Illinois at Chicago
Ph: 312-996-3002   FAX: 312-413-7585
<http://www.evl.uic.edu/scharver/>

<Prev in Thread] Current Thread [Next in Thread>