HOWTO Merge OpenSceneGraph
From Gentoo Linux Wiki
Contents |
[edit] Introduction
This wiki page describes how to merge OpenSceneGraph with Gentoo Linux using local ebuild scripts. OpenSceneGraph lets you render advanced 3D worlds in real-time, see screenshots.
Bottom line: this page gives you three ebuild scripts, see links at end. Copy these to your local Portage tree (to dev-cpp for argument's sake) run ebuild digest on these new ebuilds then emerge them!
After merging the packages successfully, run
/usr/share/OpenSceneGraph/bin/osgviewer /usr/share/OpenSceneGraph/cow.osg
and you should see something like the following.
Question is: is this Barry?
[edit] Note
The osg ebuild sets up PATH and OSG_FILE_PATH environment variables. So, after emerging osg, if you refresh your system's environment either by logging back in or by using:
env-update
as root user then as your personal login:
source /etc/profile
then you can omit the paths, i.e. just enter
osgviewer cow.osg
The environment tells the system where to find osgviewer and where OSG can find its data files.
[edit] Overview
OpenSceneGraph actually comprises three dependent sub-packages: OpenThreads, Producer and finally OpenSceneGraph proper. The last two will not compile without OpenThreads, nor will OSG proper compile without Producer.
Note that OSG's Producer is a library just named libProducer, not OpenProducer or OSGProducer! It could therefore easily conflict with some other package in future. For now, package name follows the library name: just producer (or dev-cpp/producer assuming dev-cpp category).
The osg ebuild does not install examples by default. To include installation of examples in /usr/share/OpenSceneGraph add this line to your /etc/portage/package.use:
dev-cpp/osg examples
Some people might want to communicate their applications with someone not having OpenSceneGraph installed. The use flag static will cause the libraries also to be built for static linking.
dev-cpp/openthreads static dev-cpp/producer static dev-cpp/osg examples static
This gives you /usr/lib/libOpenThreads.a, /usr/lib/libProducer.a, /usr/lib/libosg*.a and /usr/lib/osgPlugins/osgdb_*.a in addition to the shared object files.
Note: if you do not specify the static use flags, and you get the message :make: *** No rule to make target `inststatic'. Stop.... add these use flags to make it build.
[edit] Optimisation
Package osg takes quite some time to compile! The source comprises a lot of C++. It makes sense therefore to enable fast compiler caching, package ccache. Add ccache to your make.conf features, i.e.
FEATURES="ccache"
and execute emerge ccache if not already merged. See TIP Use ccache for more details.
[edit] Ebuild scripts
Version 1.0_rc7:
The following ebuilds are now available in addition to the 0.9.9 ebuilds:
- dev-cpp/openthreads/openthreads-1.4.1_rc7.ebuild
- dev-cpp/producer/producer-1.0_rc7.ebuild
- dev-cpp/osg-1.0_rc7.ebuild
which can be downloaded as a single tarball further down the page. Unlike the 0.9.9 scripts, they just need to be unpacked to the portage overlay, but make sure they don't collide with anything you might have installed. If you need to customize further, read on through the excellent walkthrough below.
| File: dev-cpp/openthreads/openthreads-1.4.1_rc7.ebuild |
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils
DESCRIPTION="Cross platform, object orientated threading library maintained by the OpenSceneGraph team."
HOMEPAGE="http://www.openscenegraph.org"
SRC_URI="http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-1.0-rc7.zip"
SLOT="0"
LICENSE="LGPL-2.1"
KEYWORDS="x86"
IUSE="static"
DEPEND=""
S="${WORKDIR}/OSG_OP_OT-1.0-rc7/OpenThreads"
src_unpack() {
unpack OSG_OP_OT-1.0-rc7.zip
use static && epatch ${FILESDIR}/${P}-static.patch
}
src_compile() {
use static && ( emake static || die "static make failed" )
emake || die "shared make failed"
}
src_install() {
einstall INST_LOCATION="${D}/usr" || die "einstall failed"
}
|
| File: dev-cpp/openthreads/files/openthreads-1.4.1_rc7-static.patch |
diff -Naur OSG_OP_OT-1.0-rc7/OpenThreads/Make/instrules OSG_OP_OT-1.0-rc7_/OpenThreads/Make/instrules
--- OSG_OP_OT-1.0-rc7/OpenThreads/Make/instrules 2005-11-11 10:48:58.000000000 +0000
+++ OSG_OP_OT-1.0-rc7_/OpenThreads/Make/instrules 2005-12-01 14:29:24.000000000 +0000
@@ -19,6 +19,8 @@
__inst_lib:
@[ -d $(INST_LIBS) ] || mkdir -p $(INST_LIBS)
@$(INSTXCMD) lib/$(OS)$(ARCH)/libOpenThreads.$(LIB_EXT) $(INST_LIBS)/libOpenThreads.$(LIB_EXT)
+ @[ -e lib/$(OS)$(ARCH)/libOpenThreads.$(STATICLIB_EXT) ] && \
+ $(INSTXCMD) lib/$(OS)$(ARCH)/libOpenThreads.$(STATICLIB_EXT) $(INST_LIBS)/libOpenThreads.$(STATICLIB_EXT)
__inst_headers:
@[ -d $(INST_INCLUDE)/OpenThreads ] || mkdir -p $(INST_INCLUDE)/OpenThreads
|
| File: dev-cpp/producer/producer-1.0_rc7.ebuild |
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils
DESCRIPTION="Open Producer is a cross-platform C++/OpenGL library that is focused on Camera control."
HOMEPAGE="http://www.openscenegraph.org"
SRC_URI="http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-1.0-rc7.zip"
SLOT="0"
LICENSE="LGPL-2.1"
KEYWORDS="x86"
IUSE="static"
# Producer will _not_ compile without OpenThreads!
DEPEND="openthreads"
S="${WORKDIR}/OSG_OP_OT-1.0-rc7/Producer"
src_unpack() {
unpack OSG_OP_OT-1.0-rc7.zip
use static && epatch ${FILESDIR}/${P}-static.patch
}
src_compile() {
use static && ( emake static || die "static make failed" )
emake || die "shared make failed"
}
src_install() {
einstall INST_LOCATION="${D}/usr" || die "einstall failed"
}
|
| File: dev-cpp/producer/files/producer-1.0_rc7-static.patch |
diff -Naur OSG_OP_OT-1.0-rc7_old/Producer/Make/instrules OSG_OP_OT-1.0-rc7/Producer/Make/instrules
--- OSG_OP_OT-1.0-rc7_old/Producer/Make/instrules 2005-12-01 14:29:24.000000000 +0000
+++ OSG_OP_OT-1.0-rc7/Producer/Make/instrules 2005-11-11 10:48:58.000000000 +0000
@@ -19,6 +19,8 @@
__inst_lib:
@[ -d $(INST_LIBS) ] || mkdir -p $(INST_LIBS)
@$(INSTXCMD) lib/$(OS)$(ARCH)/libProducer.$(LIB_EXT) $(INST_LIBS)/libProducer.$(LIB_EXT)
+ @[ -e lib/$(OS)$(ARCH)/libProducer.$(STATICLIB_EXT) ] && \
+ $(INSTXCMD) lib/$(OS)$(ARCH)/libProducer.$(STATICLIB_EXT) $(INST_LIBS)/libProducer.$(STATICLIB_EXT)
__inst_headers:
@[ -d $(INST_INCLUDE)/Producer ] || mkdir -p $(INST_INCLUDE)/Producer
|
| File: dev-cpp/osg/osg-1.0_rc7.ebuild |
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils
DESCRIPTION="OpenSceneGraph OpenGL portable, 3D high peformance graphics toolkit"
HOMEPAGE="http://www.openscenegraph.org"
SRC_URI="http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-1.0-rc7.zip
examples? ( http://www.openscenegraph.org/downloads/data/OpenSceneGraph-Data-1.0.zip )"
SLOT="0"
LICENSE="LGPL-2.1"
KEYWORDS="x86"
IUSE="examples static"
# OSG will _not_ compile without OpenThreads or Producer!
DEPEND="openthreads producer"
S="${WORKDIR}/OSG_OP_OT-1.0-rc7/OpenSceneGraph"
src_unpack() {
unpack OSG_OP_OT-1.0-rc7.zip
use static && epatch ${FILESDIR}/${P}-static.patch
use examples && unpack OpenSceneGraph-Data-1.0.zip
}
src_compile() {
local cc_eg=""
use examples && cc_eg="COMPILE_EXAMPLES=yes"
use static && ( emake static ${cc_eg} || die "emake failed" )
emake ${cc_eg} || die "emake failed"
}
src_install() {
einstall INST_LOCATION="${D}/usr" || die "einstall failed"
insinto /usr/share/OpenSceneGraph
doins -r ../../OpenSceneGraph-Data/*
# Set up environment. Add /usr/share/OpenSceneGraph/bin to PATH
# and make OSG_FILE_PATH=/usr/share/OpenSceneGraph so that
# OpenSceneGraph will find its example data files by default.
# Only do the latter if using examples! Thanks to contribution by
# anonymous user in Germany, delff.informatik.uni-kl.de!
dodir /etc/env.d
echo "PATH=/usr/share/OpenSceneGraph/bin" \
> ${D}/etc/env.d/99osg
use examples && echo "OSG_FILE_PATH=/usr/share/OpenSceneGraph" \
>> ${D}/etc/env.d/99osg
}
pkg_postinst() {
use static && einfo "Static libraries have been created, when using them make"
use static && einfo "sure to manually link against GL and X libraries."
einfo "Environment has been updated to let PATH find osgviewer and"
einfo "example binaries. Activate environment changes immediately"
einfo "using:"
einfo "env-update"
einfo "source /etc/profile"
einfo "Otherwise new environment settings start next time you login"
}
|
| File: dev-cpp/osg/files/osg-1.0_rc7-static.patch |
diff -Naur OSG_OP_OT-1.0-rc7_old/OpenSceneGraph/Make/makerules OSG_OP_OT-1.0-rc7/OpenSceneGraph/Make/makerules
--- OSG_OP_OT-1.0-rc7_old/OpenSceneGraph/Make/makerules 2005-03-13 01:47:45.000000000 +0000
+++ OSG_OP_OT-1.0-rc7/OpenSceneGraph/Make/makerules 2005-12-02 06:53:26.000000000 +0000
@@ -127,7 +127,7 @@
$(MAKE) -f ../GNUmakefile "DOF=$(DBGF)" TOPDIR=../${TOPDIR} \
THISDIR=../$(THISDIR)\
MAKEDEPEND=Makedepend $(STATICLIB)
- @$(MAKE) LNSRC=$(DEBUGDIR)/$(STATICLIB) LNDEST=$(LIBINST)/$(OS)$(ARCH)/$(STATICLIB) __link
+ @$(MAKE) LNSRC=$(DEBUGDIR)/$(STATICLIB) LNDEST=$(LIBINST)/$(STATICLIB) __link
$(WRAPPER:=.dbg) :
@[ -d $(DEBUGDIR) ] || mkdir $(DEBUGDIR)
@@ -176,7 +176,7 @@
$(MAKE) -f ../GNUmakefile DOF=$(OPTF) TOPDIR=../${TOPDIR} \
THISDIR=../$(THISDIR)\
MAKEDEPEND=Makedepend $(STATICLIB)
- @$(MAKE) LNSRC=$(OPTDIR)/$(STATICLIB) LNDEST=$(LIBINST)/$(OS)$(ARCH)/$(STATICLIB) __link
+ @$(MAKE) LNSRC=$(OPTDIR)/$(STATICLIB) LNDEST=$(LIBINST)/$(STATICLIB) __link
$(WRAPPER:=.opt) :
|
Version 0.9.9:
- openthreads-0.9.9.ebuild
- producer-0.9.9.ebuild
- osg-0.9.9.ebuild
Where to place the scripts? If your local Portage tree lives at /usr/local/portage as defined by PORTDIR_OVERLAY setting in /etc/make.conf then make a new subdirectory called dev-cpp with three new sub-subdirectories:
- openthreads for the OpenThreads ebuild script
- producer for the Producer ebuild script
- osg for the OSG ebuild script
Do not forget to digest the scripts using
ebuild `equery w openthreads` digest ebuild `equery w producer` digest ebuild `equery w osg` digest
See HOWTO Installing 3rd Party Ebuilds.
If you have not already downloaded the OSG zip files, the digest commands will download them automatically for you. There are two: one here http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-0.9.9.zip containing the sources, and the other here http://www.openscenegraph.org/downloads/data/OpenSceneGraph-Data-0.9.9.zip containing data for the OSG examples.
| File: openthreads-0.9.9.ebuild |
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
DESCRIPTION="OpenSceneGraph OpenGL portable, 3D high peformance graphics toolkit"
HOMEPAGE="http://www.openscenegraph.org"
SRC_URI="http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-0.9.9.zip"
SLOT="0"
LICENSE="LGPL-2.1"
KEYWORDS="x86"
IUSE=""
DEPEND=""
S="${WORKDIR}/OSG_OP_OT-${PV}/OpenThreads"
src_install() {
einstall INST_LOCATION="${D}/usr" || die "einstall failed"
}
|
| File: producer-0.9.9.ebuild |
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
DESCRIPTION="OpenSceneGraph OpenGL portable, 3D high peformance graphics toolkit"
HOMEPAGE="http://www.openscenegraph.org"
SRC_URI="http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-0.9.9.zip"
SLOT="0"
LICENSE="LGPL-2.1"
KEYWORDS="x86"
IUSE=""
# Producer will _not_ compile without OpenThreads!
DEPEND="openthreads"
S="${WORKDIR}/OSG_OP_OT-${PV}/Producer"
src_install() {
einstall INST_LOCATION="${D}/usr" || die "einstall failed"
}
|
| File: osg-0.9.9.ebuild |
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils
DESCRIPTION="OpenSceneGraph OpenGL portable, 3D high peformance graphics toolkit"
HOMEPAGE="http://www.openscenegraph.org"
SRC_URI="http://www.openscenegraph.org/downloads/snapshots/OSG_OP_OT-${PV}.zip
examples? ( http://www.openscenegraph.org/downloads/data/OpenSceneGraph-Data-${PV}.zip )"
SLOT="0"
LICENSE="LGPL-2.1"
KEYWORDS="x86"
IUSE="examples"
# OSG will _not_ compile without OpenThreads or Producer!
DEPEND="openthreads producer"
S="${WORKDIR}/OSG_OP_OT-${PV}/OpenSceneGraph"
src_compile() {
local cc_eg=""
use examples && cc_eg="COMPILE_EXAMPLES=yes"
emake ${cc_eg} || die "emake failed"
}
src_install() {
einstall INST_LOCATION="${D}/usr" || die "einstall failed"
insinto /usr/share/OpenSceneGraph
doins -r ../../OpenSceneGraph-Data/*
# Set up environment. Add /usr/share/OpenSceneGraph/bin to PATH
# and make OSG_FILE_PATH=/usr/share/OpenSceneGraph so that
# OpenSceneGraph will find its example data files by default.
# Only do the latter if using examples! Thanks to contribution by
# anonymous user in Germany, delff.informatik.uni-kl.de!
dodir /etc/env.d
echo "PATH=/usr/share/OpenSceneGraph/bin" \
> ${D}/etc/env.d/99osg
use examples && echo "OSG_FILE_PATH=/usr/share/OpenSceneGraph" \
>> ${D}/etc/env.d/99osg
}
pkg_postinst() {
einfo "Environment has been updated to let PATH find osgviewer and"
einfo "example binaries. Activate environment changes immediately"
einfo "using:"
einfo "env-update"
einfo "source /etc/profile"
einfo "Otherwise new environment settings start next time you login"
}
|
[edit] Feedback
Concerns or Compliments? Please use the Discussion section.
[edit] Resources
You can copy the ebuilds from this wiki page: view the source and copy all the text between <pre> and </pre> tags. The scripts appear between these tags verbatim.
Alternatively, you can download the scripts using external links given below.
- OpenSceneGraph-1.0 ebuilds tarball (put here in a hurry, pretty much like the 1.0-rc7) (openthreads 1.4.1 ebuild in this tarball is not working. Compare it with the rc version and fix the last part of the ebuild file, then generate digest and merge)
- OpenSceneGraph-1.0-rc7 ebuilds tarball
Right click on links and save as file.
You should check these ebuilds from Gentoo Bugzilla (probably soon integrated to the official tree):

