blob: 86dcfb35cb17c8317c2fbc949ae47ed982a8a9b3 [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 Egli71647d62014-05-20 09:20:28 +02004 Copyright (C) 2012, 2013, 2014 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
21This distribution uses Automake, Autoconf, and Libtool. If you are
Christian Egli71647d62014-05-20 09:20:28 +020022getting the sources from git (or change configure.ac), you'll need to
Christian Egli5510e4a2009-11-05 09:55:30 +000023have these tools installed to (re)build. Optionally (if you want to
24generate 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 Egli71647d62014-05-20 09:20:28 +020035This distribution also uses Gnulib (http://www.gnu.org/software/gnulib). If
36you want to update from the current gnulib, install gnulib, and then run
37gnulib-tool --import in the top-level directory.
Christian Egli5510e4a2009-11-05 09:55:30 +000038
39For the record, the first time invocation was
40 gnulib-tool --import --lib=libgnu --source-base=gnulib \
41 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
42 --macro-prefix=gl getopt-gnu progname version-etc
43More modules might have been added since. The currently-used gnulib
44modules and other gnulib information are recorded in
45gnulib/m4/gnulib-cache.m4. Given a source checkout of gnulib, you can
46update the files with gnulib-tool --import.
47
48** How to build
Christian Egli71647d62014-05-20 09:20:28 +020049After getting the sources from git, with
Christian Egli81b04812009-11-05 11:07:17 +000050
Christian Egli71647d62014-05-20 09:20:28 +020051 git clone https://github.com/liblouis/liblouis.git
Christian Egli81b04812009-11-05 11:07:17 +000052
53and installing the tools above, change to the liblouis directory and
54and bootstrap the project with the following command
55
56 ./autogen.sh
57
58to do a fresh build. Then run configure as usual:
59
60 ./configure
61
62You have the choice to compile liblouis for either 16- or 32-bit
63Unicode. By default it is compiled for the former. To get 32-bit
64Unicode run configure with --enable-ucs4 .
65
66After running configure run "make" and then "make install". You must
67have root privileges for the installation step.
Christian Egli5510e4a2009-11-05 09:55:30 +000068
Bert Frees34df6a62015-04-10 16:10:21 +020069** Install with Homebrew
70Homebrew (http://brew.sh) is a package manager for Mac OS X that
71installs software from source. There is nothing special about the
72installation process in the sense that under the hood it happens
73exactly as described above, with the only difference that Homebrew
74automates it completely.
75
76First, use the ~brew tap~ command to add the repository that includes
77the liblouis formula:
78
79 brew tap liblouis/liblouis
80
81Now you are ready to install liblouis:
82
83 brew install liblouis
84
Bert Freesd41c9ac2015-03-25 14:42:43 +010085** Docker
Bert Frees34df6a62015-04-10 16:10:21 +020086Docker (https://www.docker.com) can be useful both for creating a
87development environment for liblouis, and for shipping the
88application.
Bert Freesd41c9ac2015-03-25 14:42:43 +010089
Bert Frees34df6a62015-04-10 16:10:21 +020090Setting up a developer environment can take long and can be
91problematic especially for Windows. Thanks to Docker we can set up the
92environment for you, we can easily distribute it as an image, which
93can be run by anybody and will behave exactly the same for everybody.
Bert Freesd41c9ac2015-03-25 14:42:43 +010094
Bert Frees34df6a62015-04-10 16:10:21 +020095Docker images of liblouis are being built automatically each time
96something changes in the code (see https://registry.hub.docker.com/repos/liblouis).
97In order to use them, first get Docker at
98http://docs.docker.com/introduction/get-docker. Download the latest
99liblouis image with:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100100
101 docker pull liblouis/libouis
Bert Frees34df6a62015-04-10 16:10:21 +0200102
103Then, enter the development environment by running the image in a
104Docker container:
105
106 docker run -it liblouis/libouis bash
107
108Local files and directories can be "mounted" inside the container, in
109order to make it easier to edit files and to persist changes across
110runs. For example, to use local table files:
111
112 docker run -it -v $(pwd)/tables:/tmp/liblouis/tables liblouis/liblouis bash
113
114See the Docker documentation for more info.
115
116The same Docker image can be used as a development environment and as
117the application itself. For example, to run the lou_translate tool
118from inside a Docker container:
119
Bert Freesd41c9ac2015-03-25 14:42:43 +0100120 docker run -it liblouis/libouis lou_translate en-us-g1.ctb
121
Bert Frees34df6a62015-04-10 16:10:21 +0200122To rebuild the image yourself, run the following command in the root
123directory of the liblouis source:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100124
125 docker build -t liblouis/liblouis
126
127** How to run tests
Bert Frees34df6a62015-04-10 16:10:21 +0200128Tests are run with
Bert Freesd41c9ac2015-03-25 14:42:43 +0100129
Bert Frees34df6a62015-04-10 16:10:21 +0200130 make check
131
132This however doesn't include the harness tests. Running the harness
133tests requires Python and nose (https://nose.readthedocs.org). Also,
134you need to have compiled with --enable-ucs4. To run all harness
135tests, go into the tests/harness directory and run:
136
137 make runall
138
139To run a single test:
140
141 make <name of harness file>
Bert Freesd41c9ac2015-03-25 14:42:43 +0100142
Christian Eglif70f4e02011-01-03 15:09:06 +0000143** How to debug
Christian Egli45b3d322013-01-17 09:51:56 +0000144First you have to build liblouis with debugging info enabled.
145
146 $ ./configure CFLAGS='-g -O0 -Wall -Wextra'
147 $ make
148
Christian Eglif70f4e02011-01-03 15:09:06 +0000149Starting the programs under the tools directory within gdb is a little
150tricky as they are linked with libtool. See the info page of libtool
151for more information. To start lou_checktable for table wiskunde.ctb
152for example you'd have to issue the following commands:
153
154 $ libtool --mode=execute gdb ./tools/lou_checktable
155 (gdb) run tables/wiskunde.ctb
156
Christian Eglic77a5892012-05-11 12:11:26 +0000157** How to find memory leaks
158Valgrind is a tool that can be used to find memory errors. It is
159recommended that you compile liblouis without any optimizations and
160with all warnings enabled before running it through Valgrind:
161
162 $ ./configure CFLAGS='-g -O0 -Wall'
163 $ make
164
165Then use Valgrind to analyze liblouis. For example you can run
166lou_translate trough Valgrind:
167
168 $ libtool --mode=execute valgrind -v --tool=memcheck \
169 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
170 ./tools/lou_translate en-us-g2.ctb
171
172Type a few words at the prompt, check translation and terminate
173lou_translate. Now open the file valgrind.log and see if there are any
174memory leaks reported.
175
176You can also just run lou_checktable for example:
177
178 $ libtool --mode=execute valgrind -v --tool=memcheck \
179 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
180 ./tools/lou_checktable tables/nl-BE-g1.ctb
181
182Again open valgrind.log to see if any memory leaks were reported.
183
Christian Egliae435322012-05-14 10:00:36 +0000184For the full experience run lou_allround under Valgrind:
185
186 $ libtool --mode=execute valgrind -v --tool=memcheck \
187 --leak-check=full --show-reachable=yes \
188 --leak-resolution=high --track-origins=yes \
189 --log-file=valgrind.log ./tools/lou_allround
190
Christian Egli6eb63342013-06-03 10:03:54 +0000191** How to analyze performance
192Gprof helps you analyze the performance of programs. You have to
193compile liblouis as follows:
194
195 $ ./configure --disable-shared
196 $ make clean all CFLAGS='-g -O0 -pg' LDFLAGS='-all-static'
197
198Then translate some stuff with a large table:
199
200 $ ./tools/lou_translate tests/tables/large.ctb
201
202Finally look at the call profile:
203
204 $ libtool --mode=execute gprof ./tools/lou_translate gmon.out
205
Christian Egli35f4aeb2010-08-19 11:58:07 +0000206** How to build for win32
Christian Egli311d52b2013-01-11 16:19:23 +0000207See the README.windows file and the windows subdirectory.
Christian Egli75cd5692012-05-16 08:00:37 +0000208
Bert Frees34df6a62015-04-10 16:10:21 +0200209*** How to cross-compile for Windows
210To compile for win32, use the MinGW win32 cross-compiler as shown
211below. Use the prefix option to install the binaries to a temporary
212place where you can create a zip file.
Christian Egli75cd5692012-05-16 08:00:37 +0000213
Christian Eglidaaf7e32013-06-21 14:27:14 +0000214 ./configure --build i686-pc-linux-gnu --host i586-mingw32msvc --prefix=/tmp/liblouis-mingw32msvc
Christian Egli75cd5692012-05-16 08:00:37 +0000215 make
Christian Eglidaaf7e32013-06-21 14:27:14 +0000216 make install
217 zip -r liblouis-mingw32msvc.zip /tmp/liblouis-mingw32msvc
Christian Egli75cd5692012-05-16 08:00:37 +0000218
Bert Frees34df6a62015-04-10 16:10:21 +0200219To compile for win64, use the MinGW-w64 cross-compiler:
220
221 ./configure --host x86_64-w64-mingw32 --prefix=/tmp/liblouis-w64-mingw32
222 make
223 make install
224 zip -r liblouis-w64-mingw32.zip /tmp/liblouis-w64-mingw32
225
226*** TODO How to build for Windows using Cygwin
227(possibly use a Vagrantfile as demonstration + explain that Cygwin
228binaries can not be used outside the Cygwin environment)
229
230*** TODO How to build for Windows using MinGW
231(possibly use a Vagrant file as demonstration)
232
Christian Egli75cd5692012-05-16 08:00:37 +0000233
Christian Eglieddc4662009-03-09 13:27:20 +0000234* Release Procedure
235These steps describe what a maintainer does to make a release; they
236are not needed for ordinary patch submission.
237
238** Set the version number
239Update the version number in NEWS (with version, date, and release
240type), ChangeLog and configure.ac.
241
Christian Eglid1f57182011-05-18 07:16:46 +0000242Don't forget to update the libtool versioning info in configure.ac,
243i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE.
244
Christian Eglieddc4662009-03-09 13:27:20 +0000245** Commit and tag
246Commit the changes and tag this version
247
Christian Egli5f9c03f2014-09-01 14:01:41 +0200248 git tag -s v2.6.0 -m "Release 2.6.0"
249 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000250
251If you know the exact version number that needs to be tagged use
252
Christian Egli5f9c03f2014-09-01 14:01:41 +0200253 git tag -s v2.6.0 -m "Release 2.6.0" <commit>
254 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000255
256** Make the release
257Check out a clean copy in a different directory, like /tmp. Run
258autogen.sh and configure with no special prefixes. Run make distcheck.
259This will make sure that all needed files are present, and do a
260general sanity check. Run make dist. This will produce a tarball.
261
Christian Egli9a3b3ce2009-05-27 13:46:37 +0000262 ./autogen.sh && ./configure && make && make distcheck && make dist
Christian Eglieddc4662009-03-09 13:27:20 +0000263
264** Upload
Christian Egli71647d62014-05-20 09:20:28 +0200265Add the tarball to the liblouis web site, i.e. add it under
Christian Egli5f9c03f2014-09-01 14:01:41 +0200266$WEBSITE/downloads and add a link to it in $WEBSITE/downloads/index.md.
Christian Egli71647d62014-05-20 09:20:28 +0200267See below for instructions on how to update the web site.
Christian Eglieddc4662009-03-09 13:27:20 +0000268
Christian Egli2ed702e2009-03-12 13:06:39 +0000269** Online documentation
Christian Egli71647d62014-05-20 09:20:28 +0200270The online documentation is part of the liblouis web site. To add it to the
271site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html.
272Make sure you add the proper YAML front matter. Again see below for
273instructions on how to update the web site.
Christian Egli2ed702e2009-03-12 13:06:39 +0000274
Christian Egli71647d62014-05-20 09:20:28 +0200275** Web site maintenance
276The liblouis web site at liblouis.org is maintained with the help of
277github pages (https://pages.github.com/). To edit the site just check
278out the repo at https://github.com/liblouis/liblouis.github.io. You'll
279need to know a few things about Jekyll (http://jekyllrb.com/) and
280textile (http://redcloth.org/textile/) the markup that is used to edit
281the content. In order to update the site simply edit, commit and push.
Christian Egli2ed702e2009-03-12 13:06:39 +0000282
Christian Egli71647d62014-05-20 09:20:28 +0200283For the new release update the project web site. Add a post containing
284the current NEWS to the _posts directory.
Christian Egli2ed702e2009-03-12 13:06:39 +0000285
Christian Egli25419732011-05-09 07:38:14 +0000286** Announce
287Send an announcement to the liblouis list
288liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example.
289