building.rst 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. .. _building-label:
  2. ===============================
  3. Appendix A: Building the Client
  4. ===============================
  5. This section explains how to build the ownCloud Client from source for all
  6. major platforms. You should read this section if you want to develop for the
  7. desktop client.
  8. .. note:: Build instructions are subject to change as development proceeds.
  9. Please check the version for which you want to build.
  10. The instructions contained in this topic were updated to work with version 1.7 of the ownCloud Client.
  11. Linux
  12. -----
  13. 1. Add the `ownCloud repository from OBS`_.
  14. 2. Install the dependencies (as root, or using ``sudo``) using the following
  15. commands for your specific Linux distribution:
  16. * Debian/Ubuntu: ``apt-get update; apt-get build-dep owncloud-client``
  17. * openSUSE: ``zypper ref; zypper si -d owncloud-client``
  18. * Fedora/CentOS: ``yum install yum-utils; yum-builddep owncloud-client``
  19. 3. Follow the :ref:`generic-build-instructions`.
  20. 4. (Optional) Call ``make install`` to install the client to the ``/usr/local/bin`` directory.
  21. Mac OS X
  22. --------
  23. In additon to needing XCode (along with the command line tools), developing in
  24. the Mac OS X environment requires extra dependencies. You can install these
  25. dependencies through MacPorts_ or Homebrew_. These dependencies are required
  26. only on the build machine, because non-standard libs are deployed in the app
  27. bundle.
  28. The tested and preferred way to develop in this environment is through the use
  29. of HomeBrew_. The ownCloud team has its own repository containing non-standard
  30. recipes.
  31. To set up your build environment for development using HomeBrew_:
  32. 1. Add the ownCloud repository using the following command::
  33. brew tap owncloud/owncloud
  34. 2. Install any missing dependencies::
  35. brew install $(brew deps owncloud-client)
  36. 3. Add Qt from brew to the path::
  37. export PATH=/usr/local/Cellar/qt5/5.x.y/bin/qmake
  38. Where ``x.z`` is the current version of Qt 5 that brew has installed
  39. on your machine.
  40. 5. For compilation of the client, follow the :ref:`generic-build-instructions`.
  41. 6. Install the Packages_ package creation tool.
  42. 7. In the build directory, run ``admin/osx/create_mac.sh <build_dir>
  43. <install_dir>``. If you have a developer signing certificate, you can specify
  44. its Common Name as a third parameter (use quotes) to have the package
  45. signed automatically.
  46. .. note:: Contrary to earlier versions, ownCloud 1.7 and later are packaged
  47. as a ``pkg`` installer. Do not call "make package" at any time when
  48. compiling for OS X, as this will build a disk image, and will not
  49. work correctly.
  50. Windows Development Build
  51. -----------------------
  52. If you want to test some changes and deploy them locally, you can build natively
  53. on Windows using MinGW. If you want to generate an installer for deployment, please
  54. follow `Windows Installer Build (Cross-Compile)`_ instead.
  55. 1. Get the required dependencies:
  56. * Make sure that you have CMake_ and Git_.
  57. * Download the Qt_ MinGW package. You will use the MinGW version bundled with it.
  58. * Download an `OpenSSL Windows Build`_ (the non-"Light" version)
  59. 2. Get the QtKeychain_ sources as well as the latest versions of the ownCloud client
  60. from Git as follows::
  61. git clone https://github.com/frankosterfeld/qtkeychain.git
  62. git clone git://github.com/owncloud/client.git
  63. 3. Open the Qt MinGW shortcut console from the Start Menu
  64. 4. Make sure that OpenSSL's ``bin`` directory as well as your qtkeychain source
  65. directories are in your PATH. This will allow CMake to find the library and
  66. headers, as well as allow the ownCloud client to find the DLLs at runtime::
  67. set PATH=C:\<OpenSSL Install Dir>\bin;%PATH%
  68. set PATH=C:\<qtkeychain Clone Dir>;%PATH%
  69. 5. Build qtkeychain **directly in the source directory** so that the DLL is built
  70. in the same directory as the headers to let CMake find them together through PATH::
  71. cd <qtkeychain Clone Dir>
  72. cmake -G "MinGW Makefiles" .
  73. mingw32-make
  74. cd ..
  75. 6. Create the build directory::
  76. mkdir client-build
  77. cd client-build
  78. 7. Build the client::
  79. cmake -G "MinGW Makefiles" ../client
  80. mingw32-make
  81. .. note:: You can try using ninja to build in parallel using
  82. ``cmake -G Ninja ../client`` and ``ninja`` instead.
  83. .. note:: Refer to the :ref:`generic-build-instructions` section for additional options.
  84. The ownCloud binary will appear in the ``bin`` directory.
  85. Windows Installer Build (Cross-Compile)
  86. ---------------------------------------
  87. Due to the large number of dependencies, building the client installer for Windows
  88. is **currently only officially supported on openSUSE**, by using the MinGW cross compiler.
  89. You can set up any currently supported version of openSUSE in a virtual machine if you do not
  90. have it installed already.
  91. In order to make setup simple, you can use the provided Dockerfile to build your own image.
  92. 1. Assuming you are in the root of the ownCloud Client's source tree, you can
  93. build an image from this Dockerfile like this::
  94. cd admin/win32/docker
  95. docker build . -t ownCloud-client-win32:<version>
  96. Replace ``<version>`` by the version of the client you are building, e.g.
  97. |version| for the release of the client that this document describes.
  98. If you do not wish to use docker, you can run the commands in ``RUN`` manually
  99. in a shell, e.g. to create your own build environment in a virtual machine.
  100. .. note:: Docker images are specific to releases. This one refers to |version|.
  101. Newer releases may have different dependencies, and thus require a later
  102. version of the docker image! Always pick the docker image fitting your release
  103. of ownCloud client!
  104. 2. From within the source tree Run the docker instance::
  105. docker run ownCloud-client-win32:<version> -v "$PWD:/home/jenkins/client" \
  106. admin/win32/docker/build.sh $(id -u)
  107. It will run the build, create an NSIS based installer, as well as run tests.
  108. You will find the resulting binary in an newly created ``build-win32`` subfolder.
  109. If you do not wish to use docker, and ran the ``RUN`` commands above in a virtual machine,
  110. you can run the indented commands in the lower section of ``build.sh`` manually in your
  111. source tree.
  112. 4. Finally, you should sign the installer to avoid warnings upon installation.
  113. This requires a `Microsoft Authenticode`_ Certificate ``osslsigncode`` to sign the installer::
  114. osslsigncode -pkcs12 $HOME/.codesign/packages.pfx -h sha1 \
  115. -pass yourpass \
  116. -n "ACME Client" \
  117. -i "http://acme.com" \
  118. -ts "http://timestamp.server/" \
  119. -in ${unsigned_file} \
  120. -out ${installer_file}
  121. for ``-in``, use the URL to the time stamping server provided by your CA along with the Authenticode certificate. Alternatively,
  122. you may use the official Microsoft ``signtool`` utility on Microsoft Windows.
  123. If you're familiar with docker, you can use the version of ``osslsigncode`` that is part of the docker image.
  124. .. _generic-build-instructions:
  125. Generic Build Instructions
  126. --------------------------
  127. Compared to previous versions, building the desktop sync client has become easier. Unlike
  128. earlier versions, CSync, which is the sync engine library of the client, is now
  129. part of the client source repository and not a separate module.
  130. You can download the desktop sync client from the ownCloud `Client Download Page`_.
  131. To build the most up to date version of the client:
  132. 1. Clone the latest versions of the client from Git_ as follows::
  133. git clone git://github.com/owncloud/client.git
  134. git submodule init
  135. git submodule update
  136. 2. Create the build directory::
  137. mkdir client-build
  138. cd client-build
  139. 3. Configure the client build::
  140. cmake -DCMAKE_BUILD_TYPE="Debug" ../client
  141. .. note:: You must use absolute paths for the ``include`` and ``library``
  142. directories.
  143. .. note:: On Mac OS X, you need to specify ``-DCMAKE_INSTALL_PREFIX=target``,
  144. where ``target`` is a private location, i.e. in parallel to your build
  145. dir by specifying ``../install``.
  146. 4. Call ``make``.
  147. The owncloud binary will appear in the ``bin`` directory.
  148. The following are known cmake parameters:
  149. * ``QTKEYCHAIN_LIBRARY=/path/to/qtkeychain.dylib -DQTKEYCHAIN_INCLUDE_DIR=/path/to/qtkeychain/``:
  150. Used for stored credentials. When compiling with Qt5, the library is called ``qt5keychain.dylib.``
  151. You need to compile QtKeychain with the same Qt version.
  152. * ``WITH_DOC=TRUE``: Creates doc and manpages through running ``make``; also adds install statements,
  153. providing the ability to install using ``make install``.
  154. * ``CMAKE_PREFIX_PATH=/path/to/Qt5.2.0/5.2.0/yourarch/lib/cmake/``: Builds using Qt5.
  155. * ``BUILD_WITH_QT4=ON``: Builds using Qt4 (even if Qt5 is found).
  156. * ``CMAKE_INSTALL_PREFIX=path``: Set an install prefix. This is mandatory on Mac OS
  157. .. _`ownCloud repository from OBS`: http://software.opensuse.org/download/package?project=isv:ownCloud:desktop&package=owncloud-client
  158. .. _CMake: http://www.cmake.org/download
  159. .. _CSync: http://www.csync.org
  160. .. _`Client Download Page`: http://owncloud.org/sync-clients/
  161. .. _Git: http://git-scm.com
  162. .. _MacPorts: http://www.macports.org
  163. .. _Homebrew: http://mxcl.github.com/homebrew/
  164. .. _`OpenSSL Windows Build`: http://slproweb.com/products/Win32OpenSSL.html
  165. .. _Qt: http://www.qt.io/download
  166. .. _`Microsoft Authenticode`: https://msdn.microsoft.com/en-us/library/ie/ms537361%28v=vs.85%29.aspx
  167. .. _QtKeychain: https://github.com/frankosterfeld/qtkeychain
  168. .. _Packages: http://s.sudre.free.fr/Software/Packages/about.html