blob: 8412718c0f8518feba13a59757cf4375f27ad73c [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 Eglif9496272017-04-18 17:00:39 +020014* Table of Contents :TOC:
15 - [[#developing][Developing]]
16 - [[#where-to-get-it][Where to get it]]
17 - [[#build-requirements][Build requirements]]
18 - [[#gnulib][Gnulib]]
19 - [[#how-to-build][How to build]]
20 - [[#install-with-homebrew][Install with Homebrew]]
21 - [[#docker][Docker]]
22 - [[#how-to-run-tests][How to run tests]]
23 - [[#how-to-debug][How to debug]]
24 - [[#how-to-find-memory-leaks][How to find memory leaks]]
25 - [[#how-to-analyze-performance][How to analyze performance]]
26 - [[#how-to-build-for-windows][How to build for Windows]]
27 - [[#release-procedure][Release Procedure]]
28 - [[#update-the-news-entry][Update the NEWS entry]]
29 - [[#set-the-version-number][Set the version number]]
30 - [[#commit-and-tag][Commit and tag]]
31 - [[#make-the-release][Make the release]]
32 - [[#upload][Upload]]
33 - [[#online-documentation][Online documentation]]
34 - [[#web-site-maintenance][Web site maintenance]]
35 - [[#announce][Announce]]
36
Christian Egli5510e4a2009-11-05 09:55:30 +000037* Developing
38** Where to get it
Christian Egli71647d62014-05-20 09:20:28 +020039The development sources are available through git at github.com:
Christian Egli5510e4a2009-11-05 09:55:30 +000040
Christian Egli71647d62014-05-20 09:20:28 +020041 https://github.com/liblouis/liblouis
Christian Egli5510e4a2009-11-05 09:55:30 +000042
43** Build requirements
Christian Egli818e58b2015-06-05 14:27:06 +020044To build Automake, Autoconf, and Libtool are used. If you are getting
45the sources from git (or change configure.ac), you'll need to have
46these tools installed to (re)build. Optionally (if you want to
Christian Egli5510e4a2009-11-05 09:55:30 +000047generate man pages) you'll also need help2man. All of these programs
48are available from ftp://ftp.gnu.org/gnu.
49
Christian Eglia02c1362017-03-06 10:38:45 +010050If you want to run the YAML based test suite you will have to install
51~libyaml~.
52
Bert Frees34df6a62015-04-10 16:10:21 +020053On Mac OS, the programs can be optained with Homebrew (http://brew.sh):
Bert Freesd41c9ac2015-03-25 14:42:43 +010054
Bert Frees34df6a62015-04-10 16:10:21 +020055 brew install automake libtool pkg-config texinfo
56
57Note that if you are using Homebrew to install liblouis (see below),
58the build dependencies are installed automatically.
Bert Freesd41c9ac2015-03-25 14:42:43 +010059
Christian Egli5510e4a2009-11-05 09:55:30 +000060** Gnulib
Christian Egli818e58b2015-06-05 14:27:06 +020061Gnulib (http://www.gnu.org/software/gnulib) is used to provide
62portable basic functionality to programs and libraries. We use two
63instances of gnulib, one to provide portable functions such as
64~malloc~, ~strndup~, etc to the library and another one to provide
65portable functionality such as ~getopt~, ~progname~ or
66~version-etc~ to the tools.
Christian Egli5510e4a2009-11-05 09:55:30 +000067
Christian Egli818e58b2015-06-05 14:27:06 +020068The first time invocation to import gnulib for the library was
69
70 gnulib-tool --add-import --lib=libgnu --source-base=gnulib \
71 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
72 --macro-prefix=gl --no-vc-files \
73 malloc-gnu realloc-gnu strndup
74
75and for the tools
76
77 gnulib-tool --add-import --lib=libgnutools --source-base=tools/gnulib \
78 --m4-base=tools/gnulib/m4 --aux-dir=build-aux --libtool \
79 --macro-prefix=gl_tools --no-vc-files \
80 getopt-gnu malloc-gnu progname version-etc
81
Christian Egli5510e4a2009-11-05 09:55:30 +000082More modules might have been added since. The currently-used gnulib
83modules and other gnulib information are recorded in
Christian Egli818e58b2015-06-05 14:27:06 +020084~gnulib/m4/gnulib-cache.m4~ and ~tools/gnulib/m4/gnulib-cache.m4~.
85
86If you want to update from the current gnulib, install gnulib, and
87then run the following commands in the top-level directory.
88
89 gnulib-tool --add-import --lib=libgnu --source-base=gnulib \
90 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
91 --macro-prefix=gl --no-vc-files
92 gnulib-tool --add-import --lib=libgnutools --source-base=tools/gnulib \
93 --m4-base=tools/gnulib/m4 --aux-dir=build-aux --libtool \
94 --macro-prefix=gl_tools --no-vc-files
Christian Egli5510e4a2009-11-05 09:55:30 +000095
96** How to build
Christian Egli71647d62014-05-20 09:20:28 +020097After getting the sources from git, with
Christian Egli81b04812009-11-05 11:07:17 +000098
Christian Egli71647d62014-05-20 09:20:28 +020099 git clone https://github.com/liblouis/liblouis.git
Christian Egli81b04812009-11-05 11:07:17 +0000100
101and installing the tools above, change to the liblouis directory and
102and bootstrap the project with the following command
103
104 ./autogen.sh
105
106to do a fresh build. Then run configure as usual:
107
108 ./configure
109
110You have the choice to compile liblouis for either 16- or 32-bit
111Unicode. By default it is compiled for the former. To get 32-bit
112Unicode run configure with --enable-ucs4 .
113
114After running configure run "make" and then "make install". You must
115have root privileges for the installation step.
Christian Egli5510e4a2009-11-05 09:55:30 +0000116
Bert Frees34df6a62015-04-10 16:10:21 +0200117** Install with Homebrew
118Homebrew (http://brew.sh) is a package manager for Mac OS X that
119installs software from source. There is nothing special about the
120installation process in the sense that under the hood it happens
121exactly as described above, with the only difference that Homebrew
122automates it completely.
123
124First, use the ~brew tap~ command to add the repository that includes
125the liblouis formula:
126
127 brew tap liblouis/liblouis
128
129Now you are ready to install liblouis:
130
131 brew install liblouis
132
Bert Freesd41c9ac2015-03-25 14:42:43 +0100133** Docker
Bert Frees34df6a62015-04-10 16:10:21 +0200134Docker (https://www.docker.com) can be useful both for creating a
135development environment for liblouis, and for shipping the
136application.
Bert Freesd41c9ac2015-03-25 14:42:43 +0100137
Bert Frees34df6a62015-04-10 16:10:21 +0200138Setting up a developer environment can take long and can be
139problematic especially for Windows. Thanks to Docker we can set up the
140environment for you, we can easily distribute it as an image, which
141can be run by anybody and will behave exactly the same for everybody.
Bert Freesd41c9ac2015-03-25 14:42:43 +0100142
Bert Frees34df6a62015-04-10 16:10:21 +0200143Docker images of liblouis are being built automatically each time
144something changes in the code (see https://registry.hub.docker.com/repos/liblouis).
145In order to use them, first get Docker at
146http://docs.docker.com/introduction/get-docker. Download the latest
147liblouis image with:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100148
Bert Frees16f28202015-09-11 15:54:03 +0200149 docker pull liblouis/liblouis
Bert Frees34df6a62015-04-10 16:10:21 +0200150
151Then, enter the development environment by running the image in a
152Docker container:
153
Bert Frees16f28202015-09-11 15:54:03 +0200154 docker run -it liblouis/liblouis bash
Bert Frees34df6a62015-04-10 16:10:21 +0200155
156Local files and directories can be "mounted" inside the container, in
157order to make it easier to edit files and to persist changes across
158runs. For example, to use local table files:
159
160 docker run -it -v $(pwd)/tables:/tmp/liblouis/tables liblouis/liblouis bash
161
162See the Docker documentation for more info.
163
164The same Docker image can be used as a development environment and as
165the application itself. For example, to run the lou_translate tool
166from inside a Docker container:
167
Bert Frees16f28202015-09-11 15:54:03 +0200168 docker run -it liblouis/liblouis lou_translate en-us-g1.ctb
Bert Freesd41c9ac2015-03-25 14:42:43 +0100169
Bert Frees34df6a62015-04-10 16:10:21 +0200170To rebuild the image yourself, run the following command in the root
171directory of the liblouis source:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100172
Bert Frees16f28202015-09-11 15:54:03 +0200173 docker build -t liblouis/liblouis .
Bert Freesd41c9ac2015-03-25 14:42:43 +0100174
Bert Frees12e99042015-11-15 12:23:40 +0100175A .dockerignore file is required if you want to compile the source both on te host and in the Docker
176container. The .dockerignore file can be updated from .gitignore with:
177
178 make .dockerignore
179
Bert Freesd41c9ac2015-03-25 14:42:43 +0100180** How to run tests
Bert Frees34df6a62015-04-10 16:10:21 +0200181Tests are run with
Bert Freesd41c9ac2015-03-25 14:42:43 +0100182
Bert Frees34df6a62015-04-10 16:10:21 +0200183 make check
184
Christian Eglif70f4e02011-01-03 15:09:06 +0000185** How to debug
Christian Egli45b3d322013-01-17 09:51:56 +0000186First you have to build liblouis with debugging info enabled.
187
188 $ ./configure CFLAGS='-g -O0 -Wall -Wextra'
189 $ make
190
Christian Eglif70f4e02011-01-03 15:09:06 +0000191Starting the programs under the tools directory within gdb is a little
192tricky as they are linked with libtool. See the info page of libtool
193for more information. To start lou_checktable for table wiskunde.ctb
194for example you'd have to issue the following commands:
195
196 $ libtool --mode=execute gdb ./tools/lou_checktable
197 (gdb) run tables/wiskunde.ctb
198
Christian Eglic77a5892012-05-11 12:11:26 +0000199** How to find memory leaks
200Valgrind is a tool that can be used to find memory errors. It is
201recommended that you compile liblouis without any optimizations and
202with all warnings enabled before running it through Valgrind:
203
204 $ ./configure CFLAGS='-g -O0 -Wall'
205 $ make
206
207Then use Valgrind to analyze liblouis. For example you can run
208lou_translate trough Valgrind:
209
210 $ libtool --mode=execute valgrind -v --tool=memcheck \
211 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
212 ./tools/lou_translate en-us-g2.ctb
213
214Type a few words at the prompt, check translation and terminate
215lou_translate. Now open the file valgrind.log and see if there are any
216memory leaks reported.
217
218You can also just run lou_checktable for example:
219
220 $ libtool --mode=execute valgrind -v --tool=memcheck \
221 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
Davy Kagerb32f70a2016-07-04 12:16:33 +0200222 ./tools/lou_checktable tables/nl-BE-g0.utb
Christian Eglic77a5892012-05-11 12:11:26 +0000223
224Again open valgrind.log to see if any memory leaks were reported.
225
Christian Egliae435322012-05-14 10:00:36 +0000226For the full experience run lou_allround under Valgrind:
227
228 $ libtool --mode=execute valgrind -v --tool=memcheck \
229 --leak-check=full --show-reachable=yes \
230 --leak-resolution=high --track-origins=yes \
231 --log-file=valgrind.log ./tools/lou_allround
232
Christian Egli29de9382017-04-21 10:38:56 +0200233*** Electric Fence
234Electric Fence is a tool that helps detect memory access that overruns
235the boundaries of a malloc() memory allocation, and access to memory
236that has been free()d.
237
238Under Debian the usage is fairly straightforward:
239
240#+BEGIN_SRC shell
241$ sudo apt install sudo apt install electric-fence
242#+END_SRC
243
244Then compile [[How to debug][as above]] and invoke the debugger [[How to debug][as above]]. Inside =gdb=
245set up =LOUIS_TABLEPATH= and =LD_PRELOAD= as follows:
246
247#+BEGIN_SRC gdb-script
248set environment LOUIS_TABLEPATH ./tables,./tests/tables,./tests/tables/moreTables,./tests/tablesWithMetadata,./tests/tables/emphclass
249set environment LD_PRELOAD /usr/lib/libefence.so.0.0
250run
251#+END_SRC
252
253If there are problems with memory access the program will run into a
254segmentation fault which you can consequently analyze in the debugger.
255
Christian Egli6eb63342013-06-03 10:03:54 +0000256** How to analyze performance
257Gprof helps you analyze the performance of programs. You have to
258compile liblouis as follows:
259
260 $ ./configure --disable-shared
261 $ make clean all CFLAGS='-g -O0 -pg' LDFLAGS='-all-static'
262
263Then translate some stuff with a large table:
264
265 $ ./tools/lou_translate tests/tables/large.ctb
266
267Finally look at the call profile:
268
269 $ libtool --mode=execute gprof ./tools/lou_translate gmon.out
270
Bert Freesd51268a2015-11-15 17:23:45 +0100271** How to build for Windows
Christian Egli311d52b2013-01-11 16:19:23 +0000272See the README.windows file and the windows subdirectory.
Christian Egli75cd5692012-05-16 08:00:37 +0000273
Bert Frees34df6a62015-04-10 16:10:21 +0200274*** How to cross-compile for Windows
275To compile for win32, use the MinGW win32 cross-compiler as shown
276below. Use the prefix option to install the binaries to a temporary
Christian Egli854386d2016-06-01 16:47:42 +0200277place where you can create a zip file. The LDFLAGS='-all-static'
278ensures that libgcc is linked in statically. Otherwise the users need
279to have libgcc_s_sjlj-1.dll.
Christian Egli75cd5692012-05-16 08:00:37 +0000280
Christian Eglid5bea6c2016-06-03 08:38:52 +0200281Some users want the dlls unversioned. To achieve that add
282'-avoid-version' to LDFLAGS.
283
Christian Egli854386d2016-06-01 16:47:42 +0200284 ./configure --build=i686-pc-linux-gnu --host=i686-w64-mingw32 --prefix=/tmp/liblouis-mingw32
Christian Eglid5bea6c2016-06-03 08:38:52 +0200285 make LDFLAGS='-avoid-version -Xcompiler -static-libgcc'
Christian Eglidaaf7e32013-06-21 14:27:14 +0000286 make install
Christian Egli854386d2016-06-01 16:47:42 +0200287 zip -r liblouis-mingw32msvc.zip /tmp/liblouis-mingw32
Christian Egli75cd5692012-05-16 08:00:37 +0000288
Bert Frees34df6a62015-04-10 16:10:21 +0200289To compile for win64, use the MinGW-w64 cross-compiler:
290
Christian Egli854386d2016-06-01 16:47:42 +0200291 ./configure --build=i686-pc-linux-gnu --host=x86_64-w64-mingw32 --prefix=/tmp/liblouis-w64-mingw32
Christian Eglid5bea6c2016-06-03 08:38:52 +0200292 make LDFLAGS='-avoid-version -Xcompiler -static-libgcc'
Bert Frees34df6a62015-04-10 16:10:21 +0200293 make install
294 zip -r liblouis-w64-mingw32.zip /tmp/liblouis-w64-mingw32
295
Bert Freesd51268a2015-11-15 17:23:45 +0100296Two makefile rules have been provided to do this automatically for you. Docker will be used if the
297right cross-compiler is not installed. To compile for win32 using the MinGW cross-compiler, run make
298distwin32. This will produce a ZIP file called liblouis-<version>-win32.zip. To compile for win64
299using the MinGW-w64 cross-compiler, run make distwin64. This will produce a ZIP file called
300liblouis-<version>-win64.zip.
301
Bert Frees34df6a62015-04-10 16:10:21 +0200302*** TODO How to build for Windows using Cygwin
303(possibly use a Vagrantfile as demonstration + explain that Cygwin
304binaries can not be used outside the Cygwin environment)
305
306*** TODO How to build for Windows using MinGW
307(possibly use a Vagrant file as demonstration)
308
Christian Eglieddc4662009-03-09 13:27:20 +0000309* Release Procedure
310These steps describe what a maintainer does to make a release; they
311are not needed for ordinary patch submission.
312
Christian Egli2d889a82015-12-07 08:56:55 +0100313** Update the NEWS entry
314If any new tables were added or renamed please note them with their
315name in the NEWS entry. This is usefull for projects like NVDA.
316
Christian Eglieddc4662009-03-09 13:27:20 +0000317** Set the version number
318Update the version number in NEWS (with version, date, and release
Christian Egli541e7272017-03-06 14:34:31 +0100319type), ChangeLog, configure.ac and windows/include/config.h.
Christian Eglieddc4662009-03-09 13:27:20 +0000320
Christian Eglid1f57182011-05-18 07:16:46 +0000321Don't forget to update the libtool versioning info in configure.ac,
322i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE.
323
Christian Eglieddc4662009-03-09 13:27:20 +0000324** Commit and tag
325Commit the changes and tag this version
326
Christian Egli5f9c03f2014-09-01 14:01:41 +0200327 git tag -s v2.6.0 -m "Release 2.6.0"
328 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000329
330If you know the exact version number that needs to be tagged use
331
Christian Egli5f9c03f2014-09-01 14:01:41 +0200332 git tag -s v2.6.0 -m "Release 2.6.0" <commit>
333 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000334
335** Make the release
336Check out a clean copy in a different directory, like /tmp. Run
337autogen.sh and configure with no special prefixes. Run make distcheck.
338This will make sure that all needed files are present, and do a
339general sanity check. Run make dist. This will produce a tarball.
340
Christian Egli9a3b3ce2009-05-27 13:46:37 +0000341 ./autogen.sh && ./configure && make && make distcheck && make dist
Christian Eglieddc4662009-03-09 13:27:20 +0000342
343** Upload
Christian Egli88bfad92015-06-01 11:16:46 +0200344Add the tarball to the github liblouis releases page, i.e. add it
345under https://github.com/liblouis/liblouis/releases with the specific
346release and add a link to it in $WEBSITE/downloads/index.md. See below
347for instructions on how to update the web site.
Christian Eglieddc4662009-03-09 13:27:20 +0000348
Christian Egli2ed702e2009-03-12 13:06:39 +0000349** Online documentation
Christian Egli71647d62014-05-20 09:20:28 +0200350The online documentation is part of the liblouis web site. To add it to the
351site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html.
352Make sure you add the proper YAML front matter. Again see below for
353instructions on how to update the web site.
Christian Egli2ed702e2009-03-12 13:06:39 +0000354
Christian Egli71647d62014-05-20 09:20:28 +0200355** Web site maintenance
356The liblouis web site at liblouis.org is maintained with the help of
357github pages (https://pages.github.com/). To edit the site just check
358out the repo at https://github.com/liblouis/liblouis.github.io. You'll
359need to know a few things about Jekyll (http://jekyllrb.com/) and
Christian Egli3725f222016-07-15 10:19:55 +0200360markdown, the markup that is used to edit the content. In order to
361update the site simply edit, commit and push.
Christian Egli2ed702e2009-03-12 13:06:39 +0000362
Christian Egli00087342017-03-07 16:13:16 +0100363For the new release update the project web site.
364
365- Add a post containing the current NEWS to the _posts directory and
366- add the download artifacts to the download page
Christian Egli2ed702e2009-03-12 13:06:39 +0000367
Christian Egli25419732011-05-09 07:38:14 +0000368** Announce
369Send an announcement to the liblouis list
370liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example.
371