Compile Open Source Project

This chapter will show you how to build an open source project for your DSM system using Package Toolkit. If you wish to compile the open source project manually, please refer to Appendix B: Compile Open Source Project Manually.

As mentioned in Create Package, you have to create SynoBuildConf/build, SynoBuildConf/install, and SynoBuildConf/depends before using Package Toolkit.

Unlike the previous example, compiling an application on most open source projects may require executing the following three steps:

  1. configure
  2. make
  3. make install

The configure script consists of many lines which are used to check some details about the machine where the software is going to be installed. This script will also check a lot of dependencies on your system. When you run the configure script, you will see a lot of output on the screen, each being some sort of question with a respective yes/no as a reply. If any of the major requirements are missing on your system, the configure script will exit and you will not be able to proceed with the installation until you meet the required conditions. In most cases, compile applications on some particular target machines will require you to modify the configure script manually to provide the correct values.

When running the configure script to configure software packages for cross-compiling, you will need to specify the CC, LD, RANLIB, CFLAGS, LDFLAGS, host, target, and build.

In this chapter, we will use platform x64 as our example.


First download the tmux source code from the official github site or you can download tmux from this link.

Note: The archive file you've downloaded from the above links is different from the official tmux source code. We have added the necessary build scripts.

Project Layout:

    ├── tmux related source code
    ├── scripts/
    └── SynoBuildConf/
        ├── build
        ├── depends
        └── install


The following is the depends file for this example. There is nothing special about the depends file.



The build script is slightly different from the previous one. Here you will have to pass the following environment variables to configure:

  • CC
  • AR

In addition, since tmux is dependent on ncurses, you will need to use pkg-config to resolve the necessary header files and libraries for tmux.

The following is an example of SynoBuildConf/build:

# Copyright (c) 2000-2015 Synology Inc. All rights reserved.

include /env.mak

case ${MakeClean} in
        make distclean

NCURSES_INCS="`pkg-config ncurses --cflags`"
NCURSES_LIBS="`pkg-config ncurses --libs`"


./configure ${ConfigOpt}

make ${MAKE_FLAGS}


Instead of copying the binary to the destination folder, most big projects will use make install to install the binaries and libraries. You can pass the DESTDIR environment variable to specify where you want to install the binaries and libraries.

# Copyright (c) 2000-2015 Synology Inc. All rights reserved.


PrepareDirs() {
    for dir in $INST_DIR $PKG_DIR; do
        rm -rf "$dir"
    for dir in $INST_DIR $PKG_DIR $PKG_DEST; do
        mkdir -p "$dir"

SetupPackageFiles() {
    DESTDIR="${INST_DIR}" make install

    ./ > INFO
    cp INFO "${PKG_DIR}"
    cp -r scripts/ "${PKG_DIR}"

MakePackage() {
    source /pkgscripts/include/
    pkg_make_package $INST_DIR $PKG_DIR
    pkg_make_spk $PKG_DIR $PKG_DEST

main() {

main "$@"

As mentioned before, we will use to generate the INFO file.

# Copyright (c) 2000-2015 Synology Inc. All rights reserved.

. /pkgscripts/include/
arch="$(pkg_get_platform) "
maintainer="Synology Inc."
description="This package will install tmux in your DSM system."
[ "$(caller)" != "0 NULL" ] && return 0

Note: Remember to set the executable bit of file.

Build and Create Package:

Run the following commands to compile the source code and build the package.

/toolkit/pkgscripts/ -p x64 -c tmux

After the build process, you can check the result in /toolkit/result_spk.

Verify the Result

If the building process was successful, you will see that the .spk file has been placed under result_spk folder. To test the spk file, You can use manual install in Package Center to install your package.

Warning: Remember to import your keys to the DSM system or select Any publisher in Package Center->Settings->General->Trust Level. Otherwise, the installation will fail.

You can then try to connect to the DSM using ssh and type the following command to fully scan your DSM machine.

cd /var/packages/"${PKG_NAME}"/target/usr/local/bin