Building SVN versions with CMake

From Scribus Wiki
Revision as of 18:03, 21 September 2014 by Alevati (talk | contribs) (→‎Specific Dependencies: adding a complete (or so I hope) list of dependencies for 1.5.x)
Jump to navigation Jump to search
Broom.png
This article needs to be cleaned up. Please update the information, remove factual errors, refresh category data, or correct the hyperlinks.

This page tries to describe how to build Scribus from source. The instructions mainly refer to building Scribus on Linux. Building on Mac OS and on Windows is not easy; you can find some explanations for Mac OS here, and for Windows here.

TL;DR (Too Long; Didn't Read)

You know what you are doing already and just want to compile Scribus via SVN, skip the introduction and go to Installing 1.5svn

Why would I Need or Want to 'Build' Scribus?

  1. For Necessity: You are using the current stable version, but certain bugs are a problem, and you know they have been fixed since the last release.
  2. For Science: You have heard about some new features in the development version, and you'd like to try them out.
  3. For the World: You're considering helping out the Scribus project and want to see how it's put together to get some idea about how you can help.

'Or, for that matter, what is this 'Building' you speak of?

Expand this content if you need a little bit more background on what Building source code means. --->

Fear is the mind Killer...

"Do not fear building Scribus from source" ~Paul Muad'dib Atreides

There is nothing to fear here, building Scribus yourself is not as hard as it sounds. This page can teach a beginner many things at once: starting with beginning to comprehend the internals of Scribus to appreciating the Command Line shell and how to invoke commands through it. Learn how to install software libraries (components that Scribus utilizes) and go so far as to modify source code through applying patches. This exposure will help increase your skill set to work on most all platforms and widen your knowledge of software creation and maintenance.

1st: Download latest snapshot with Subversion

Subversion is the versioning control system used for Scribus. This allows multiple developers to hack on Scribus source code simultaneously. Check the Subversion page for further details on how to use this tool. Make sure you have svn installed.

# Add instruction here for directory creation where SVN will download to
# Direct the user to choose which SVN branch they are downloading by having them view the table below
# Execute said chosen SVN command to download the branch

Status Version SVN Path Command to download from SVN
Developmental v1.5.0 /trunk/Scribus svn co svn://scribus.net/trunk/Scribus scribus150
Stable v1.4.x /branches/Version14x/Scribus svn co svn://scribus.net/branches/Version14x/Scribus scribus14x
Outdated v.1.3.3x /branches/Version133x/Scribus svn co svn://scribus.net/branches/Version13x/Scribus scribus13x

Important Notes:

  • All subversion URLs for Scribus anonsvn are based at: svn://scribus.net/
  • Updating your working copy is much the same as cvs - just cd into your working copy and run "svn up".
  • There's also http://scribus.net/svn/Scribus/ , which gets you to the same content, but svn://scribus.net/ is usually faster. HTTP access might be useful to those behind paranoid firewalls or proxies.
  • If you used to check out -r <Version>, check out <SVN Path> instead



Thanks to Anduin.net, anonymous SVN access is updated daily.

2nd: Install methods: Package Manager, Source, Out-of-Source Build

Essential tools

Before going further, we must understand that in order for anything to get built, tools need to exist. In modern OS's especially Linux many of these are build tools arrive already bundled. If they aren't for some reason you will need to install them manually (see package manager)

  • gcc
  • gcc-c++
  • cmake (version ≥ 2.8.9)
  • subversion – if you're going to compile, you might as well get the latest Scribus updates

There are several option for installation.

Package Managers

Note: many Linux distros have their own Package Managers i.e. Debian has apt, Fedora and Centos have yum, Redhat uses rpm etc... On Mac OS X there are several choices, most popular are Macports and Homebrew. In general, by utilizing the installed package manager we can streamline the installations through easy one liners which will automate the install. We do this by invoking the following pattern:

(package-manager) install (software-or-library-package-name)

Debian;    apt-get install cmake
Fedora:    yum install cmake
MacOSXbrew install cmake

Specific Dependencies

Dependencies are considered to be 3rd party software libraries or other altogether unique software projects that are have components that are needed to build a specific project from. When we want to build Scribus we need to make sure that we have all the dependencies fulfilled or else it will complain to us about missing components or obsolete ones. The following section assumes you need to manually install dependencies. Here are the list of package names that will be needed to be installed before attempting to build Scribus. Each major version of Scribus will require different dependencies.

Version 1.5.x

Here is a list of dependencies for Scribus 1.5.x:

 Qt (version >= 5.0; see below for details)
 Cairo
 Pixman
 Boost
 Cups (not required on Windows)
 Fontconfig (not required on Windows)
 Freetype
 Libhunspell (if missing, spellchecker won't work)
 Libjpeg
 Libtiff
 Libxml2
 LittleCMS (version >= 2.1)
 Pkgconfig (Linux)
 PoDoFo
 Poppler and Poppler data
 Python 2.7
 Python-Pillow
 Tk and Tkinter (required by some scripts shipped with Scribus)

On Linux, for each item you have to install both the main package and the development package (for example: cairo and cairo-devel, pixman and pixman-devel, and so on).

Getting Qt5

Starting with rev. 18438 (2 September 2013), building version 1.5.0svn requires Qt5 (for previous revisions, it was optional). If Qt5 is not present on your system, you will have to install or build it. You can download Qt5 from http://qt-project.org/downloads. Installers are available for Windows, MacOS X and Linux. For Linux, if your distribution provides Qt5, you can install it from its repositories (details for some distributions are listed below).

Also available is the source code, in case you want to build Qt5 yourself, or if an installer is not available for your operating system.

The installer suggests as installation directory /home/username/Qt and we suggest you keep to that.

If you have Qt4 and Qt5 installed, and/or cmake does not find Qt5, you need to specify its location with the build option -DQT_PREFIX="path-to-Qt5" (for example: -DQT_PREFIX="/home/user/Qt/5.1.1/gcc/")

In case you need a list, the required qt5 libs are :

 Qt5Core
 Qt5Widgets
 Qt5Gui
 Qt5Xml
 Qt5WebKit
 Qt5WebKitWidgets
 Qt5Network
 Qt5OpenGL
 Qt5LinguistTools
 Qt5Quick
 Qt5PrintSupport

In case you got problems, Pygmee suggests too : "it build here after i've build sigil where it make a bit changes in QT5 config".

Debian

On Debian Testing, on top of the packages pulled in by apt-get build-dep you need. ---->

Fedora 19 and 20

Fedora 19 and 20 have Qt5 packages available from their repositories. The requirements seem to be ---->

Ubuntu

Ubuntu v13.04 ---->

Ubuntu v13.10 ---->

Ubuntu v14.04 ---->

OpenSuse

13.1 RC1 or newer ---->

Windows

Please refer to Building_SVN_versions_on_Windows

Mac OSX

Homebrew Package Manager ---->

MacPorts ---->

Additional dependencies for some graphics formats

In 1.5.0+, there are a number of vector and bitmap graphics formats which can now be imported into Scribus. Some of these have particular additional dependencies.

GraphicsMagick (Optional)

You do not need GraphicsMagick to run cmake or compile 1.5.0svn, but some added import filters will be available if you have it (and cmake will detect it automatically). What Scribus needs are the following packages: graphicsmagick, graphicsmagick-devel, graphicsmagick-c++, and graphicsmagick-c++-devel.

OpenSceneGraph (Optional)

This may be available with your Linux distribution (definitely for Fedora 17 and later). You can also download and compile yourself.

Fedora

OpenSUSE

MS Publisher and WPG Importers

To build Scribus with support for MS Publisher and WPG files, you need libmspub, as well as libwpg and libwpd. Note that the minimum version for PUB import is libmspub 0.0.6, and also that you want the development packages (libwpd-devel, libwpg-devel, libmspub-devel, for example in Fedora).

Update (June 2014): Scribus is now able to import MS Publisher, MS Visio and CorelDraw documents via librevenge. See this page for details.

v1.4.4

Warning Warning: Please update this section

Build from Source

Moved from top of the page..being integrated Kunda (talk) 15:07, 29 June 2014 (CEST)
If you are compiling for the first time, don't be scared of the command line. Just copy the lines relevant to the version of Scribus you want to use, one by one on the command line.

Watch out: * Newbies should take care, that only 'make install' part has to be done as a root. Rest of the part, like downloading and compiling can be done easily as a normal users.
You can install as a user, however, if you are installing into a directory you have write permission for. See the -DCMAKE_INSTALL_PREFIX command below. * And if you already have a version of Scribus on your system, don't forget to use the option WANT_VERSIONING=1. You can specify this option as -DWANT_VERSIONING=1.


Take as an example this following set of commands which are geared towards the Linux environment. Here we see a case in which there is a downloading of the Scribus development version (1.5, not yet stable), building it and then installing it. Note that this assumes that the environment has been prepared previously with all the dependencies installed.

Recently moved from top of page. Still fine tuning how to represent this.

Warning Warning: You must have CMake version ≥ 2.8.9 (Older versions will fail). See: Official:Compile with CMake
mkdir ~/src/
mkdir ~/src/scribus_svn
sudo mkdir /usr/local/scribus_svn
cd ~/src/scribus_svn
svn co svn://scribus.net/trunk/Scribus
cd ./Scribus
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/scribus_svn ..
make
sudo make install

Note:

  • you may change ~/src/ to wherever you want to put your source into.
  • you may change /usr/local/scribus_svn/ to wherever you want to put the Scribus binaries.
  • in case you want to install the 1.4 stable version, replace the "svn" instruction with following : svn co svn://scribus.net/branches/Version14x/Scribus

End of subsection

Start the Build Process

Before continuing, please note that an out-of-source build is recommended, however.. From the Scribus directory:

/path/to/cmake . -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install/to/scribuscmake/

For example:

/usr/local/bin/cmake . -DCMAKE_INSTALL_PREFIX:PATH=/opt/scribus15svn

Some options that the Scribus CMake files know about (more can be found here : http://wiki.scribus.net/canvas/CMake_Build_Options):

  • -DWANT_VERSIONING=1: Sets the build to use the VERSION setting as a suffix for the install directories and the binary. Eg, the binary could be scribus-1.3.5svn. This should mean that you can install multiple versions with the same prefix with no clashes.
  • -DWANT_DEBUG=1: Sets the build to be a debug release and use -O0 -g3, instead of -O2 (This is the default for now, and cannot be turned off unless you edit the CMakeFiles.txt file).
  • -DWANT_CAIRO=1: Makes CMake search for cairo and build with cairo instead of LibArt_LGPL. cairo is the primary supported option for 1.3.5+. (DEPRECATED)
  • -DWANT_LIBART=1 (not available in 1.3.5, default in 1.3.3.x): Makes CMake search for and build with LibArt_LGPL instead of cairo.
  • -DWANT_QTARTHUR=1: In 1.3.5, uses the QT4 ARTHUR rendering library. This is an alternative to CAIRO.
  • -DWANT_HUNSPELL=1: This will enable the new (as of 1.4.2) hunspell-based spell checking capabilities across *all* platforms.

If you have several version of QT installed or QT is installed in a non standard location you'll have to tell cmake where to find it by setting -DQT_QMAKE_EXECUTABLE

For example: to make a cairo debug build, then something like this:

/usr/local/bin/cmake . -DCMAKE_INSTALL_PREFIX:PATH=/opt/scribus134cvs -DWANT_CAIRO=1 -DWANT_DEBUG=1 -DWANT_VERSIONING=1

To use qt_arthur instead:

/usr/local/bin/cmake . -DCMAKE_INSTALL_PREFIX:PATH=/opt/scribus134cvs -DWANT_QTARTHUR=1 -DWANT_DEBUG=1 -DWANT_VERSIONING=1

Out-of-Source-Builds

One of the advantages of CMake is that you can do an out-of-source build. What is this? It enables you to build the application without writing anything at all to the directory where the Scribus source is. This means your source tree is clean, always. Its easier and faster to update, and you can build multiple targets out-of-source from the same source tree. Cool!

To do an out-of-source build, you need a new directory to build in. Say you have the source files in:

/home/username/scribuscmake/Scribus

Make the following directory:

/home/username/scribuscmake/builddir

So then, instead of doing:

eg /usr/local/bin/cmake . -DCMAKE_INSTALL_PREFIX:PATH=/opt/scribus15svn

you would then change to the builddir directory and run:

eg /usr/local/bin/cmake ../Scribus -DCMAKE_INSTALL_PREFIX:PATH=/opt/scribus15svn

Simple!

More CMake Options

CMake_Build_Options

Continuing on to the build stage

Once this has successfully completed, simply run make && make install.

The CMake based build system is very new to Scribus and it will change and it will need improving. Please report issues on our mailing list or bugtracker.

There is a long todo list for this build system including, but not limited to:

  • Checking it works across distributions
  • Checking it works across various flavours of UNIX
  • Checking it works on 64 bit distros
  • Add Win32 and Mac OSX support

Making a tarball for distribution

To make a tarball for distribution, the old way would be to make dist. The new way is to run make package_source or /path/to/cpack -G TBZ2 --config CPackSourceConfig.cmake to give you a bundle of the source. With cmake 2.4.1 there is only support for a gzip tar.gz however a bzip2 tar.bz2 is possible with later versions of cmake.

Notes For Packagers

If you package Scribus for a distribution keep in mind the issue of the install prefix versus temporary install directory prefix. The following seems to work well for Debian packaging:

>_______mkdir -p $(BUILD_DIR)

>_______cd $(BUILD_DIR) && $(CMAKE) \
>_______    -DWANT_DEBUG:STRING=$(DEBUG_FLAG) \
>_______    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
>_______    -DCMAKE_SKIP_RPATH:BOOL=1 \
>_______    -DRPATH_STYLE:STRING=none \
>_______    -DWANT_VERSIONING:BOOL=1 \
>_______    -DCUSTOM_VERSIONTAG:STRING=-ng \
>_______    -DCMAKE_CXX_FLAGS:STRING='-o2 -g -Wall' \
>_______    -DCMAKE_C_FLAGS:STRING='-o2 -g -Wall' ../../

then

>_______$(MAKE) -C $(BUILD_DIR) install DESTDIR=$(INSTALL_DIR)

where $(BUILD_DIR) is ./build and $(INSTALL_DIR) is ./install

Using $(PREFIX) is the key to avoiding hardcoded absolute path problem.

=

TODO

  • Enable more pkg-config usage
  • Prefixes for more packages