| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 1 | Cross-compiling LibreOffice |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 2 | *************************** |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 3 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 4 | Cross-compilation works, to various degree, to the following |
| Tor Lillqvist | 7aa6f1b | 2013-04-03 21:04:16 +0300 | [diff] [blame] | 5 | platforms: Windows, iOS, Android, and Raspbian. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 6 | |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 7 | |
| 8 | General |
| 9 | ------- |
| 10 | |
| 11 | In GNU Autoconf terminology, "build" is the platform on which you are |
| Tor Lillqvist | bc229ca | 2012-05-17 22:57:46 +0300 | [diff] [blame] | 12 | running a build of some software and "host" is the platform on which |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 13 | the software you are building will run. Only in the specific case of |
| 14 | building compilers and other programming tools is the term "target" |
| 15 | used to indicate the platform for which the tools your are building |
| 16 | will produce code. As LibreOffice is not a compiler, the "target" term |
| 17 | should not be used in the context of cross-compilation. |
| 18 | |
| 19 | (For a case where all three of "build", "host" and "target" are |
| 20 | different: consider a gcc cross-compiler running on Windows, producing |
| 21 | code for Android, where the cross-compiler itself was built on |
| 22 | Linux. (This is a real case.) An interesting tidbit is that such |
| 23 | configurations are called "Canadian Cross".) |
| 24 | |
| 25 | Even though the LibreOffice build mechanism is highly unorthodox, the |
| 26 | configure script takes the normal --build and --host options like any |
| 27 | GNU Autoconf -based configure script. To cross-compile, you basically |
| 28 | need just to specify a suitable --host option and things should work |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 29 | out nicely. In practice, many details need to be handled. See examples |
| 30 | below. |
| 31 | |
| 32 | Note that in the case of LibreOffice, it is uncommon to run the |
| 33 | configure script directly. Normally one uses the autogen.sh script. |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 34 | The autogen.sh script reads command-line options from file called |
| Chris Sherlock | 91b27bc | 2013-05-16 00:49:50 +1000 | [diff] [blame] | 35 | autogen.input if it exists. The typical way of working is to keep |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 36 | the configure parameters in that file and edit it as needed. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 37 | |
| 38 | |
| 39 | What is so hard, then? |
| 40 | ---------------------- |
| 41 | |
| 42 | Despite the fact that the configure script takes normal --build and |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 43 | --host options, that is just the beginning. It was necessary to |
| 44 | separate tests for "host" and "build" platforms in the configure |
| 45 | script. See the git log for details. And the reasonably "standard" |
| 46 | configure.in is just the top level; when we get down to the actual |
| 47 | makefilery used to build the bits of LibreOffice, it gets much worse. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 48 | |
| 49 | |
| 50 | Windows |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 51 | ******* |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 52 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 53 | There was some support in LibreOffice already from OpenOffice.org days |
| 54 | for building it locally on Windows with the GNU tool-chain (MinGW). |
| 55 | Apparently, those doing that work never attempted cross-compilation. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 56 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 57 | This OOo-originated MinGW support attempts to be for both running the |
| 58 | Cygwin gcc in its -mno-cygwin mode, and a Windows-native MinGW |
| 59 | compiler. The -mno-cygwin mechanism in the Cygwin gcc is rapidly being |
| 60 | obsoleted, if it isn't already, and we have not attempted to try to |
| Chris Sherlock | 91b27bc | 2013-05-16 00:49:50 +1000 | [diff] [blame] | 61 | keep it working; in fact we have actively cleaned out mechanisms |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 62 | related to this. Ditto for native MinGW. If one compiles natively on |
| 63 | Windows, just use a version of Microsoft's compiler. OpenOffice.org |
| 64 | and LibreOffice have been built for Windows all the time using that. |
| Tor Lillqvist | 297a2df | 2011-06-18 11:31:50 +0300 | [diff] [blame] | 65 | |
| Chris Sherlock | 91b27bc | 2013-05-16 00:49:50 +1000 | [diff] [blame] | 66 | The only case where it makes sense to use MinGW is for |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 67 | cross-compilation. There is just too much crack involved on Windows |
| 68 | anyway, and it is a semi-miracle that the MSVC build under Cygwin |
| 69 | works as nicely as it does. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 70 | |
| 71 | MinGW is available as cross-build toolchains pre-packaged in more or |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 72 | less official packages for many Linux distros including Debian, Fedora |
| Chris Sherlock | 91b27bc | 2013-05-16 00:49:50 +1000 | [diff] [blame] | 73 | and openSUSE. For instance, the mingw32 packages in the Open Build |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 74 | Service, running on openSUSE, can be found at: |
| Jan Holesovsky | 81ca6d8 | 2011-08-19 15:01:17 +0200 | [diff] [blame] | 75 | |
| 76 | http://download.opensuse.org/repositories/windows:/mingw:/win32/ |
| 77 | |
| Fridrich Štrba | 06fa2d5 | 2011-10-20 13:27:08 +0200 | [diff] [blame] | 78 | For example, you can install it like this: |
| Jan Holesovsky | 81ca6d8 | 2011-08-19 15:01:17 +0200 | [diff] [blame] | 79 | |
| Fridrich Štrba | 06fa2d5 | 2011-10-20 13:27:08 +0200 | [diff] [blame] | 80 | zypper ar http://download.opensuse.org/repositories/windows:/mingw:/win32/<your_os>/windows:mingw:win32.repo |
| 81 | |
| Miklos Vajna | 42960dc | 2013-04-19 18:26:03 +0200 | [diff] [blame] | 82 | where <your_os> is one of SLE_11, SLE_11_SP1, openSUSE_XX.Y, or |
| Fridrich Štrba | 06fa2d5 | 2011-10-20 13:27:08 +0200 | [diff] [blame] | 83 | openSUSE_Factory. |
| 84 | |
| Jan Holesovsky | 91a8ef2 | 2011-08-24 10:26:11 +0200 | [diff] [blame] | 85 | zypper in mingw32-cross-gcc mingw32-cross-gcc-c++ mingw32-python-devel \ |
| Jan Holesovsky | 4533b4b | 2012-11-25 11:07:44 +0100 | [diff] [blame] | 86 | mingw32-python mingw32-libboost_date_time \ |
| Jan Holesovsky | 91a8ef2 | 2011-08-24 10:26:11 +0200 | [diff] [blame] | 87 | mingw32-libexpat-devel mingw32-libexpat mingw32-boost-devel \ |
| 88 | mingw32-libhyphen-devel mingw32-libhyphen mingw32-hyphen-en \ |
| 89 | mingw32-liblpsolve mingw32-liblpsolve-devel \ |
| Jan Holesovsky | c0111fd | 2011-08-24 01:09:03 +0200 | [diff] [blame] | 90 | mingw32-libxml2-devel mingw32-libxslt-devel mingw32-libicu \ |
| 91 | mingw32-libicu-devel mingw32-libgraphite2 mingw32-libgraphite2-devel \ |
| Fridrich Štrba | 06fa2d5 | 2011-10-20 13:27:08 +0200 | [diff] [blame] | 92 | mingw32-libcairo2 mingw32-cairo-devel mingw32-librsvg mingw32-librsvg-devel \ |
| Jan Holesovsky | c0111fd | 2011-08-24 01:09:03 +0200 | [diff] [blame] | 93 | mingw32-hunspell mingw32-hunspell-devel mingw32-libcurl \ |
| Jan Holesovsky | 2f33c16 | 2011-08-24 01:18:36 +0200 | [diff] [blame] | 94 | mingw32-libcurl-devel mingw32-libneon mingw32-libneon-devel \ |
| Fridrich Štrba | 06fa2d5 | 2011-10-20 13:27:08 +0200 | [diff] [blame] | 95 | mingw32-libopenssl mingw32-libopenssl-devel mingw32-libexttextcat \ |
| 96 | mingw32-libexttextcat-devel mingw32-libdb mingw32-libdb-devel \ |
| Jan Holesovsky | 91a8ef2 | 2011-08-24 10:26:11 +0200 | [diff] [blame] | 97 | mingw32-cross-pkg-config mingw32-pkg-config mingw32-libcppunit \ |
| 98 | mingw32-libcppunit-devel mingw32-libredland mingw32-libredland-devel \ |
| Jan Holesovsky | 4533b4b | 2012-11-25 11:07:44 +0100 | [diff] [blame] | 99 | mingw32-libmythes mingw32-libmythes-devel mingw32-mozilla-nss \ |
| Jan Holesovsky | 7861bf0 | 2012-11-25 12:46:10 +0100 | [diff] [blame] | 100 | mingw32-mozilla-nss-devel mingw32-mozilla-nspr \ |
| 101 | mingw32-mozilla-nspr-devel mingw32-libpoppler mingw32-libpoppler-devel |
| Jan Holesovsky | 81ca6d8 | 2011-08-19 15:01:17 +0200 | [diff] [blame] | 102 | |
| Jan Holesovsky | 063afe5 | 2012-07-23 18:16:46 +0200 | [diff] [blame] | 103 | You also need wine, ideally: |
| 104 | |
| 105 | zypper ar http://download.opensuse.org/repositories/Emulators:/Wine/<your_os>/Emulators:Wine.repo |
| 106 | |
| 107 | zypper in wine wine-devel wine-devel-32bit |
| 108 | |
| 109 | And in order to be able to use 'winegcc -m32', also |
| 110 | |
| 111 | zypper in glibc-devel-32bit gcc-32bit |
| 112 | |
| Jan Holesovsky | 81ca6d8 | 2011-08-19 15:01:17 +0200 | [diff] [blame] | 113 | There might be more that are missing, please read carefully what autogen.sh |
| 114 | tells you, and either remove one of the --with-system-*, or install the |
| Jan Holesovsky | c0111fd | 2011-08-24 01:09:03 +0200 | [diff] [blame] | 115 | missing dependency. |
| 116 | |
| 117 | It also looks like graphite2.pc needs tweaking in order to work right; but |
| Tor Lillqvist | 7974c4f | 2011-08-28 11:14:47 +0300 | [diff] [blame] | 118 | that's likely to be fixed in the openSUSE project. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 119 | |
| 120 | It is somewhat unclear how well thought-out the conditionals and code |
| Tor Lillqvist | 297a2df | 2011-06-18 11:31:50 +0300 | [diff] [blame] | 121 | for MinGW inside the OOo-originated code in LibreOffice actually |
| Tor Lillqvist | c4feba9 | 2012-01-22 10:18:47 +0200 | [diff] [blame] | 122 | are. It often seems a bit randomish, with copy-pasting having been |
| 123 | preferred to factoring out differences. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 124 | |
| Tor Lillqvist | ee4fc40 | 2012-01-17 19:06:26 +0200 | [diff] [blame] | 125 | Most of the configuration settings are maintained in the |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 126 | distro-configs/LibreOfficeMinGW.conf file, so in your autogen.input, |
| Tor Lillqvist | ee4fc40 | 2012-01-17 19:06:26 +0200 | [diff] [blame] | 127 | you can use: |
| Jan Holesovsky | 9d65c893 | 2011-11-03 21:06:33 +0100 | [diff] [blame] | 128 | |
| 129 | CC=ccache i686-w64-mingw32-gcc |
| 130 | CXX=ccache i686-w64-mingw32-g++ |
| 131 | CC_FOR_BUILD=ccache gcc |
| 132 | CXX_FOR_BUILD=ccache g++ |
| 133 | --with-distro=LibreOfficeMinGW |
| 134 | |
| Tor Lillqvist | ee4fc40 | 2012-01-17 19:06:26 +0200 | [diff] [blame] | 135 | Alternatively, you can use something like the following; but the |
| 136 | preferred way is to keep the LibreOfficeMinGW.conf file up-to-date. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 137 | |
| 138 | CC=ccache i686-w64-mingw32-gcc |
| 139 | CXX=ccache i686-w64-mingw32-g++ |
| 140 | CC_FOR_BUILD=ccache gcc |
| 141 | CXX_FOR_BUILD=ccache g++ |
| 142 | --build=x86_64-unknown-linux-gnu |
| 143 | --host=i686-w64-mingw32 |
| 144 | --with-distro=LibreOfficeWin32 |
| Tor Lillqvist | 5166d6e | 2011-08-31 10:37:33 +0300 | [diff] [blame] | 145 | --disable-activex |
| Tor Lillqvist | d0ab680 | 2011-07-21 09:49:26 +0300 | [diff] [blame] | 146 | --disable-directx |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 147 | --disable-ext-nlpsolver |
| David Ostrovsky | 2aa5d13 | 2013-10-05 23:07:24 +0200 | [diff] [blame] | 148 | --disable-report-builder |
| 149 | --disable-scripting-beanshell |
| 150 | --disable-scripting-javascript |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 151 | --disable-ext-wiki-publisher |
| Stephan Bergmann | 7bf64a5 | 2012-11-24 22:58:01 +0100 | [diff] [blame] | 152 | --disable-pdfimport |
| Tor Lillqvist | c565e5d | 2011-06-13 15:46:26 +0300 | [diff] [blame] | 153 | --enable-python=system |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 154 | --with-system-altlinuxhyph |
| 155 | --with-system-boost |
| Tor Lillqvist | 297a2df | 2011-06-18 11:31:50 +0300 | [diff] [blame] | 156 | --with-system-cairo |
| Tor Lillqvist | d0ab680 | 2011-07-21 09:49:26 +0300 | [diff] [blame] | 157 | --with-system-cppunit |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 158 | --with-system-curl |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 159 | --with-system-expat |
| 160 | --with-system-hunspell |
| 161 | --with-system-icu |
| Tor Lillqvist | 297a2df | 2011-06-18 11:31:50 +0300 | [diff] [blame] | 162 | --with-system-libpng |
| Tor Lillqvist | c565e5d | 2011-06-13 15:46:26 +0300 | [diff] [blame] | 163 | --with-system-libwpd |
| 164 | --with-system-libwpg |
| 165 | --with-system-libwps |
| 166 | --with-system-libxml |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 167 | --with-system-lpsolve |
| Tor Lillqvist | c565e5d | 2011-06-13 15:46:26 +0300 | [diff] [blame] | 168 | --with-system-mythes |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 169 | --with-system-neon |
| 170 | --with-system-openssl |
| 171 | --with-system-redland |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 172 | --with-vendor=no |
| Tor Lillqvist | 5166d6e | 2011-08-31 10:37:33 +0300 | [diff] [blame] | 173 | --without-help |
| 174 | --without-helppack-integration |
| 175 | --without-myspell-dicts |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 176 | |
| Tor Lillqvist | bc229ca | 2012-05-17 22:57:46 +0300 | [diff] [blame] | 177 | Once you have compiled it, you may want to try to run it, for instance |
| 178 | using Wine: |
| Jan Holesovsky | 07a7e3a | 2011-09-27 12:02:01 +0200 | [diff] [blame] | 179 | |
| Jan Holesovsky | 004820b | 2011-09-29 15:25:54 +0200 | [diff] [blame] | 180 | $ cd /tmp |
| Jan Holesovsky | ef88d77 | 2013-03-01 11:55:15 +0100 | [diff] [blame] | 181 | $ tar xf <your-build-dir>/workdir/wntgcci.pro/installation/LibreOffice_Dev/archive/install/en-US/LibO-Dev_4.1.0.0.alpha0_Win_x86_archive.tar.gz |
| 182 | $ cd LibO-Dev_4.1.0.0.alpha0_Win_x86_archive/LOdev\ 4.1/program/ |
| Jan Holesovsky | 07a7e3a | 2011-09-27 12:02:01 +0200 | [diff] [blame] | 183 | $ wine soffice.exe |
| 184 | |
| Jan Holesovsky | 004820b | 2011-09-29 15:25:54 +0200 | [diff] [blame] | 185 | NB. it is important to unpack somewhere low in the hierarchy structure (like |
| 186 | in /tmp as advised above), otherwise you'll get BerkeleyDB errors on startup. |
| 187 | |
| Jan Holesovsky | 07a7e3a | 2011-09-27 12:02:01 +0200 | [diff] [blame] | 188 | And if you are brave enough, you can even debug it. First you have to add the |
| 189 | URE dll's to the wine's PATH using 'wine regedit' - see |
| 190 | http://www.winehq.org/docs/wineusr-guide/environment-variables, and add |
| Jan Holesovsky | 256c4de | 2013-03-01 11:57:04 +0100 | [diff] [blame] | 191 | Z:\tmp\LibO-Dev_4.1.0.0.alpha0_Win_x86_archive/LOdev\ 4.1\URE\bin |
| Jan Holesovsky | 004820b | 2011-09-29 15:25:54 +0200 | [diff] [blame] | 192 | to "Path" in My Computer->HKEY_CURRENT_USER->Environment. |
| Jan Holesovsky | 07a7e3a | 2011-09-27 12:02:01 +0200 | [diff] [blame] | 193 | |
| Jan Holesovsky | 07a7e3a | 2011-09-27 12:02:01 +0200 | [diff] [blame] | 194 | And start debugging: |
| 195 | |
| 196 | $ winedbg soffice.bin |
| 197 | |
| 198 | Would be great to be able to use winedbg --gdb, but it was crashing here :-( - |
| 199 | but maybe you'll be more lucky. |
| 200 | |
| Jan Holesovsky | e0c17f4 | 2012-03-19 15:27:25 +0100 | [diff] [blame] | 201 | Tricks of some use with winedbg: |
| 202 | -------------------------------- |
| 203 | |
| 204 | To examine OUStrings, you might want to use the following trick (prints 50 |
| 205 | unicode characters of rLibName OUString - the +10 is where the buffer starts): |
| 206 | |
| 207 | Wine-dbg>x /50u rLibName->pData+10 |
| 208 | 0x0909b6c8: vnd.sun.star.expand:$LO_LIB_DIR/abplo.dll |
| 209 | |
| Jan Holesovsky | 41e2ab3 | 2011-08-25 13:11:26 +0200 | [diff] [blame] | 210 | TODO: |
| 211 | |
| Jan Holesovsky | 538b449 | 2012-06-19 09:22:29 +0200 | [diff] [blame] | 212 | - make the debugging more convenient on (native) Windows |
| 213 | - check possibilities like WinGDB - http://www.wingdb.com/ |
| 214 | - or find / write a MSVS / WinDBG extension that can read MinGW debugging |
| 215 | symbols natively; more info |
| 216 | http://windbg.info/forum/12-symbol-and-source-files-/21-debugging-mingwgcc-built-dll-in-visual-studio.html |
| 217 | |
| Jan Holesovsky | 41e2ab3 | 2011-08-25 13:11:26 +0200 | [diff] [blame] | 218 | - installation |
| 219 | - so far the make_installer.pl calls makecab.exe, uuidgen.exe, and |
| 220 | others; would be best to avoid that if at all possible (using a free |
| 221 | cab implementation, part of Wine or something) |
| 222 | - MSI generation |
| Jan Holesovsky | 41e2ab3 | 2011-08-25 13:11:26 +0200 | [diff] [blame] | 223 | |
| 224 | - runtime |
| 225 | - no idea if the entire thing works after the installation at all; I |
| 226 | suppose there will be runtime problems to look at too |
| 227 | |
| 228 | - cleanup |
| 229 | - enable & fix pieces that are currently disabled |
| 230 | - --without-myspell-dicts |
| 231 | - --disable-directx |
| 232 | - --disable-activex |
| Jan Holesovsky | 41e2ab3 | 2011-08-25 13:11:26 +0200 | [diff] [blame] | 233 | - much of the stuff currently relies on --with-system-*, and |
| 234 | consequently on the mingw32-* openSUSE packages; might be good to be |
| 235 | able to build with as few dependencies as possible - but that is low |
| Tor Lillqvist | c4feba9 | 2012-01-22 10:18:47 +0200 | [diff] [blame] | 236 | prio |
| Jan Holesovsky | 41e2ab3 | 2011-08-25 13:11:26 +0200 | [diff] [blame] | 237 | |
| 238 | - profiling |
| 239 | - when all the above is sorted out, we should look at the speed of |
| 240 | this vs. the speed of the MSVC version |
| 241 | |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 242 | |
| 243 | iOS |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 244 | *** |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 245 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 246 | iOS is the operating system on Apple's mobile devices. Clearly for a |
| 247 | device like the iPad it would not be acceptable to run a normal |
| 248 | LibreOffice application with overlapping windows and mouse-oriented |
| 249 | GUI widgets. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 250 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 251 | It makes sense to use only a part of LibreOffice's code for iOS. Lots |
| 252 | of the GUI-oriented code should be left out. iOS apps that want to use |
| 253 | the applicable LibreOffice code will handle all their GUI in a |
| 254 | platform-dependent manner. How well it will be possible to do such a |
| 255 | split remains to be seen. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 256 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 257 | Obviously we want it to be possible to eventually distribute apps |
| 258 | using LibreOffice code through the App Store. Technically, one |
| 259 | important special aspect of iOS is that apps in the App Store are not |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 260 | allowed to load own dynamic libraries. (System libraries are used in |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 261 | the form of dynamic libraries, just like on Mac OS X, of which iOS is |
| 262 | a variant.) |
| 263 | |
| 264 | Thus all the libraries in LibreOffice that normally are shared |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 265 | libraries (DLLs on Windows, shared objects (.so) on Linux, dynamic |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 266 | libraries on Mac OS X (.dylib)) must be built as static archives |
| 267 | instead. This has some interesting consequences for how UNO is |
| 268 | implemented and used. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 269 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 270 | An iOS app is a "bundle" that contains a single executable, In an app |
| 271 | using LibreOffice code, that eecutable then congtains the necessary |
| 272 | LibreOffice libraries and UNO components statically linked. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 273 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 274 | The Apple tool-chain for iOS cross-building is available only for OS |
| 275 | X. In order to be able to run and debug an app on an actual device |
| 276 | (and not just the iOS Simulator) you need to be registered in the iOS |
| 277 | Developer Program. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 278 | |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 279 | Here is an autogen.input for iOS (device) using Xcode 4.6, on OS X 10.8: |
| Tor Lillqvist | bc229ca | 2012-05-17 22:57:46 +0300 | [diff] [blame] | 280 | |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 281 | --build=i386-apple-darwin10.7.0 |
| 282 | --host=arm-apple-darwin10 |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 283 | --enable-dbgutil |
| 284 | --enable-debug |
| Tor Lillqvist | 21aec7e | 2012-02-22 20:41:58 +0200 | [diff] [blame] | 285 | --enable-werror |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 286 | |
| Tor Lillqvist | f285ac7 | 2014-07-09 12:21:53 +0300 | [diff] [blame] | 287 | For the iOS Simulator, but note that building for the simulator is |
| 288 | broken at the moment (July 2014): |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 289 | |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 290 | --build=i386-apple-darwin10.7.0 |
| 291 | --host=arm-apple-darwin10 |
| 292 | --enable-ios-simulator |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 293 | --enable-dbgutil |
| 294 | --enable-debug |
| 295 | --enable-werror |
| Tor Lillqvist | 21aec7e | 2012-02-22 20:41:58 +0200 | [diff] [blame] | 296 | |
| Tor Lillqvist | f285ac7 | 2014-07-09 12:21:53 +0300 | [diff] [blame] | 297 | You will have to install autoconf and automake yourself before running |
| 298 | autogen.sh. They are no longer included in Xcode 4.3 and later (not |
| 299 | even in the add-on "command line tools"). |
| Tor Lillqvist | 21aec7e | 2012-02-22 20:41:58 +0200 | [diff] [blame] | 300 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 301 | The -mmacosx-version-min=10.7 is necessary when building for the iOS |
| Tor Lillqvist | ab4014e | 2012-06-04 11:19:36 +0300 | [diff] [blame] | 302 | simulator to avoid clang replacing simple calls to fprintf with calls |
| 303 | to fwrite$UNIX2003 which Xcode then warns that doesn't exist on iOS. |
| 304 | |
| Tor Lillqvist | 21aec7e | 2012-02-22 20:41:58 +0200 | [diff] [blame] | 305 | |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 306 | Android |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 307 | ******* |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 308 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 309 | From a technical point of view the core Android OS (the kernel) is |
| 310 | Linux, but everything else is different. Unlike iOS, an Android app |
| 311 | can use shared objects just fine, so that aspect of UNO doesn't need |
| 312 | special handling. Except that there is a silly low limit in the |
| 313 | Android dynamic linker on the number of libraries you can dlopen. This |
| 314 | is a limitation in user-level (but system-provided and not really |
| 315 | replaceable) code, not the kernel. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 316 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 317 | Thus, just like for iOS, also for Android the LibreOffice libraries |
| 318 | and UNO components are built as static archives. For Android, those |
| 319 | static archives, and any app-specific native code, are linked into one |
| 320 | single app-specific shared library, called liblo-native-code.so. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 321 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 322 | For the GUI, the same holds as said above for iOS. The GUI layer needs |
| 323 | to be platform-specific, written in Java. |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 324 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 325 | Android cross-compilation work has been done mainly on Linux (openSUSE |
| 326 | in particular). Earlier also cross-compiling from OS X was tried. The |
| 327 | Android cross-compilation tool-chain (the "Native Development Kit", or |
| 328 | NDK) is available for Linux, OS X and Windows, but trying to |
| 329 | cross-compile LibreOffice from Windows will probably drive you insane. |
| Tor Lillqvist | 0f9f8ef | 2012-09-10 14:28:34 +0300 | [diff] [blame] | 330 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 331 | You will also need the Android SDK as full "make" also builds a couple |
| 332 | of Android apps where the upper layer is written in Java. |
| Tor Lillqvist | 199d220 | 2012-01-03 13:01:47 +0200 | [diff] [blame] | 333 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 334 | Use the "android" tool from the SDK to install the SDK Tools, SDK |
| Jan Holesovsky | c79e70f | 2014-06-26 10:57:05 +0200 | [diff] [blame] | 335 | Platform Tools, the API 15 SDK Platform and the Android Support |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 336 | Library. If you want to run the Android apps in the emulator, you of |
| 337 | course need an appropriate system image for that. |
| 338 | |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 339 | Here is an autogen.input for Android on ARM when cross-compiling |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 340 | from Linux: |
| 341 | |
| 342 | --build=x86_64-unknown-linux-gnu |
| 343 | --enable-dbgutil |
| Tor Lillqvist | ab236e1 | 2012-08-09 12:59:08 +0300 | [diff] [blame] | 344 | --enable-debug |
| 345 | --enable-werror |
| Tor Lillqvist | 2462aa6 | 2014-02-21 22:37:47 +0200 | [diff] [blame] | 346 | --with-android-ndk=/home/tml/android-ndk-r9c |
| 347 | --with-android-ndk-toolchain-version=4.8 |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 348 | --with-android-sdk=/home/tml/adt-bundle-linux/sdk |
| Michael Meeks | e61e51a | 2012-08-03 16:39:20 +0100 | [diff] [blame] | 349 | --with-distro=LibreOfficeAndroid |
| Tor Lillqvist | 9a6beed | 2011-12-15 23:54:31 +0200 | [diff] [blame] | 350 | |
| Tor Lillqvist | 2462aa6 | 2014-02-21 22:37:47 +0200 | [diff] [blame] | 351 | And here is an (quite old) autogen.input for Android on X86: |
| Michael Meeks | e61e51a | 2012-08-03 16:39:20 +0100 | [diff] [blame] | 352 | |
| Michael Meeks | e61e51a | 2012-08-03 16:39:20 +0100 | [diff] [blame] | 353 | --with-android-ndk=/opt/libreoffice/android-ndk-r8b |
| 354 | --with-android-ndk-toolchain-version=4.6 |
| 355 | --with-android-sdk=/opt/libreoffice/android-sdk-linux |
| 356 | --build=i586-suse-linux |
| 357 | --enable-ccache |
| Michael Meeks | e61e51a | 2012-08-03 16:39:20 +0100 | [diff] [blame] | 358 | --with-distro=LibreOfficeAndroidX86 |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 359 | |
| Tor Lillqvist | 886a299 | 2012-09-10 16:21:30 +0300 | [diff] [blame] | 360 | There are a couple of (more or less) interactive apps that you can run |
| 361 | on the emulator or on a device that use LibreOffice code. Look in |
| 362 | android/experimental. DocumentLoader is just a testbench, really for |
| Miklos Vajna | a54e927 | 2012-11-20 09:20:40 +0100 | [diff] [blame] | 363 | code to load a document (just Writer ones so far) and display one page |
| Tor Lillqvist | 886a299 | 2012-09-10 16:21:30 +0300 | [diff] [blame] | 364 | at a time. LibreOffice4Android is what resulted from a Google Summer |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 365 | of Code project in 2012, a document viewer. desktop is a totally |
| Tor Lillqvist | c43613b | 2013-03-18 09:50:46 +0200 | [diff] [blame] | 366 | different app, where the actual LibreOffice desktop GUI is present. |
| 367 | Note that none of these apps in any way are claimed to be ready for |
| 368 | end-users. No "beta testing" offers needed, it is painfully obvious |
| 369 | what problems they have. |
| Tor Lillqvist | 3ef7293 | 2012-01-03 13:48:29 +0200 | [diff] [blame] | 370 | |
| Tor Lillqvist | 886a299 | 2012-09-10 16:21:30 +0300 | [diff] [blame] | 371 | To run some of the apps, do "make install" followed by either "make |
| 372 | run" or starting it from Android itself. You most likely want to have |
| 373 | an "adb logcat" running in another window. |
| Tor Lillqvist | 199d220 | 2012-01-03 13:01:47 +0200 | [diff] [blame] | 374 | |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 375 | To debug, do manually what "make run" would do and when the app has |
| 376 | started, run ndk-gdb. |
| Tor Lillqvist | 7606616c | 2012-05-17 16:37:02 +0300 | [diff] [blame] | 377 | |
| Jan Holesovsky | c862be0 | 2014-10-13 16:51:08 +0200 | [diff] [blame] | 378 | You can also do that manually; to install: |
| 379 | |
| 380 | <android-sdk-linux>/platform-tools/adb install -r android/experimental/LOAndroid3/bin/LibreOfficeViewer-debug.apk |
| 381 | |
| 382 | To see the log: |
| 383 | |
| 384 | <android-sdk-linux>/platform-tools/adb logcat |
| 385 | |
| 386 | To debug, install the .apk, run it, and then: |
| 387 | |
| 388 | cd android/experimental/LOAndroid3 |
| 389 | <android-ndk-r9d>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb |
| 390 | |
| Jan Holesovsky | cfd74ae | 2014-06-27 15:44:25 +0200 | [diff] [blame] | 391 | NB: If you happen to upgrade to Android SDK Tools 23, and the build (using |
| 392 | 'make verbose=t android') fails for you with: |
| 393 | |
| 394 | [dx] UNEXPECTED TOP-LEVEL EXCEPTION: |
| 395 | [dx] java.io.FileNotFoundException: /local/libreoffice/android-sdk-linux/tools/support/annotations.jar (Adresář nebo soubor neexistuje) |
| 396 | |
| 397 | you need to copy the annotations.jar from an older sdk; like |
| 398 | |
| 399 | wget 'http://dl-ssl.google.com/android/repository/tools_r22.6.2-linux.zip' |
| 400 | unzip tools_r22.6.2-linux.zip |
| 401 | cp tools/support/annotations.jar <android-sdk-linux>/tools/support/ |
| Tor Lillqvist | ad4a467 | 2011-05-27 18:29:43 +0300 | [diff] [blame] | 402 | |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 403 | Raspbian |
| Tor Lillqvist | 30fded6 | 2013-03-18 09:24:41 +0200 | [diff] [blame] | 404 | ******** |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 405 | |
| Matúš Kukan | ee2d727 | 2014-01-16 15:56:30 +0100 | [diff] [blame] | 406 | In theory, this should work also for another Linux, it does not need to be Raspbian. |
| Tor Lillqvist | 661ab31 | 2014-02-22 13:48:40 +0200 | [diff] [blame] | 407 | But this cross-compilation work is tested from Debian and openSUSE to Raspbian. |
| Matúš Kukan | ee2d727 | 2014-01-16 15:56:30 +0100 | [diff] [blame] | 408 | |
| Tor Lillqvist | 78a6158 | 2014-01-20 15:01:25 +0200 | [diff] [blame] | 409 | You will need headers, pkg-config files and libraries from a Raspbian |
| 410 | system to build against. Available at |
| 411 | http://dev-www.libreoffice.org/extern/ . Look for the latest |
| 412 | raspbian-root-*.tar.gz . For instance: |
| 413 | |
| 414 | $ wget http://dev-www.libreoffice.org/extern/raspbian-root-20140120.tar.gz |
| 415 | $ mkdir raspbian-root |
| 416 | $ cd raspbian-root |
| 417 | $ tar -xf raspbian-root-20140120.tar.gz |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 418 | |
| 419 | You can build cross-compiler yourself or get the executables here: |
| 420 | $ git clone git://github.com/raspberrypi/tools |
| Tor Lillqvist | 78a6158 | 2014-01-20 15:01:25 +0200 | [diff] [blame] | 421 | |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 422 | tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian is known to work. |
| 423 | |
| 424 | Then create pkg-config wrapper, something like: |
| 425 | $ cat > pkg-config-wrapper-host << _EOF |
| 426 | #!/bin/sh |
| 427 | |
| Michael Stahl | d729d16 | 2014-02-27 16:19:43 +0100 | [diff] [blame] | 428 | if [ "$CROSS_COMPILING" = TRUE ]; then |
| Tor Lillqvist | 78a6158 | 2014-01-20 15:01:25 +0200 | [diff] [blame] | 429 | SYSROOT=$HOME/lo/raspbian-root |
| 430 | export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig:${SYSROOT}/usr/share/pkgconfig |
| 431 | export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig |
| 432 | export PKG_CONFIG_SYSROOT_DIR=${SYSROOT} |
| 433 | fi |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 434 | |
| 435 | exec pkg-config "\$@" |
| 436 | _EOF |
| 437 | $ chmod +x pkg-config-wrapper-host |
| Tor Lillqvist | 78a6158 | 2014-01-20 15:01:25 +0200 | [diff] [blame] | 438 | |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 439 | This does not work with pkg-config 0.23. 0.26 is known to work. |
| 440 | |
| Tor Lillqvist | 5011f4c | 2013-05-01 20:47:02 +0300 | [diff] [blame] | 441 | And you are ready to build with autogen.input similar to: |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 442 | |
| 443 | PKG_CONFIG=<path-to-pkg-config-wrapper-host> |
| 444 | CC=<path-to-arm-linux-gnueabihf-gcc> --sysroot=<path-to-raspbian_rootfs> |
| 445 | CXX=<path-to-arm-linux-gnueabihf-g++> --sysroot=<path-to-raspbian_rootfs> |
| 446 | --build=x86_64-unknown-linux-gnu |
| 447 | --host=arm-unknown-linux-gnueabihf |
| Matúš Kukan | ee2d727 | 2014-01-16 15:56:30 +0100 | [diff] [blame] | 448 | --disable-sdk |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 449 | --enable-python=system |
| 450 | PYTHON_CFLAGS=-I<path-to-raspbian_rootfs>/usr/include/python2.7 |
| 451 | PYTHON_LIBS=-lpython2.7 |
| 452 | --with-java |
| 453 | JAVAINC=-I<path-to-raspbian_rootfs>/usr/lib/jvm/java-6-openjdk-armhf/include |
| Matúš Kukan | 63a1321 | 2013-03-14 17:05:15 +0100 | [diff] [blame] | 454 | --with-system-cairo |
| 455 | --with-system-cppunit |
| 456 | --with-system-icu |
| 457 | --with-system-neon |
| 458 | --with-system-nss |
| 459 | --with-system-openldap |
| 460 | --with-system-openssl |
| 461 | --with-system-redland |
| 462 | |
| 463 | Finally, when you are ready to run the binaries in Raspbian, |
| Matúš Kukan | ee2d727 | 2014-01-16 15:56:30 +0100 | [diff] [blame] | 464 | you may need to get more system libraries, who knows. |
| 465 | $ sudo apt-get install libreoffice # or similar |
| 466 | That installs libreoffice too, which you don't need because you have |
| 467 | just built one, but I don't know how to avoid it easily. |