blob: 32dee37209f7e979e0c04a121778b1e0756d6b0f [file] [log] [blame]
Christian Eglif70f4e02011-01-03 15:09:06 +00001This HACKING file describes the development environment. -*- org -*-
Christian Egli5510e4a2009-11-05 09:55:30 +00002
Christian Egli311d52b2013-01-11 16:19:23 +00003 Copyright (C) 2008, 2009, 2011 ViewPlus Technologies, Inc. and Abilitiessoft, Inc.
Christian Egli818e58b2015-06-05 14:27:06 +02004 Copyright (C) 2012, 2013, 2014,2015 Swiss Library for the Blind, Visually Impaired and Print Disabled
Christian Egli311d52b2013-01-11 16:19:23 +00005
Christian Egli5510e4a2009-11-05 09:55:30 +00006 Copying and distribution of this file, with or without modification,
7 are permitted in any medium without royalty provided the copyright
Christian Egli741b0072014-09-18 11:08:45 +02008 notice and this notice are preserved. This file is offered as-is,
9 without any warranty.
Christian Eglieddc4662009-03-09 13:27:20 +000010
11This file attempts to describe the maintainer-specific notes to follow
12when hacking liblouis.
13
Christian Egli5510e4a2009-11-05 09:55:30 +000014* Developing
15** Where to get it
Christian Egli71647d62014-05-20 09:20:28 +020016The development sources are available through git at github.com:
Christian Egli5510e4a2009-11-05 09:55:30 +000017
Christian Egli71647d62014-05-20 09:20:28 +020018 https://github.com/liblouis/liblouis
Christian Egli5510e4a2009-11-05 09:55:30 +000019
20** Build requirements
Christian Egli818e58b2015-06-05 14:27:06 +020021To build Automake, Autoconf, and Libtool are used. If you are getting
22the sources from git (or change configure.ac), you'll need to have
23these tools installed to (re)build. Optionally (if you want to
Christian Egli5510e4a2009-11-05 09:55:30 +000024generate man pages) you'll also need help2man. All of these programs
25are available from ftp://ftp.gnu.org/gnu.
26
Bert Frees34df6a62015-04-10 16:10:21 +020027On Mac OS, the programs can be optained with Homebrew (http://brew.sh):
Bert Freesd41c9ac2015-03-25 14:42:43 +010028
Bert Frees34df6a62015-04-10 16:10:21 +020029 brew install automake libtool pkg-config texinfo
30
31Note that if you are using Homebrew to install liblouis (see below),
32the build dependencies are installed automatically.
Bert Freesd41c9ac2015-03-25 14:42:43 +010033
Christian Egli5510e4a2009-11-05 09:55:30 +000034** Gnulib
Christian Egli818e58b2015-06-05 14:27:06 +020035Gnulib (http://www.gnu.org/software/gnulib) is used to provide
36portable basic functionality to programs and libraries. We use two
37instances of gnulib, one to provide portable functions such as
38~malloc~, ~strndup~, etc to the library and another one to provide
39portable functionality such as ~getopt~, ~progname~ or
40~version-etc~ to the tools.
Christian Egli5510e4a2009-11-05 09:55:30 +000041
Christian Egli818e58b2015-06-05 14:27:06 +020042The first time invocation to import gnulib for the library was
43
44 gnulib-tool --add-import --lib=libgnu --source-base=gnulib \
45 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
46 --macro-prefix=gl --no-vc-files \
47 malloc-gnu realloc-gnu strndup
48
49and for the tools
50
51 gnulib-tool --add-import --lib=libgnutools --source-base=tools/gnulib \
52 --m4-base=tools/gnulib/m4 --aux-dir=build-aux --libtool \
53 --macro-prefix=gl_tools --no-vc-files \
54 getopt-gnu malloc-gnu progname version-etc
55
Christian Egli5510e4a2009-11-05 09:55:30 +000056More modules might have been added since. The currently-used gnulib
57modules and other gnulib information are recorded in
Christian Egli818e58b2015-06-05 14:27:06 +020058~gnulib/m4/gnulib-cache.m4~ and ~tools/gnulib/m4/gnulib-cache.m4~.
59
60If you want to update from the current gnulib, install gnulib, and
61then run the following commands in the top-level directory.
62
63 gnulib-tool --add-import --lib=libgnu --source-base=gnulib \
64 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
65 --macro-prefix=gl --no-vc-files
66 gnulib-tool --add-import --lib=libgnutools --source-base=tools/gnulib \
67 --m4-base=tools/gnulib/m4 --aux-dir=build-aux --libtool \
68 --macro-prefix=gl_tools --no-vc-files
Christian Egli5510e4a2009-11-05 09:55:30 +000069
70** How to build
Christian Egli71647d62014-05-20 09:20:28 +020071After getting the sources from git, with
Christian Egli81b04812009-11-05 11:07:17 +000072
Christian Egli71647d62014-05-20 09:20:28 +020073 git clone https://github.com/liblouis/liblouis.git
Christian Egli81b04812009-11-05 11:07:17 +000074
75and installing the tools above, change to the liblouis directory and
76and bootstrap the project with the following command
77
78 ./autogen.sh
79
80to do a fresh build. Then run configure as usual:
81
82 ./configure
83
84You have the choice to compile liblouis for either 16- or 32-bit
85Unicode. By default it is compiled for the former. To get 32-bit
86Unicode run configure with --enable-ucs4 .
87
88After running configure run "make" and then "make install". You must
89have root privileges for the installation step.
Christian Egli5510e4a2009-11-05 09:55:30 +000090
Bert Frees34df6a62015-04-10 16:10:21 +020091** Install with Homebrew
92Homebrew (http://brew.sh) is a package manager for Mac OS X that
93installs software from source. There is nothing special about the
94installation process in the sense that under the hood it happens
95exactly as described above, with the only difference that Homebrew
96automates it completely.
97
98First, use the ~brew tap~ command to add the repository that includes
99the liblouis formula:
100
101 brew tap liblouis/liblouis
102
103Now you are ready to install liblouis:
104
105 brew install liblouis
106
Bert Freesd41c9ac2015-03-25 14:42:43 +0100107** Docker
Bert Frees34df6a62015-04-10 16:10:21 +0200108Docker (https://www.docker.com) can be useful both for creating a
109development environment for liblouis, and for shipping the
110application.
Bert Freesd41c9ac2015-03-25 14:42:43 +0100111
Bert Frees34df6a62015-04-10 16:10:21 +0200112Setting up a developer environment can take long and can be
113problematic especially for Windows. Thanks to Docker we can set up the
114environment for you, we can easily distribute it as an image, which
115can be run by anybody and will behave exactly the same for everybody.
Bert Freesd41c9ac2015-03-25 14:42:43 +0100116
Bert Frees34df6a62015-04-10 16:10:21 +0200117Docker images of liblouis are being built automatically each time
118something changes in the code (see https://registry.hub.docker.com/repos/liblouis).
119In order to use them, first get Docker at
120http://docs.docker.com/introduction/get-docker. Download the latest
121liblouis image with:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100122
Bert Frees16f28202015-09-11 15:54:03 +0200123 docker pull liblouis/liblouis
Bert Frees34df6a62015-04-10 16:10:21 +0200124
125Then, enter the development environment by running the image in a
126Docker container:
127
Bert Frees16f28202015-09-11 15:54:03 +0200128 docker run -it liblouis/liblouis bash
Bert Frees34df6a62015-04-10 16:10:21 +0200129
130Local files and directories can be "mounted" inside the container, in
131order to make it easier to edit files and to persist changes across
132runs. For example, to use local table files:
133
134 docker run -it -v $(pwd)/tables:/tmp/liblouis/tables liblouis/liblouis bash
135
136See the Docker documentation for more info.
137
138The same Docker image can be used as a development environment and as
139the application itself. For example, to run the lou_translate tool
140from inside a Docker container:
141
Bert Frees16f28202015-09-11 15:54:03 +0200142 docker run -it liblouis/liblouis lou_translate en-us-g1.ctb
Bert Freesd41c9ac2015-03-25 14:42:43 +0100143
Bert Frees34df6a62015-04-10 16:10:21 +0200144To rebuild the image yourself, run the following command in the root
145directory of the liblouis source:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100146
Bert Frees16f28202015-09-11 15:54:03 +0200147 docker build -t liblouis/liblouis .
Bert Freesd41c9ac2015-03-25 14:42:43 +0100148
Bert Frees12e99042015-11-15 12:23:40 +0100149A .dockerignore file is required if you want to compile the source both on te host and in the Docker
150container. The .dockerignore file can be updated from .gitignore with:
151
152 make .dockerignore
153
Bert Freesd41c9ac2015-03-25 14:42:43 +0100154** How to run tests
Bert Frees34df6a62015-04-10 16:10:21 +0200155Tests are run with
Bert Freesd41c9ac2015-03-25 14:42:43 +0100156
Bert Frees34df6a62015-04-10 16:10:21 +0200157 make check
158
Christian Eglif70f4e02011-01-03 15:09:06 +0000159** How to debug
Christian Egli45b3d322013-01-17 09:51:56 +0000160First you have to build liblouis with debugging info enabled.
161
162 $ ./configure CFLAGS='-g -O0 -Wall -Wextra'
163 $ make
164
Christian Eglif70f4e02011-01-03 15:09:06 +0000165Starting the programs under the tools directory within gdb is a little
166tricky as they are linked with libtool. See the info page of libtool
167for more information. To start lou_checktable for table wiskunde.ctb
168for example you'd have to issue the following commands:
169
170 $ libtool --mode=execute gdb ./tools/lou_checktable
171 (gdb) run tables/wiskunde.ctb
172
Christian Eglic77a5892012-05-11 12:11:26 +0000173** How to find memory leaks
174Valgrind is a tool that can be used to find memory errors. It is
175recommended that you compile liblouis without any optimizations and
176with all warnings enabled before running it through Valgrind:
177
178 $ ./configure CFLAGS='-g -O0 -Wall'
179 $ make
180
181Then use Valgrind to analyze liblouis. For example you can run
182lou_translate trough Valgrind:
183
184 $ libtool --mode=execute valgrind -v --tool=memcheck \
185 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
186 ./tools/lou_translate en-us-g2.ctb
187
188Type a few words at the prompt, check translation and terminate
189lou_translate. Now open the file valgrind.log and see if there are any
190memory leaks reported.
191
192You can also just run lou_checktable for example:
193
194 $ libtool --mode=execute valgrind -v --tool=memcheck \
195 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
Davy Kagerb32f70a2016-07-04 12:16:33 +0200196 ./tools/lou_checktable tables/nl-BE-g0.utb
Christian Eglic77a5892012-05-11 12:11:26 +0000197
198Again open valgrind.log to see if any memory leaks were reported.
199
Christian Egliae435322012-05-14 10:00:36 +0000200For the full experience run lou_allround under Valgrind:
201
202 $ libtool --mode=execute valgrind -v --tool=memcheck \
203 --leak-check=full --show-reachable=yes \
204 --leak-resolution=high --track-origins=yes \
205 --log-file=valgrind.log ./tools/lou_allround
206
Christian Egli6eb63342013-06-03 10:03:54 +0000207** How to analyze performance
208Gprof helps you analyze the performance of programs. You have to
209compile liblouis as follows:
210
211 $ ./configure --disable-shared
212 $ make clean all CFLAGS='-g -O0 -pg' LDFLAGS='-all-static'
213
214Then translate some stuff with a large table:
215
216 $ ./tools/lou_translate tests/tables/large.ctb
217
218Finally look at the call profile:
219
220 $ libtool --mode=execute gprof ./tools/lou_translate gmon.out
221
Christian Egli35f4aeb2010-08-19 11:58:07 +0000222** How to build for win32
Christian Egli311d52b2013-01-11 16:19:23 +0000223See the README.windows file and the windows subdirectory.
Christian Egli75cd5692012-05-16 08:00:37 +0000224
Bert Frees34df6a62015-04-10 16:10:21 +0200225*** How to cross-compile for Windows
226To compile for win32, use the MinGW win32 cross-compiler as shown
227below. Use the prefix option to install the binaries to a temporary
Christian Egli854386d2016-06-01 16:47:42 +0200228place where you can create a zip file. The LDFLAGS='-all-static'
229ensures that libgcc is linked in statically. Otherwise the users need
230to have libgcc_s_sjlj-1.dll.
Christian Egli75cd5692012-05-16 08:00:37 +0000231
Christian Eglid5bea6c2016-06-03 08:38:52 +0200232Some users want the dlls unversioned. To achieve that add
233'-avoid-version' to LDFLAGS.
234
Christian Egli854386d2016-06-01 16:47:42 +0200235 ./configure --build=i686-pc-linux-gnu --host=i686-w64-mingw32 --prefix=/tmp/liblouis-mingw32
Christian Eglid5bea6c2016-06-03 08:38:52 +0200236 make LDFLAGS='-avoid-version -Xcompiler -static-libgcc'
Christian Eglidaaf7e32013-06-21 14:27:14 +0000237 make install
Christian Egli854386d2016-06-01 16:47:42 +0200238 zip -r liblouis-mingw32msvc.zip /tmp/liblouis-mingw32
Christian Egli75cd5692012-05-16 08:00:37 +0000239
Bert Frees34df6a62015-04-10 16:10:21 +0200240To compile for win64, use the MinGW-w64 cross-compiler:
241
Christian Egli854386d2016-06-01 16:47:42 +0200242 ./configure --build=i686-pc-linux-gnu --host=x86_64-w64-mingw32 --prefix=/tmp/liblouis-w64-mingw32
Christian Eglid5bea6c2016-06-03 08:38:52 +0200243 make LDFLAGS='-avoid-version -Xcompiler -static-libgcc'
Bert Frees34df6a62015-04-10 16:10:21 +0200244 make install
245 zip -r liblouis-w64-mingw32.zip /tmp/liblouis-w64-mingw32
246
247*** TODO How to build for Windows using Cygwin
248(possibly use a Vagrantfile as demonstration + explain that Cygwin
249binaries can not be used outside the Cygwin environment)
250
251*** TODO How to build for Windows using MinGW
252(possibly use a Vagrant file as demonstration)
253
Christian Egli75cd5692012-05-16 08:00:37 +0000254
Christian Eglieddc4662009-03-09 13:27:20 +0000255* Release Procedure
256These steps describe what a maintainer does to make a release; they
257are not needed for ordinary patch submission.
258
Christian Egli2d889a82015-12-07 08:56:55 +0100259** Update the NEWS entry
260If any new tables were added or renamed please note them with their
261name in the NEWS entry. This is usefull for projects like NVDA.
262
Christian Eglieddc4662009-03-09 13:27:20 +0000263** Set the version number
264Update the version number in NEWS (with version, date, and release
265type), ChangeLog and configure.ac.
266
Christian Eglid1f57182011-05-18 07:16:46 +0000267Don't forget to update the libtool versioning info in configure.ac,
268i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE.
269
Christian Eglieddc4662009-03-09 13:27:20 +0000270** Commit and tag
271Commit the changes and tag this version
272
Christian Egli5f9c03f2014-09-01 14:01:41 +0200273 git tag -s v2.6.0 -m "Release 2.6.0"
274 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000275
276If you know the exact version number that needs to be tagged use
277
Christian Egli5f9c03f2014-09-01 14:01:41 +0200278 git tag -s v2.6.0 -m "Release 2.6.0" <commit>
279 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000280
281** Make the release
282Check out a clean copy in a different directory, like /tmp. Run
283autogen.sh and configure with no special prefixes. Run make distcheck.
284This will make sure that all needed files are present, and do a
285general sanity check. Run make dist. This will produce a tarball.
286
Christian Egli9a3b3ce2009-05-27 13:46:37 +0000287 ./autogen.sh && ./configure && make && make distcheck && make dist
Christian Eglieddc4662009-03-09 13:27:20 +0000288
289** Upload
Christian Egli88bfad92015-06-01 11:16:46 +0200290Add the tarball to the github liblouis releases page, i.e. add it
291under https://github.com/liblouis/liblouis/releases with the specific
292release and add a link to it in $WEBSITE/downloads/index.md. See below
293for instructions on how to update the web site.
Christian Eglieddc4662009-03-09 13:27:20 +0000294
Christian Egli2ed702e2009-03-12 13:06:39 +0000295** Online documentation
Christian Egli71647d62014-05-20 09:20:28 +0200296The online documentation is part of the liblouis web site. To add it to the
297site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html.
298Make sure you add the proper YAML front matter. Again see below for
299instructions on how to update the web site.
Christian Egli2ed702e2009-03-12 13:06:39 +0000300
Christian Egli71647d62014-05-20 09:20:28 +0200301** Web site maintenance
302The liblouis web site at liblouis.org is maintained with the help of
303github pages (https://pages.github.com/). To edit the site just check
304out the repo at https://github.com/liblouis/liblouis.github.io. You'll
305need to know a few things about Jekyll (http://jekyllrb.com/) and
Christian Egli3725f222016-07-15 10:19:55 +0200306markdown, the markup that is used to edit the content. In order to
307update the site simply edit, commit and push.
Christian Egli2ed702e2009-03-12 13:06:39 +0000308
Christian Egli71647d62014-05-20 09:20:28 +0200309For the new release update the project web site. Add a post containing
310the current NEWS to the _posts directory.
Christian Egli2ed702e2009-03-12 13:06:39 +0000311
Christian Egli25419732011-05-09 07:38:14 +0000312** Announce
313Send an announcement to the liblouis list
314liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example.
315