编译安装 Panda3D

2011-06-01 17:58

///////////////////////////////////////////////////////////////////////
// Caution: there are two separate, independent build systems:
// 'makepanda', and 'ppremake'.  Use one or the other, do not attempt
// to use both.  This file is part of the 'makepanda' system.
// 注意:这里有两个独立的建立系统:
// ‘makepanda’ 和 ‘ppremake’。使用一个或另一个,不要同时使用两个。这个文件是
// ‘makepanda’ 系统的一部分。
///////////////////////////////////////////////////////////////////////

Panda3D Install --- using the 'makepanda' system.
安装 Panda3D --- 使用 ‘makepanda’ 系统。

NOTE: As the makepanda build system changes more frequently
than this document, some of the information is outdated.
注意:由于 makepanda 建立系统的文档变化更频繁,这些资料可能已经过时。

MAKE SURE YOU HAVE ALL OF THE SOURCE CODE
请确保您下载了完整的源代码


The easiest way to download the source for panda is to download the
"source package" from the panda3d website.  If you downloaded a file
labeled "source package", then you have everything you need.  Skip to
the next section.
一个比较容易的方法是,从 panda3d 网站中的 “source package” 链接下载 panda 的源代码。
如果您已经下载了源代码,那么请跳到下一节。

Alternately, it is possible to download the source in pieces. There
are three pieces:
另外,您可以从三个位置下载源代码:

    1. Source code from Sourceforge.
      从 Sourceforge 下载源代码。
    2. Third-party tools (not strictly necessary for Unix)
      第三方工具(Unix 可以用自带的)
    3. Sample programs.
      示例程序。

You will need all three to use makepanda.  You can download all three
pieces from the panda website.  Look for the files labeled "Panda3D
source, piecewise, X of 3".  You can also obtain the first piece
directly from the sourceforge CVS server:
您需要三个 makepanda。您可以从 panda 的网站上下载这三个部分。从页面中找到
“Panda3D source, piecewise, X of 3”。您可以直接从 sourceforge 的 CVS 服务器
中获得:

    CVSROOT=:pserver:anonymous@panda3d.cvs.sourceforge.net:/cvsroot/panda3d

Make sure you have all three pieces.  If you do, then your panda
directory will contain the following subdirectories:
请确保您已经获得三个模块。如果有的话,您将看到以下子目录:

    direct    - piece 1, source code from sourceforge
    dmodels    - piece 1, source code from sourceforge
    doc         - piece 1, source code from sourceforge
    dtool    - piece 1, source code from sourceforge
    Makefile    - piece 1, source code from sourceforge
    makepanda    - piece 1, source code from sourceforge
    models    - piece 1, source code from sourceforge
    panda    - piece 1, source code from sourceforge
    pandatool    - piece 1, source code from sourceforge
    ppremake    - piece 1, source code from sourceforge
    contrib     - piece 1, source code from sourceforge
    thirdparty  - piece 2, third party tools
    samples    - piece 3, sample programs

If you have all of these, you're ready to go.  If not, then you
must have missed a piece.
如果您已经有这些目录了,证明已经准备好了。如果没有,说明您弄丢了一块。

Linux/FreeBSD users may omit the "thirdparty" tree, but this means
they will need to have the thirdparty software installed on the system.
Linux/FreeBSD 用户可以省略 “thirdparty” 目录,但是您必须保证您安装了第三方软件。

INVOKING MAKEPANDA
调用 MAKEPANDA


Makepanda is a script that builds panda, all the way through. To
invoke it under windows, change directory to the root of the panda
source tree and type this:
Makepanda 是一个建立 panda 的脚本,通过所有的方式。在 windows 下,进入 panda
源码的根目录,然后键入:

    makepanda\makepanda.bat

To invoke it under Linux or OSX, change directory to the root of
the panda source tree and type this:
在 Linux 或 OSX 下,进入 panda 源码的根目录,然后键入:

    makepanda/makepanda.py

From this point forward, I will not be including the directory name or
the extension in my examples.  I will simply assume that you know to
add the correct extension as demanded by your operating system.
从现在开始,我们不会再在例子中提到目录名称和扩展名。我们就只当您明白我们在说什么目录
和扩展名。

BUILDING PANDA: QUICK START
建立 PANDA:快速入门


The easy way to build panda is to type:
建立 panda 的最简单的方式是键入:

    makepanda --everything

This will compile panda with all the features.  It can take several
hours, depending on the speed of your machine.
这将对 panda 的所有部件进行编译。这可能需要数个小时,这取决于您机器的性能。

You may wish to add the --verbose option to the makepanda
command to get more verbose output information. This is
especially useful when you run into a compiler error.
您可以通过为 makepanda 命令添加 --verbose 选项来获得更详细的信息。
当在您的编译过程中出现问题时,这个选项特别有用。

The resulting copy of panda will be found in a subdirectory 'built'
inside the source tree.  (Given that you did not override this
with the --outputdir option)
编译好后的副本会被放在 ‘built’ 文件夹下。(如果您没有使用 --outputdir 选项来修改默认目录的话)

INSTALLING PANDA
安装 PANDA


If you are using Windows, OSX or a Linux distribution that supports DEB or
RPM packages, the recommended way to install Panda3D is to run makepanda
with the --installer option and then install the resulting .exe, .deb, .rpm
or .dmg package. This is a safe solution that makes sure all the files are
installed in the correct places and all the paths are configured correctly.
More information can be found below.
如果您使用的是 Windows、OSX 或是 支持 deb 和 rpm 包的 Linux,我们推荐使用 makepanda
的 --installer 选项生成 Panda3D 的安装包,然后在安装这些 .exe、.deb、.rpm 或是 .dmg
安装包。这是一个比较安全的方法,它保证将所有文件都安装在正确的地方。您可以在下面看到详细的信息。

Linux and FreeBSD users can install Panda3D manually, however, using the
following sequence of commands (execute as root):
Linux 用户和 FreeBSD 用户可以手动安装 Panda3D ,比如使用下面的命令(要以 root 用户运行):

  python makepanda/installpanda.py --prefix /usr/local
  ldconfig


MAKEPANDA COMMAND-LINE OPTIONS
MAKEPANDA 命令的选项


The default invocation of makepanda is a good way to test panda on
your machine.  However, it compiles several features that you probably
don't need.  To disable the extra features, you need to specify
command-line options to makepanda.  If you invoke:
直接使用 makepanda 会检测您机器上的 panda 。它也会同时编译一些东西,这个您可能
不需要。如果您要禁用这些功能,您需要为 makepanda 指定选项,如果您使用了:

    makepanda --help

it will show you the available command-line options:
它会告诉您所有可以使用的选项:

  --help            (print the help message you're reading now)
                (列出帮助信息)
  --verbose         (print out more information)
                (编译时列出更多详细信息)
  --installer       (build an installer)
                (建立安装程序)
  --optimize X      (optimization level can be 1,2,3,4)
                (优化级别,可以选择 1、2、3、4)
  --version         (set the panda version number)
                (设置 panda 的版本号)
  --lzma            (use lzma compression when building installer)
                (建立安装程序时使用 lzma 压缩)
  --threads N       (use the multithreaded build system. see manual)
                (使用多线程编译,详见说明)
  --osxtarget N     (the OSX version number to build for (OSX only))
                (设置 OSX 安装包的版本(仅限于OSX))
  --override "O=V"  (override dtool_config/prc option value)
                (覆盖原有的 dtool_config/prc 选项的值)

  --use-maya6       --no-maya6     (enable/disable use of MAYA6)
                            (启用/禁用 MAYA6)
  --use-maya65      --no-maya65    (enable/disable use of MAYA65)
                            (启用/禁用 MAYA65)
  --use-maya7       --no-maya7     (enable/disable use of MAYA7)
                            (启用/禁用 MAYA7)
  --use-maya8       --no-maya8     (enable/disable use of MAYA8)
                            (启用/禁用 MAYA8)
  --use-maya85      --no-maya85    (enable/disable use of MAYA85)
                            (启用/禁用 MAYA85)
  --use-maya2008    --no-maya2008  (enable/disable use of MAYA2008)
                            (后面的我不想写了。。。)
  --use-maya2009    --no-maya2009  (enable/disable use of MAYA2009)
  --use-maya2010    --no-maya2010  (enable/disable use of MAYA2010)
  --use-max6        --no-max6      (enable/disable use of MAX6)
  --use-max7        --no-max7      (enable/disable use of MAX7)
  --use-max8        --no-max8      (enable/disable use of MAX8)
  --use-max9        --no-max9      (enable/disable use of MAX9)
  --use-max2009     --no-max2009   (enable/disable use of MAX2009)
  --use-max2010     --no-max2010   (enable/disable use of MAX2010)
  --use-dx8         --no-dx8       (enable/disable use of DX8)
  --use-dx9         --no-dx9       (enable/disable use of DX9)
  --use-python      --no-python    (enable/disable use of PYTHON)
  --use-zlib        --no-zlib      (enable/disable use of ZLIB)
  --use-png         --no-png       (enable/disable use of PNG)
  --use-jpeg        --no-jpeg      (enable/disable use of JPEG)
  --use-tiff        --no-tiff      (enable/disable use of TIFF)
  --use-vrpn        --no-vrpn      (enable/disable use of VRPN)
  --use-tinyxml     --no-tinyxml   (enable/disable use of TINYXML)
  --use-fmodex      --no-fmodex    (enable/disable use of FMODEX)
  --use-openal      --no-openal    (enable/disable use of OPENAL)
  --use-nvidiacg    --no-nvidiacg  (enable/disable use of NVIDIACG)
  --use-openssl     --no-openssl   (enable/disable use of OPENSSL)
  --use-freetype    --no-freetype  (enable/disable use of FREETYPE)
  --use-wx          --no-wx        (enable/disable use of WX)
  --use-fftw        --no-fftw      (enable/disable use of FFTW)
  --use-artoolkit   --no-artoolkit (enable/disable use of ARTOOLKIT)
  --use-squish      --no-squish    (enable/disable use of SQUISH)
  --use-ode         --no-ode       (enable/disable use of ODE)
  --use-directcam   --no-directcam (enable/disable use of DIRECTCAM)
  --use-npapi       --no-npapi     (enable/disable use of NPAPI)
  --use-opencv      --no-opencv    (enable/disable use of OPENCV)
  --use-ffmpeg      --no-ffmpeg    (enable/disable use of FFMPEG)
  --use-swscale     --no-swscale   (enable/disable use of SWSCALE)
  --use-fcollada    --no-fcollada  (enable/disable use of FCOLLADA)
  --use-gtk2        --no-gtk2      (enable/disable use of GTK2)
  --use-pandatool   --no-pandatool (enable/disable use of PANDATOOL)

  --nothing         (disable every third-party lib)
                (禁用所有的第三方库)
  --everything      (enable every third-party lib)
                (启用所有的第三方库)

Makepanda shows you all the available options, not all of which may be
relevant to your operating system.  For example, makepanda can build a
plugin for 3D Studio Max.  However, there is no 3D Studio Max for
Linux, so the options --use-max# are irrelevant under Linux.
Makepanda 列出了所有您可以使用的选项,但并不是所有的选项都适合于您的操作系统。例如,
makepanda 可以为 Studio Max 建立插件。然而,3D Studio Max 没有 Linux 版本,
所以 --use-max# 选项在 Linux 下无效。

SELECTING PANDA FEATURES
选择 PANDA 的特征


Panda contains a large number of optional features.  For example, if
panda is compiled with PNG support, then panda will be able to load
textures from PNG image files.
Panda 包含了大量的可选功能。例如,如果 panda 支持 PNG 格式,panda 就可以载入
PNG 格式的纹理。

Some of these features require the use of bulky third-party libraries.
For example, 'helix' is a streaming video library from real networks.
If you do not plan on using streaming video in your 3D world, then
you may be interested in compiling panda without helix.  This will
shave several megabytes off of the panda libraries.
一些功能需要臃肿的第三方库来支持。例如,‘helix’ 是一个网络流媒体的视频库。(听说过rmvb吗?)
如果您不打算在您的三维世界中播放流媒体,您可以编译不带有 helix 的 panda 。这样安装包
的大小会减少好几M。

To select panda features, you need to specify one of two different
command-line options:
选择 panda 的功能,您需要使用一两个选项:

    makepanda --everything
    makepanda --nothing

You can follow either of these with a list of specific exceptions.
For example, you can say:
您可以设置一些例外的清单。就像这样:

    makepanda --everything --no-helix --no-openssl
    makepanda --nothing --use-zlib --use-png

If a certain package could not be found, it is automatically
omitted and a warning message is shown when running makepanda.
如果某个包无法被找到,它会自动省略掉这个包,并且发出一个警告信息。

Please note that if you abort makepanda, and invoke it again, it
will continue where it left off the last time you ran it. However,
if you change the combination of selected features, the compilation
process may start from scratch the next time you invoke makepanda.
请注意,如果您停止 makepanda ,并且再次运行,它会在您上次停止的地方继续运行。
然而,如果您改变了选项,程序会从头编译。

USING YOUR OWN LIBRARIES
使用自己的库


Panda3D uses a number of third-party libraries: libpng, libjpeg,
openssl, etc.  If you are using a Unix variant, many of these
libraries come with the operating system.  Panda3D will use these
OS-supplied libraries where possible, so if your OS comes with a copy
of libpng, Panda3D uses that.
Panda3D 使用了许多第三方库。比如 libpng、libjpeg、openssl 之类的。如果您
使用的是类 Unix 系统,您可以使用操作系统自带的。Panda3D 会尽可能地使用操作系统
自带的库。所以如果您的操作系统带有这些库,Panda3D 会直接使用它们。

For convenience, the panda source distribution includes precompiled
copies of many of the third-party libraries.  You will find these
libraries in a subdirectory labeled 'thirdparty'.  If you are happy
with the versions we have provided, then you don't need to do anything
special.
为了方便起见,panda 的源代码中包含了与编译的第三方库。您可以在 ‘thirdparty’ 目录
中找到这些库。如果您喜欢我们提供的版本,那么您可以使用默认的值。

If you are not satisfied with the versions of the libraries we have
provided, you may supply your own versions.  To do so, duplicate the
'thirdparty' tree, substitute your own libraries, and then use
the --thirdparty option to point makepanda to your libraries.
如果不满意我们提供的版本,您可以使用自己指定的版本。为此,您要向 thirdparty
目录中不知您自己的库,然后在 --thirdparty 参数中指定您的库。

THE EDIT-COMPILE-DEBUG CYCLE

A small caution: if you invoke 'makepanda' with one set of options,
and then invoke 'makepanda' using the exact same set of options, the
second time will be fast.  It will see that everything has already
been built, and it will do no actual compilation.  As a result,
makepanda can be used as part of an edit-compile-debug cycle.
注意事项:如果您调用 ‘makepanda’ 的选项和上一次调用 ‘makepanda’ 的选项完全相同,
第二次将会很快。因为有许多东西已经建好了,这时并没有真正编译。因此,makepanda 还可
以用作 edit-compile-debug cycle 。

However, if you invoke makepanda with a *different* set of options,
makepanda may need to recompile and relink a lot of files.  This is
because several of those options change the values of '#define'
headers, so changing the options requires a recompilation.
然而,如果您需要为 makepanda 指定*不同的*选项,makepanda 会编译、链接许多文件。
这是因为选项被修改了,头文件中的一些 ‘#define’ 的值也随着发生了变化,所以修改参数
后需要重新编译。

It is all too easy to accidentally invoke 'makepanda' with the wrong
options, thereby triggering an hour-long recompilation.  To avoid this
situation, we recommend that you write a short script containing the
options you intend to use regularly.  For example, I regularly compile
panda without helix.  I have a very short Windows BAT file called
"mkp.bat" that looks like this:
下面是所有容易引发 ‘makpanda’ 错误的选项,它也许会让您花一个小时重新编译。为了避免
这种情况,我们建议您写一个小脚本,通过脚本设置选项,特别是您要经常使用时。举个例子,
我们 regularly compile panda 去除 helix 。我们建立了一个非常短的 “mkp.bat”
Windows 批处理文件,文件如下:

    @echo off
    makepanda --everything --no-helix

This helps me avoid accidentally typing makepanda with the wrong
options.
这有助于我们键入选项是出错。

BUILDING A WINDOWS INSTALLER
建立 Windows 下的安装程序


Under Windows, makepanda can create an executable installer.  All you
need to do is pass the --installer option to makepanda.  The makepanda
option --lzma will cause the installer to be compressed with LZMA
compression, which is better, but it takes a long time to do the
compression.
在 Windows 下,makepanda 可以建立一个可执行的安装程序。您只需要在 makepanda
后加入 --installer 参数即可。为 makepanda 后加上参数 --lzma 会使用 LZMA 算法
来压缩安装包,LZMA 的压缩率是比较好的,但是它的压缩时间也比较长。

BUILDING A LINUX DEB OR RPM PACKAGE
建立 LINUX 下的 DEB 和 RPM 安装包


Under Linux, passing the --installer option to makepanda will
cause makepanda to try to build a deb or rpm package.  For this to
work, you have to be using a Linux distribution that includes either
the dpkg-deb or rpmbuild binary.
在 Linux 下,您可以使用 --installer 选项来尝试生成 deb 或 rpm 安装包。对于
这个操作,您必须在 Linux 系统下进行,系统要带有 dpkg-deb 或是 rpmbuild 程序。

BUILDING A MACOSX DMG PACKAGE
建立 MACOSX 安装包


Under Mac OSX, you can also use the --installer option, which will
generate a .dmg archive containing the Panda3D installation, which
needs to be placed in your /Applications/ directory.
The .dmg also contains a shell script that automatically sets up the
library and python search paths in your .bash_profile file so you don't
have to do that yourself every time you want to use Panda3D.
在 Mac OSX 下,您也可以通过 --install 参数来生成一个 .dmp 安装包,这个安装包需要
放在 /Applications/ 目录下。
.dmg 文件还包含了一个 shell 脚本,它可以在 .bash_profile 文件中自动设置库以及搜索
python 的目录,所以您不必每次使用 Pnada3D 时都这么做。