From 80afddc08df598c0f923e20ff907d10009f9f0a7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 23 Jul 2002 10:48:22 +0000 Subject: [PATCH] Checked in Tino Schwarze's port to HP-UX. --- AUTHORS | 4 ++ Make/makedefs | 69 +++++++++++++++++++++++++++- Make/makerules | 18 +++++--- include/osg/Math | 2 +- include/osgGLUT/glut | 4 ++ src/Demos/osgcluster/README | 2 +- src/Demos/osgcluster/broadcaster.cpp | 2 + src/Demos/osgimpostor/README | 2 +- src/Demos/sgv/README | 2 +- src/osg/GLExtensions.cpp | 4 ++ src/osgDB/DynamicLibrary.cpp | 28 +++++++++++ src/osgDB/Registry.cpp | 6 +++ src/osgGLUT/Window.cpp | 2 +- src/osgPlugins/dx/DXWriter.cpp | 15 +++--- src/osgPlugins/gif/Makefile | 5 ++ src/osgPlugins/jpeg/Makefile | 4 ++ src/osgPlugins/osg/README | 2 +- src/osgPlugins/png/Makefile | 4 ++ src/osgPlugins/tiff/Makefile | 4 ++ src/osgText/Makefile | 11 +++-- 20 files changed, 165 insertions(+), 25 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8b57df688..6c52a127d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -111,6 +111,10 @@ Bob Kuehne Kristopher Bixler - port to OSX's native dynamic library support. +Tino Schwarze + -port to HP-UX. + + Indirect Contributors --------------------- diff --git a/Make/makedefs b/Make/makedefs index a5a26cf50..90a6889d2 100644 --- a/Make/makedefs +++ b/Make/makedefs @@ -49,7 +49,13 @@ INST_DOC = $(INST_SHARE_PREFIX)/OpenSceneGraph/doc INST_DATA = $(INST_SHARE_PREFIX)/OpenSceneGraph/data INST_DEMO_SRC = $(INST_SRC)/demos +ifneq ($(OS),HP-UX) LINK = ln -sf +else +# HP-UX linker seems to have problems with symlinked libs - +# somehow paths like "../../.." get into the executables +LINK = cp -f +endif INSTBINCMD = install -m 755 INSTDEVCMD = install -m 644 INSTLINKBINCMD = $(LINK) @@ -121,7 +127,7 @@ endif ifeq ($(OS),IRIX) C++ = CC - DEPFLAGS = -M + DEPARG = -M INC += -I${TOPDIR}/include -I/usr/freeware/ DEF += -LANG:std -OPT:Olimit=0 \ -DEBUG:woff=1682 -DEBUG:woff=3303\ @@ -406,6 +412,67 @@ ifeq ($(OS),MINGW) # osgcluster endif +#### HP-UX Specific definitions +# contributed by tino.schwarze@informatik.tu-chemnitz.de + +ifeq ($(OS),HP-UX) + + C++ = g++ + DEPARG = -M + INC += -I/opt/glut/include + DEF += -W -Wall -fPIC + OPTF = -O2 + # gcc 3.1 uses DWARF as default, my GDB might not yet support this... + # at least I've got problems everywhere + DBGF = -g -gstabs+ + SHARED = -shared -fPIC + ARCH = 32 +ifeq ($(ARCH),64) + # not yet tested + ARCHARGS = -march=2.0 + # I don't have performer - just a wild guess of the directory + PF_XTRA_LIBS = -L/opt/graphics/libpfdb -Wl,-rpath -Wl,/opt/graphics/libpfdb \ + -lpf3ds -lpfdem -lpfdted -lpfdwb -lpfdxf -lpfevt \ + -lpfflt -lpfgds -lpfgfo -lpfim -lpflsa -lpflsb \ + -lpfnff -lpfobj -lpfpegg -lpfpfb -lpfphd -lpfpts \ + -lpfrot -lpfscale -lpfsgf -lpfsgo -lpfsphere -lpfsv \ + -lpftri -lpfunc -lpfvct -lpfdu -lpfutil -lpf -limage +else + # at least my gcc 3.1 defaults to HP-PA RISC 1.1 + ARCHARGS = + # I don't have performer - just a wild guess of the directory + PF_XTRA_LIBS = -L/opt/graphics/libpfdb -Wl,-rpath -Wl,/usr/lib64/libpfdb \ + -lpf3ds -lpfdem -lpfdted -lpfdwb -lpfdxf -lpfevt \ + -lpfflt -lpfgds -lpfgfo -lpfim -lpflsa -lpflsb \ + -lpfnff -lpfobj -lpfpegg -lpfpfb -lpfphd -lpfpts \ + -lpfrot -lpfscale -lpfsgf -lpfsgo -lpfsphere -lpfsv \ + -lpftri -lpfunc -lpfvct -lpfdu -lpfutil -lpf -limage +endif + LINKARGS = -lpthread + LIB_EXT = sl + PLUGIN_EXT = sl + DYNAMICLIBRARYLIB = -ldld + OSG_LIBS = -losgGLUT -losgGA -losgDB -losgUtil -losg + # glut delivered with HP-UX is outdated + GLUT_LIB = -L/opt/glut/lib -lglut + GL_LIBS = -L/opt/graphics/OpenGL/lib -lGLU -lGL + X_LIBS = -L/usr/lib/X11R6 -lXext -lXi -lX11 -L/usr/lib/X11R4 -lXmu + SOCKET_LIBS = + # make sure that global constructors/destructors are called upon + # shl_load() / shl_unload() - this is a gcc specific workaround + OTHER_LIBS = -lm -Wl,+init -Wl,_GLOBAL__DI -Wl,+fini -Wl,_GLOBAL__DD + FREETYPE_INCLUDE = -I/opt/freetype/include -I/opt/freetype/include/freetype2 + FREETYPE_LIB = -L/opt/freetype/lib -lfreetype + PNG_INCLUDE = -I/opt/libpng/include + PNG_LIBS = -L/opt/libpng/lib -lpng -L/opt/zlib/lib -lz + JPEG_INCLUDE = -I/opt/jpeg-6/include + JPEG_LIBS = -L/opt/jpeg-6/lib -ljpeg + TIFF_INCLUDE = -I/opt/tiff-3.5/include + TIFF_LIB = -L/opt/tiff-3.5/lib -ltiff + GIF_INCLUDE = -I/opt/libungif/include + GIF_LIBS = -L/opt/libungif/lib -lungif + +endif VPATH=.. diff --git a/Make/makerules b/Make/makerules index 9f53e4fc0..b5cec385b 100644 --- a/Make/makerules +++ b/Make/makerules @@ -71,16 +71,22 @@ $(LIB) : $(OBJS) $(PLUGIN) : $(OBJS) $(C++) $(LDFLAGS) -bundle $(OBJS) $(LIBS) -o $@ else - +ifeq ($(OS),HP-UX) +# we need to explicitly tell the linker the library name - else it will +# include paths like ../../../libosg.sl into executables +$(LIB) $(PLUGIN) : $(OBJS) + $(C++) $(LDFLAGS) $(SHARED) $(OBJS) $(LIBS) -Wl,+h -Wl,$@ -Wl,-v -o $@ +else $(LIB) $(PLUGIN) : $(OBJS) $(C++) $(LDFLAGS) $(SHARED) $(OBJS) $(LIBS) -o $@ -endif +endif # not HP-UX +endif # not Darwin $(EXEC:=.dbg) : @[ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR) @cd $(DEBUGDIR); \ - $(MAKE) -f ../Makefile DOF=$(DBGF) TOPDIR=../${TOPDIR} \ + $(MAKE) -f ../Makefile "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \ THISDIR=../$(THISDIR)\ MAKEDEPEND=Makedepend $(EXEC) @$(MAKE) LNSRC=$(DEBUGDIR)/$(EXEC) LNDEST=$(BININST)/$(EXEC) __link @@ -88,7 +94,7 @@ $(EXEC:=.dbg) : $(LIB:=.dbg) : @[ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR) @cd $(DEBUGDIR);\ - $(MAKE) -f ../Makefile DOF=$(DBGF) TOPDIR=../${TOPDIR} \ + $(MAKE) -f ../Makefile "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \ THISDIR=../$(THISDIR)\ MAKEDEPEND=Makedepend $(LIB) @$(MAKE) LNSRC=$(DEBUGDIR)/$(LIB) LNDEST=$(LIBINST)/$(LIB) __link @@ -96,7 +102,7 @@ $(LIB:=.dbg) : $(PLUGIN:=.dbg) : @[ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR) @cd $(DEBUGDIR); \ - $(MAKE) -f ../Makefile DOF=$(DBGF) TOPDIR=../${TOPDIR} \ + $(MAKE) -f ../Makefile "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \ THISDIR=../$(THISDIR)\ MAKEDEPEND=Makedepend $(PLUGIN) @$(MAKE) LNSRC=$(DEBUGDIR)/$(PLUGIN) LNDEST=$(PLUGININST)/$(PLUGIN) __link @@ -144,7 +150,7 @@ endif ## Doesn't work too well, but leave the code here for later evaulation ifeq (0,1) ifneq ($(OS),IRIX) - $(C++) $(INC) $(DEPFLAGS) $< > .temp.dep + $(C++) $(INC) $(DEPARG) $< > .temp.dep if [ -f $(MAKEDEPEND) ] ; \ then \ grep -v $< $(MAKEDEPEND) > .temp.dep1;\ diff --git a/include/osg/Math b/include/osg/Math index debad487e..ccb5eea36 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -7,7 +7,7 @@ #include -#if defined(WIN32) || defined (macintosh)|| defined (sun) || defined (__DARWIN_OSX__) +#if defined(WIN32) || defined (macintosh)|| defined (sun) || defined (__DARWIN_OSX__) || defined(__hpux__) #include diff --git a/include/osgGLUT/glut b/include/osgGLUT/glut index 85549dbb4..caddfc641 100644 --- a/include/osgGLUT/glut +++ b/include/osgGLUT/glut @@ -8,7 +8,11 @@ #if defined(__DARWIN_OSX__) #include #else + #if defined(__hpux__) + #include + #else #include + #endif #endif #endif // __osgGLUT_h diff --git a/src/Demos/osgcluster/README b/src/Demos/osgcluster/README index 2d9da8288..2d83eca59 100644 --- a/src/Demos/osgcluster/README +++ b/src/Demos/osgcluster/README @@ -64,4 +64,4 @@ but until that day we're stuck with this 'hack'... Robert Osfield, -March 20001. +March 2001. diff --git a/src/Demos/osgcluster/broadcaster.cpp b/src/Demos/osgcluster/broadcaster.cpp index 4605265b7..8a307b2c8 100644 --- a/src/Demos/osgcluster/broadcaster.cpp +++ b/src/Demos/osgcluster/broadcaster.cpp @@ -36,6 +36,8 @@ #elif defined (WIN32) #include #include +#elif defined (__hpux__) + #include #else #error Teach me how to build on this system #endif diff --git a/src/Demos/osgimpostor/README b/src/Demos/osgimpostor/README index 6e2603a66..244042dfb 100644 --- a/src/Demos/osgimpostor/README +++ b/src/Demos/osgimpostor/README @@ -23,4 +23,4 @@ but until that day we're stuck with this 'hack'... Robert Osfield, -March 20001. +March 2001. diff --git a/src/Demos/sgv/README b/src/Demos/sgv/README index 6e2603a66..244042dfb 100644 --- a/src/Demos/sgv/README +++ b/src/Demos/sgv/README @@ -23,4 +23,4 @@ but until that day we're stuck with this 'hack'... Robert Osfield, -March 20001. +March 2001. diff --git a/src/osg/GLExtensions.cpp b/src/osg/GLExtensions.cpp index a4d0029e1..a6d7185da 100644 --- a/src/osg/GLExtensions.cpp +++ b/src/osg/GLExtensions.cpp @@ -71,6 +71,10 @@ void* osg::getGLExtensionFuncPtr(const char *funcName) symbol = NSLookupAndBindSymbol( temp.c_str() ); return NSAddressOfSymbol( symbol ); #else // all other unixes + // Note: although we use shl_load() etc. for Plugins on HP-UX, it's + // not neccessary here since we only used them because library + // intialization was not taking place with dlopen() which renders + // Plugins useless on HP-UX. static void *lib = dlopen("libGL.so", RTLD_LAZY); if (lib) return dlsym(lib, funcName); diff --git a/src/osgDB/DynamicLibrary.cpp b/src/osgDB/DynamicLibrary.cpp index 3dfebf383..df2ff97f8 100644 --- a/src/osgDB/DynamicLibrary.cpp +++ b/src/osgDB/DynamicLibrary.cpp @@ -6,8 +6,15 @@ #include #else // all other unix #include +#ifdef __hpux__ +// Although HP-UX has dlopen() it is broken! We therefore need to stick +// to shl_load()/shl_unload()/shl_findsym() +#include +#include +#else #include #endif +#endif #include @@ -31,6 +38,9 @@ DynamicLibrary::~DynamicLibrary() FreeLibrary((HMODULE)_handle); #elif defined(__DARWIN_OSX__) NSUnLinkModule(_handle, FALSE); +#elif defined(__hpux__) + // fortunately, shl_t is a pointer + shl_unload (static_cast(_handle)); #else // other unix dlclose(_handle); #endif @@ -58,6 +68,12 @@ DynamicLibrary* DynamicLibrary::loadLibrary(const std::string& libraryName) } // if (os_handle) return osgNew DynamicLibrary(libraryName,os_handle); notify(WARN) << "DynamicLibrary::failed loading "<(&_handle), procName.c_str(), TYPE_PROCEDURE, result) == 0) + { + return result; + } + else + { + notify(WARN) << "DynamicLibrary::failed looking up " << procName << std::endl; + notify(WARN) << "DynamicLibrary::error " << strerror(errno) << std::endl; + return NULL; + } #else // other unix return dlsym( _handle, procName.c_str() ); #endif diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 2713cfa44..562ef7c54 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -394,6 +394,9 @@ std::string Registry::createLibraryNameForExt(const std::string& ext) #endif #elif macintosh return "osgdb_"+ext; +#elif defined(__hpux__) + // why don't we use PLUGIN_EXT from the makefiles here? + return "osgdb_"+ext+".sl"; #else return "osgdb_"+ext+".so"; #endif @@ -417,6 +420,9 @@ std::string Registry::createLibraryNameForNodeKit(const std::string& name) #endif #elif macintosh return name; +#elif defined(__hpux__) + // why don't we use PLUGIN_EXT from the makefiles here? + return "lib"+name+".sl"; #else return "lib"+name+".so"; #endif diff --git a/src/osgGLUT/Window.cpp b/src/osgGLUT/Window.cpp index e0ed23e03..3db40c94e 100644 --- a/src/osgGLUT/Window.cpp +++ b/src/osgGLUT/Window.cpp @@ -65,7 +65,7 @@ bool Window::open() glutInitDisplayMode( _displayMode); - glutCreateWindow( _title.c_str() ); + glutCreateWindow( const_cast(_title.c_str()) ); glutReshapeFunc( reshapeCB ); glutVisibilityFunc( visibilityCB ); diff --git a/src/osgPlugins/dx/DXWriter.cpp b/src/osgPlugins/dx/DXWriter.cpp index 4438b7f39..969f6a6f0 100644 --- a/src/osgPlugins/dx/DXWriter.cpp +++ b/src/osgPlugins/dx/DXWriter.cpp @@ -605,6 +605,12 @@ inline int IsNaNorInf( float f ) return isnanf(f) || isinf(f); #elif defined(WIN32) return _isnan(f) || !_finite(f); +#elif defined(__hpux__) + // this is a hack - cmath from gcc 3.1 #undef's isinf() but does not + // redefine it (at least for me), enabling _GLIBCPP_USE_C99 also + // doesn't help (loads of compilation errors), so I just repeat the + // definition of isinf() from math.h here. + return isnan(f) || (_ISINF(f)); #else # error Teach me how to find non-numbers on this platform. return 0; @@ -1228,15 +1234,6 @@ void DXArrayWriter::WritePerVertexTCoords( //---------------------------------------------------------------------------- -inline float MAX( float x, float y ) - { return x > y ? x : y; } - -inline float MAX3( float x, float y, float z ) - { return MAX( MAX( x, y ), z ); } - -inline float MaxVecXYZ( const osg::Vec4 &v ) - { return MAX3( v[0], v[1], v[2] ); } - inline float Luminance( const osg::Vec4 &v ) { return 0.2122*v[0] + 0.7013*v[1] * 0.0865*v[2]; } diff --git a/src/osgPlugins/gif/Makefile b/src/osgPlugins/gif/Makefile index fbefc190f..5e44c8674 100644 --- a/src/osgPlugins/gif/Makefile +++ b/src/osgPlugins/gif/Makefile @@ -5,10 +5,15 @@ CXXFILES =\ ReaderWriterGIF.cpp\ +ifeq ($(OS),HP-UX) +INC += $(GIF_INCLUDE) +else INC += -I/usr/local/include\ -I/usr/freeware/include\ LINKARGS += -L/usr/freeware/lib$(ARCH) +endif + LIBS += $(OSG_LIBS) $(GIF_LIBS) $(OTHER_LIBS) diff --git a/src/osgPlugins/jpeg/Makefile b/src/osgPlugins/jpeg/Makefile index 29868bc77..19a317b3a 100644 --- a/src/osgPlugins/jpeg/Makefile +++ b/src/osgPlugins/jpeg/Makefile @@ -4,7 +4,11 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ ReaderWriterJPEG.cpp\ +ifneq ($(OS),HP-UX) INC += -I/usr/local/include/ +else +INC += $(JPEG_INCLUDE) +endif LIBS += $(OSG_LIBS) $(JPEG_LIBS) $(OTHER_LIBS) diff --git a/src/osgPlugins/osg/README b/src/osgPlugins/osg/README index 3393c5f99..73ff536ad 100644 --- a/src/osgPlugins/osg/README +++ b/src/osgPlugins/osg/README @@ -6,4 +6,4 @@ in the future to support inline images. Currently osg::Images are supported via the osgDB::Registry::read/writeImage methods and plugins. Robert Osfield, -March 20001. +March 2001. diff --git a/src/osgPlugins/png/Makefile b/src/osgPlugins/png/Makefile index 6ab1224e7..afd81f0ae 100644 --- a/src/osgPlugins/png/Makefile +++ b/src/osgPlugins/png/Makefile @@ -5,10 +5,14 @@ CXXFILES =\ ReaderWriterPNG.cpp\ LIBS += $(OSG_LIBS) $(PNG_LIBS) $(OTHER_LIBS) +ifneq ($(OS),HP-UX) INC += -I/usr/local/include\ -I/usr/freeware/include\ LINKARGS += -L/usr/freeware/lib$(ARCH) +else +INC += $(PNG_INCLUDE) +endif TARGET_BASENAME = png include $(TOPDIR)/Make/cygwin_plugin_def diff --git a/src/osgPlugins/tiff/Makefile b/src/osgPlugins/tiff/Makefile index c42cf575b..4a9515e83 100644 --- a/src/osgPlugins/tiff/Makefile +++ b/src/osgPlugins/tiff/Makefile @@ -6,8 +6,12 @@ CXXFILES =\ LIBS += $(OSG_LIBS) $(TIFF_LIB) $(OTHER_LIBS) +ifeq ($(OS),HP-UX) +INC += $(TIFF_INCLUDE) +else INC += -I/usr/local/include LDFLAGS += -L/usr/local/lib +endif TARGET_BASENAME = tiff include $(TOPDIR)/Make/cygwin_plugin_def diff --git a/src/osgText/Makefile b/src/osgText/Makefile index 86a77c332..b2d9ccbd0 100644 --- a/src/osgText/Makefile +++ b/src/osgText/Makefile @@ -32,16 +32,21 @@ CXXFILES =\ LIBS += $(OSG_LIBS) $(FREETYPE_LIB) $(OTHER_LIBS) +DEF += -DOSGTEXT_LIBRARY + +ifneq ($(OS),HP-UX) INC += -I$(OSGHOME)/include \ -I/usr/include/freetype2 \ -I/usr/local/include \ -I/usr/local/include/freetype2 \ -I/usr/freeware/include \ - -I/usr/freeware/include/freetype2 \ - -DEF += -DOSGTEXT_LIBRARY + -I/usr/freeware/include/freetype2 + LINKARGS += -L/usr/local/lib\ -L/usr/freeware/lib$(ARCH) +else +INC += $(FREETYPE_INCLUDE) +endif TARGET_BASENAME = osgText LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT)