1PLplot Configuration, Build, and Installation
2=============================================
3
4The definitive set of instructions is given at
5<https://sourceforge.net/p/plplot/wiki/Building_PLplot>.  The material
6below is cut and pasted from
7<https://sourceforge.net/p/plplot/wiki/Building_PLplot/edit> in
8markdown format as of 2014-10-08.
9
10With the exception of DJGPP on (Free)DOS (where you should follow the directions at sys/dos/djgpp/readme) all PLplot builds are done with our CMake-based build system which gives good results on Unix, Linux, and Mac OS X and Cygwin, MinGW, MinGW/MSYS, and bare windows. After reading this section you should consult [specifics for various platforms](Specifics for various platforms "wikilink") for more details. Also, after a build and install is completed you should follow up by [testing PLplot](testing PLplot "wikilink").
11
12### Building PLplot with our CMake-based build system
13
14Our CMake-based build system has been made available as part of our development releases of PLplot starting with version 5.7.0 and is now with the exception of the DJGPP platform our sole build system. It is important to consult the CMake documentation to get the most out of our build system. That documentation is quite thorough but tends to be a bit scattered so we have collected what we think are the best [general CMake documentation links](general CMake documentation links "wikilink") for your convenience.
15
16After consulting that documentation, [install](http://www.cmake.org/HTML/Install.html) the appropriate package of [CMake](http://www.cmake.org) for your system platform. Note, you must use at least version 2.6.0 of CMake for your PLplot configuration, but our build system works with the latest version (2.6.2) of CMake as well.
17
18### <a name="Generic_Unix_instructions_for_our_build_system"></a>Generic Unix instructions for our build system
19
20#### (Optional) set environment variables to help cmake find system components that are installed in non-standard locations
21
22Here is one particular example (which must be executed before the cmake invocation discussed below).
23
24`export CMAKE_INCLUDE_PATH=/home/software/autotools/install/include:/home/software/cgmlib/cd1.3`
25`export CMAKE_LIBRARY_PATH=/home/software/autotools/install/lib:/home/software/cgmlib/cd1.3`
26`export PKG_CONFIG_PATH=/home/software/libLASi/install/lib/pkgconfig`
27
28For this particular example, <tt>CMAKE_INCLUDE_PATH</tt> helps cmake to find the headers for <tt>libltdl</tt> and <tt>libcd</tt> in non-standard install locations; <tt>CMAKE_LIBRARY_PATH</tt> helps cmake to find the <tt>libltdl</tt> and <tt>libcd</tt> libraries in non-standard install locations; and <tt>PKG_CONFIG_PATH</tt> helps cmake to use the <tt>pkg-config</tt> command internally to find a libLASi pkg-config module file that is installed in a non-standard location.
29
30In general, <tt>CMAKE_INCLUDE_PATH</tt> helps cmake find headers and other files that are installed in non-standard locations; <tt>CMAKE_LIBRARY_PATH</tt> helps cmake find libraries that are installed in non-standard locations; and <tt>PKG_CONFIG_PATH</tt> helps pkg-config (either externally or internally from cmake) find pkg-config modules installed in non-standard locations. Finally, although not used in the specific example above, the colon-separated environment variable <tt>PATH</tt> helps cmake find executables that are installed in non-standard locations.
31
32#### (Optional) set environment variables to specify the compilers and compiler flags
33
34Here is one particular example (which must be executed before the cmake invocation discussed below).
35
36`export CC="gcc -O2"`
37`export CXX="g++ -O2"`
38`export FC="g77 -O2"`
39
40If you don't set the environment variables above, then by default no compiler options (i.e., no optimization and no debugging symbols) are used for gcc-related compilers for our build system which makes for fast builds, but slow execution.
41
42#### cmake invocation
43
44Here is one typical example.
45
46`mkdir build_dir`
47`cd build_dir`
48`cmake -DCMAKE_INSTALL_PREFIX=/my/prefix \`
49`../plplot_cmake >& cmake.out`
50
51(CMake is capable of generating builds within the source tree, but we have emphasized a build with a separate build tree here because of its fundamental advantage that the source tree remains clean with no generated files in it.)
52
53Check the cmake.out file for any configuration issues, especially WARNING messages which signal that a component of PLplot has been removed because required system components for that component have not been found.
54
55There are a large number of [CMake options for PLplot](CMake options for PLplot "wikilink") which can be set for cmake to personalize your build. Use the ccmake front end to cmake to obtain documentation of all these options. In the above case we have specified a particular install prefix "/my/prefix".
56
57Note in the above example an initially empty build directory (arbitrarily) named build_dir is used to insure a clean start, and ../plplot_cmake is the (arbitrary) name of the top-level directory of a freshly checked out source tree from our svn repository. If instead you use a freshly unpacked PLplot source distribution tarball "../plplot_cmake" will need to be replaced by "../plplot-5.9.2" (for our latest release at time of writing).
58
59To start a fresh build, simply execute "cd build_dir; rm -rf \*" before invoking cmake. Of course, "rm -rf \*" is an extremely dangerous command (since it removes everything in the current directory and all subdirectories), but you should be okay so long as you cd to the correct directory before executing the "rm" command.
60
61#### Build and install
62
63`make >& make.out`
64`make install >& make_install.out`
65
66Check make.out and make_install.out for any errors. Follow up by [testing PLplot](testing PLplot "wikilink").
67
68
69
70
71
72
73