blob: 56021b85f3b34ab4cf08c80235a9165c4be4e809 [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
123 docker pull liblouis/libouis
Bert Frees34df6a62015-04-10 16:10:21 +0200124
125Then, enter the development environment by running the image in a
126Docker container:
127
128 docker run -it liblouis/libouis bash
129
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 Freesd41c9ac2015-03-25 14:42:43 +0100142 docker run -it liblouis/libouis lou_translate en-us-g1.ctb
143
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
147 docker build -t liblouis/liblouis
148
149** How to run tests
Bert Frees34df6a62015-04-10 16:10:21 +0200150Tests are run with
Bert Freesd41c9ac2015-03-25 14:42:43 +0100151
Bert Frees34df6a62015-04-10 16:10:21 +0200152 make check
153
154This however doesn't include the harness tests. Running the harness
155tests requires Python and nose (https://nose.readthedocs.org). Also,
156you need to have compiled with --enable-ucs4. To run all harness
157tests, go into the tests/harness directory and run:
158
159 make runall
160
161To run a single test:
162
163 make <name of harness file>
Bert Freesd41c9ac2015-03-25 14:42:43 +0100164
Christian Eglif70f4e02011-01-03 15:09:06 +0000165** How to debug
Christian Egli45b3d322013-01-17 09:51:56 +0000166First you have to build liblouis with debugging info enabled.
167
168 $ ./configure CFLAGS='-g -O0 -Wall -Wextra'
169 $ make
170
Christian Eglif70f4e02011-01-03 15:09:06 +0000171Starting the programs under the tools directory within gdb is a little
172tricky as they are linked with libtool. See the info page of libtool
173for more information. To start lou_checktable for table wiskunde.ctb
174for example you'd have to issue the following commands:
175
176 $ libtool --mode=execute gdb ./tools/lou_checktable
177 (gdb) run tables/wiskunde.ctb
178
Christian Eglic77a5892012-05-11 12:11:26 +0000179** How to find memory leaks
180Valgrind is a tool that can be used to find memory errors. It is
181recommended that you compile liblouis without any optimizations and
182with all warnings enabled before running it through Valgrind:
183
184 $ ./configure CFLAGS='-g -O0 -Wall'
185 $ make
186
187Then use Valgrind to analyze liblouis. For example you can run
188lou_translate trough Valgrind:
189
190 $ libtool --mode=execute valgrind -v --tool=memcheck \
191 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
192 ./tools/lou_translate en-us-g2.ctb
193
194Type a few words at the prompt, check translation and terminate
195lou_translate. Now open the file valgrind.log and see if there are any
196memory leaks reported.
197
198You can also just run lou_checktable for example:
199
200 $ libtool --mode=execute valgrind -v --tool=memcheck \
201 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
202 ./tools/lou_checktable tables/nl-BE-g1.ctb
203
204Again open valgrind.log to see if any memory leaks were reported.
205
Christian Egliae435322012-05-14 10:00:36 +0000206For the full experience run lou_allround under Valgrind:
207
208 $ libtool --mode=execute valgrind -v --tool=memcheck \
209 --leak-check=full --show-reachable=yes \
210 --leak-resolution=high --track-origins=yes \
211 --log-file=valgrind.log ./tools/lou_allround
212
Christian Egli6eb63342013-06-03 10:03:54 +0000213** How to analyze performance
214Gprof helps you analyze the performance of programs. You have to
215compile liblouis as follows:
216
217 $ ./configure --disable-shared
218 $ make clean all CFLAGS='-g -O0 -pg' LDFLAGS='-all-static'
219
220Then translate some stuff with a large table:
221
222 $ ./tools/lou_translate tests/tables/large.ctb
223
224Finally look at the call profile:
225
226 $ libtool --mode=execute gprof ./tools/lou_translate gmon.out
227
Christian Egli35f4aeb2010-08-19 11:58:07 +0000228** How to build for win32
Christian Egli311d52b2013-01-11 16:19:23 +0000229See the README.windows file and the windows subdirectory.
Christian Egli75cd5692012-05-16 08:00:37 +0000230
Bert Frees34df6a62015-04-10 16:10:21 +0200231*** How to cross-compile for Windows
232To compile for win32, use the MinGW win32 cross-compiler as shown
233below. Use the prefix option to install the binaries to a temporary
234place where you can create a zip file.
Christian Egli75cd5692012-05-16 08:00:37 +0000235
Christian Eglidaaf7e32013-06-21 14:27:14 +0000236 ./configure --build i686-pc-linux-gnu --host i586-mingw32msvc --prefix=/tmp/liblouis-mingw32msvc
Christian Egli75cd5692012-05-16 08:00:37 +0000237 make
Christian Eglidaaf7e32013-06-21 14:27:14 +0000238 make install
239 zip -r liblouis-mingw32msvc.zip /tmp/liblouis-mingw32msvc
Christian Egli75cd5692012-05-16 08:00:37 +0000240
Bert Frees34df6a62015-04-10 16:10:21 +0200241To compile for win64, use the MinGW-w64 cross-compiler:
242
243 ./configure --host x86_64-w64-mingw32 --prefix=/tmp/liblouis-w64-mingw32
244 make
245 make install
246 zip -r liblouis-w64-mingw32.zip /tmp/liblouis-w64-mingw32
247
248*** TODO How to build for Windows using Cygwin
249(possibly use a Vagrantfile as demonstration + explain that Cygwin
250binaries can not be used outside the Cygwin environment)
251
252*** TODO How to build for Windows using MinGW
253(possibly use a Vagrant file as demonstration)
254
Christian Egli75cd5692012-05-16 08:00:37 +0000255
Christian Eglieddc4662009-03-09 13:27:20 +0000256* Release Procedure
257These steps describe what a maintainer does to make a release; they
258are not needed for ordinary patch submission.
259
Christian Egli2d889a82015-12-07 08:56:55 +0100260** Update the NEWS entry
261If any new tables were added or renamed please note them with their
262name in the NEWS entry. This is usefull for projects like NVDA.
263
Christian Eglieddc4662009-03-09 13:27:20 +0000264** Set the version number
265Update the version number in NEWS (with version, date, and release
266type), ChangeLog and configure.ac.
267
Christian Eglid1f57182011-05-18 07:16:46 +0000268Don't forget to update the libtool versioning info in configure.ac,
269i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE.
270
Christian Eglieddc4662009-03-09 13:27:20 +0000271** Commit and tag
272Commit the changes and tag this version
273
Christian Egli5f9c03f2014-09-01 14:01:41 +0200274 git tag -s v2.6.0 -m "Release 2.6.0"
275 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000276
277If you know the exact version number that needs to be tagged use
278
Christian Egli5f9c03f2014-09-01 14:01:41 +0200279 git tag -s v2.6.0 -m "Release 2.6.0" <commit>
280 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000281
282** Make the release
283Check out a clean copy in a different directory, like /tmp. Run
284autogen.sh and configure with no special prefixes. Run make distcheck.
285This will make sure that all needed files are present, and do a
286general sanity check. Run make dist. This will produce a tarball.
287
Christian Egli9a3b3ce2009-05-27 13:46:37 +0000288 ./autogen.sh && ./configure && make && make distcheck && make dist
Christian Eglieddc4662009-03-09 13:27:20 +0000289
290** Upload
Christian Egli88bfad92015-06-01 11:16:46 +0200291Add the tarball to the github liblouis releases page, i.e. add it
292under https://github.com/liblouis/liblouis/releases with the specific
293release and add a link to it in $WEBSITE/downloads/index.md. See below
294for instructions on how to update the web site.
Christian Eglieddc4662009-03-09 13:27:20 +0000295
Christian Egli2ed702e2009-03-12 13:06:39 +0000296** Online documentation
Christian Egli71647d62014-05-20 09:20:28 +0200297The online documentation is part of the liblouis web site. To add it to the
298site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html.
299Make sure you add the proper YAML front matter. Again see below for
300instructions on how to update the web site.
Christian Egli2ed702e2009-03-12 13:06:39 +0000301
Christian Egli71647d62014-05-20 09:20:28 +0200302** Web site maintenance
303The liblouis web site at liblouis.org is maintained with the help of
304github pages (https://pages.github.com/). To edit the site just check
305out the repo at https://github.com/liblouis/liblouis.github.io. You'll
306need to know a few things about Jekyll (http://jekyllrb.com/) and
307textile (http://redcloth.org/textile/) the markup that is used to edit
308the content. In order to update the site simply edit, commit and push.
Christian Egli2ed702e2009-03-12 13:06:39 +0000309
Christian Egli71647d62014-05-20 09:20:28 +0200310For the new release update the project web site. Add a post containing
311the current NEWS to the _posts directory.
Christian Egli2ed702e2009-03-12 13:06:39 +0000312
Christian Egli25419732011-05-09 07:38:14 +0000313** Announce
314Send an announcement to the liblouis list
315liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example.
316