blob: b2b287fb5d09f0d4762581083562dd35e87af13c [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
Christian Eglia02c1362017-03-06 10:38:45 +010027If you want to run the YAML based test suite you will have to install
28~libyaml~.
29
Bert Frees34df6a62015-04-10 16:10:21 +020030On Mac OS, the programs can be optained with Homebrew (http://brew.sh):
Bert Freesd41c9ac2015-03-25 14:42:43 +010031
Bert Frees34df6a62015-04-10 16:10:21 +020032 brew install automake libtool pkg-config texinfo
33
34Note that if you are using Homebrew to install liblouis (see below),
35the build dependencies are installed automatically.
Bert Freesd41c9ac2015-03-25 14:42:43 +010036
Christian Egli5510e4a2009-11-05 09:55:30 +000037** Gnulib
Christian Egli818e58b2015-06-05 14:27:06 +020038Gnulib (http://www.gnu.org/software/gnulib) is used to provide
39portable basic functionality to programs and libraries. We use two
40instances of gnulib, one to provide portable functions such as
41~malloc~, ~strndup~, etc to the library and another one to provide
42portable functionality such as ~getopt~, ~progname~ or
43~version-etc~ to the tools.
Christian Egli5510e4a2009-11-05 09:55:30 +000044
Christian Egli818e58b2015-06-05 14:27:06 +020045The first time invocation to import gnulib for the library was
46
47 gnulib-tool --add-import --lib=libgnu --source-base=gnulib \
48 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
49 --macro-prefix=gl --no-vc-files \
50 malloc-gnu realloc-gnu strndup
51
52and for the tools
53
54 gnulib-tool --add-import --lib=libgnutools --source-base=tools/gnulib \
55 --m4-base=tools/gnulib/m4 --aux-dir=build-aux --libtool \
56 --macro-prefix=gl_tools --no-vc-files \
57 getopt-gnu malloc-gnu progname version-etc
58
Christian Egli5510e4a2009-11-05 09:55:30 +000059More modules might have been added since. The currently-used gnulib
60modules and other gnulib information are recorded in
Christian Egli818e58b2015-06-05 14:27:06 +020061~gnulib/m4/gnulib-cache.m4~ and ~tools/gnulib/m4/gnulib-cache.m4~.
62
63If you want to update from the current gnulib, install gnulib, and
64then run the following commands in the top-level directory.
65
66 gnulib-tool --add-import --lib=libgnu --source-base=gnulib \
67 --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \
68 --macro-prefix=gl --no-vc-files
69 gnulib-tool --add-import --lib=libgnutools --source-base=tools/gnulib \
70 --m4-base=tools/gnulib/m4 --aux-dir=build-aux --libtool \
71 --macro-prefix=gl_tools --no-vc-files
Christian Egli5510e4a2009-11-05 09:55:30 +000072
73** How to build
Christian Egli71647d62014-05-20 09:20:28 +020074After getting the sources from git, with
Christian Egli81b04812009-11-05 11:07:17 +000075
Christian Egli71647d62014-05-20 09:20:28 +020076 git clone https://github.com/liblouis/liblouis.git
Christian Egli81b04812009-11-05 11:07:17 +000077
78and installing the tools above, change to the liblouis directory and
79and bootstrap the project with the following command
80
81 ./autogen.sh
82
83to do a fresh build. Then run configure as usual:
84
85 ./configure
86
87You have the choice to compile liblouis for either 16- or 32-bit
88Unicode. By default it is compiled for the former. To get 32-bit
89Unicode run configure with --enable-ucs4 .
90
91After running configure run "make" and then "make install". You must
92have root privileges for the installation step.
Christian Egli5510e4a2009-11-05 09:55:30 +000093
Bert Frees34df6a62015-04-10 16:10:21 +020094** Install with Homebrew
95Homebrew (http://brew.sh) is a package manager for Mac OS X that
96installs software from source. There is nothing special about the
97installation process in the sense that under the hood it happens
98exactly as described above, with the only difference that Homebrew
99automates it completely.
100
101First, use the ~brew tap~ command to add the repository that includes
102the liblouis formula:
103
104 brew tap liblouis/liblouis
105
106Now you are ready to install liblouis:
107
108 brew install liblouis
109
Bert Freesd41c9ac2015-03-25 14:42:43 +0100110** Docker
Bert Frees34df6a62015-04-10 16:10:21 +0200111Docker (https://www.docker.com) can be useful both for creating a
112development environment for liblouis, and for shipping the
113application.
Bert Freesd41c9ac2015-03-25 14:42:43 +0100114
Bert Frees34df6a62015-04-10 16:10:21 +0200115Setting up a developer environment can take long and can be
116problematic especially for Windows. Thanks to Docker we can set up the
117environment for you, we can easily distribute it as an image, which
118can be run by anybody and will behave exactly the same for everybody.
Bert Freesd41c9ac2015-03-25 14:42:43 +0100119
Bert Frees34df6a62015-04-10 16:10:21 +0200120Docker images of liblouis are being built automatically each time
121something changes in the code (see https://registry.hub.docker.com/repos/liblouis).
122In order to use them, first get Docker at
123http://docs.docker.com/introduction/get-docker. Download the latest
124liblouis image with:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100125
Bert Frees16f28202015-09-11 15:54:03 +0200126 docker pull liblouis/liblouis
Bert Frees34df6a62015-04-10 16:10:21 +0200127
128Then, enter the development environment by running the image in a
129Docker container:
130
Bert Frees16f28202015-09-11 15:54:03 +0200131 docker run -it liblouis/liblouis bash
Bert Frees34df6a62015-04-10 16:10:21 +0200132
133Local files and directories can be "mounted" inside the container, in
134order to make it easier to edit files and to persist changes across
135runs. For example, to use local table files:
136
137 docker run -it -v $(pwd)/tables:/tmp/liblouis/tables liblouis/liblouis bash
138
139See the Docker documentation for more info.
140
141The same Docker image can be used as a development environment and as
142the application itself. For example, to run the lou_translate tool
143from inside a Docker container:
144
Bert Frees16f28202015-09-11 15:54:03 +0200145 docker run -it liblouis/liblouis lou_translate en-us-g1.ctb
Bert Freesd41c9ac2015-03-25 14:42:43 +0100146
Bert Frees34df6a62015-04-10 16:10:21 +0200147To rebuild the image yourself, run the following command in the root
148directory of the liblouis source:
Bert Freesd41c9ac2015-03-25 14:42:43 +0100149
Bert Frees16f28202015-09-11 15:54:03 +0200150 docker build -t liblouis/liblouis .
Bert Freesd41c9ac2015-03-25 14:42:43 +0100151
Bert Frees12e99042015-11-15 12:23:40 +0100152A .dockerignore file is required if you want to compile the source both on te host and in the Docker
153container. The .dockerignore file can be updated from .gitignore with:
154
155 make .dockerignore
156
Bert Freesd41c9ac2015-03-25 14:42:43 +0100157** How to run tests
Bert Frees34df6a62015-04-10 16:10:21 +0200158Tests are run with
Bert Freesd41c9ac2015-03-25 14:42:43 +0100159
Bert Frees34df6a62015-04-10 16:10:21 +0200160 make check
161
Christian Eglif70f4e02011-01-03 15:09:06 +0000162** How to debug
Christian Egli45b3d322013-01-17 09:51:56 +0000163First you have to build liblouis with debugging info enabled.
164
165 $ ./configure CFLAGS='-g -O0 -Wall -Wextra'
166 $ make
167
Christian Eglif70f4e02011-01-03 15:09:06 +0000168Starting the programs under the tools directory within gdb is a little
169tricky as they are linked with libtool. See the info page of libtool
170for more information. To start lou_checktable for table wiskunde.ctb
171for example you'd have to issue the following commands:
172
173 $ libtool --mode=execute gdb ./tools/lou_checktable
174 (gdb) run tables/wiskunde.ctb
175
Christian Eglic77a5892012-05-11 12:11:26 +0000176** How to find memory leaks
177Valgrind is a tool that can be used to find memory errors. It is
178recommended that you compile liblouis without any optimizations and
179with all warnings enabled before running it through Valgrind:
180
181 $ ./configure CFLAGS='-g -O0 -Wall'
182 $ make
183
184Then use Valgrind to analyze liblouis. For example you can run
185lou_translate trough Valgrind:
186
187 $ libtool --mode=execute valgrind -v --tool=memcheck \
188 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
189 ./tools/lou_translate en-us-g2.ctb
190
191Type a few words at the prompt, check translation and terminate
192lou_translate. Now open the file valgrind.log and see if there are any
193memory leaks reported.
194
195You can also just run lou_checktable for example:
196
197 $ libtool --mode=execute valgrind -v --tool=memcheck \
198 --leak-check=full --leak-resolution=high --log-file=valgrind.log \
Davy Kagerb32f70a2016-07-04 12:16:33 +0200199 ./tools/lou_checktable tables/nl-BE-g0.utb
Christian Eglic77a5892012-05-11 12:11:26 +0000200
201Again open valgrind.log to see if any memory leaks were reported.
202
Christian Egliae435322012-05-14 10:00:36 +0000203For the full experience run lou_allround under Valgrind:
204
205 $ libtool --mode=execute valgrind -v --tool=memcheck \
206 --leak-check=full --show-reachable=yes \
207 --leak-resolution=high --track-origins=yes \
208 --log-file=valgrind.log ./tools/lou_allround
209
Christian Egli6eb63342013-06-03 10:03:54 +0000210** How to analyze performance
211Gprof helps you analyze the performance of programs. You have to
212compile liblouis as follows:
213
214 $ ./configure --disable-shared
215 $ make clean all CFLAGS='-g -O0 -pg' LDFLAGS='-all-static'
216
217Then translate some stuff with a large table:
218
219 $ ./tools/lou_translate tests/tables/large.ctb
220
221Finally look at the call profile:
222
223 $ libtool --mode=execute gprof ./tools/lou_translate gmon.out
224
Bert Freesd51268a2015-11-15 17:23:45 +0100225** How to build for Windows
Christian Egli311d52b2013-01-11 16:19:23 +0000226See the README.windows file and the windows subdirectory.
Christian Egli75cd5692012-05-16 08:00:37 +0000227
Bert Frees34df6a62015-04-10 16:10:21 +0200228*** How to cross-compile for Windows
229To compile for win32, use the MinGW win32 cross-compiler as shown
230below. Use the prefix option to install the binaries to a temporary
Christian Egli854386d2016-06-01 16:47:42 +0200231place where you can create a zip file. The LDFLAGS='-all-static'
232ensures that libgcc is linked in statically. Otherwise the users need
233to have libgcc_s_sjlj-1.dll.
Christian Egli75cd5692012-05-16 08:00:37 +0000234
Christian Eglid5bea6c2016-06-03 08:38:52 +0200235Some users want the dlls unversioned. To achieve that add
236'-avoid-version' to LDFLAGS.
237
Christian Egli854386d2016-06-01 16:47:42 +0200238 ./configure --build=i686-pc-linux-gnu --host=i686-w64-mingw32 --prefix=/tmp/liblouis-mingw32
Christian Eglid5bea6c2016-06-03 08:38:52 +0200239 make LDFLAGS='-avoid-version -Xcompiler -static-libgcc'
Christian Eglidaaf7e32013-06-21 14:27:14 +0000240 make install
Christian Egli854386d2016-06-01 16:47:42 +0200241 zip -r liblouis-mingw32msvc.zip /tmp/liblouis-mingw32
Christian Egli75cd5692012-05-16 08:00:37 +0000242
Bert Frees34df6a62015-04-10 16:10:21 +0200243To compile for win64, use the MinGW-w64 cross-compiler:
244
Christian Egli854386d2016-06-01 16:47:42 +0200245 ./configure --build=i686-pc-linux-gnu --host=x86_64-w64-mingw32 --prefix=/tmp/liblouis-w64-mingw32
Christian Eglid5bea6c2016-06-03 08:38:52 +0200246 make LDFLAGS='-avoid-version -Xcompiler -static-libgcc'
Bert Frees34df6a62015-04-10 16:10:21 +0200247 make install
248 zip -r liblouis-w64-mingw32.zip /tmp/liblouis-w64-mingw32
249
Bert Freesd51268a2015-11-15 17:23:45 +0100250Two makefile rules have been provided to do this automatically for you. Docker will be used if the
251right cross-compiler is not installed. To compile for win32 using the MinGW cross-compiler, run make
252distwin32. This will produce a ZIP file called liblouis-<version>-win32.zip. To compile for win64
253using the MinGW-w64 cross-compiler, run make distwin64. This will produce a ZIP file called
254liblouis-<version>-win64.zip.
255
Bert Frees34df6a62015-04-10 16:10:21 +0200256*** TODO How to build for Windows using Cygwin
257(possibly use a Vagrantfile as demonstration + explain that Cygwin
258binaries can not be used outside the Cygwin environment)
259
260*** TODO How to build for Windows using MinGW
261(possibly use a Vagrant file as demonstration)
262
Christian Egli75cd5692012-05-16 08:00:37 +0000263
Christian Eglieddc4662009-03-09 13:27:20 +0000264* Release Procedure
265These steps describe what a maintainer does to make a release; they
266are not needed for ordinary patch submission.
267
Christian Egli2d889a82015-12-07 08:56:55 +0100268** Update the NEWS entry
269If any new tables were added or renamed please note them with their
270name in the NEWS entry. This is usefull for projects like NVDA.
271
Christian Eglieddc4662009-03-09 13:27:20 +0000272** Set the version number
273Update the version number in NEWS (with version, date, and release
274type), ChangeLog and configure.ac.
275
Christian Eglid1f57182011-05-18 07:16:46 +0000276Don't forget to update the libtool versioning info in configure.ac,
277i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE.
278
Christian Eglieddc4662009-03-09 13:27:20 +0000279** Commit and tag
280Commit the changes and tag this version
281
Christian Egli5f9c03f2014-09-01 14:01:41 +0200282 git tag -s v2.6.0 -m "Release 2.6.0"
283 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000284
285If you know the exact version number that needs to be tagged use
286
Christian Egli5f9c03f2014-09-01 14:01:41 +0200287 git tag -s v2.6.0 -m "Release 2.6.0" <commit>
288 git push origin v2.6.0
Christian Eglieddc4662009-03-09 13:27:20 +0000289
290** Make the release
291Check out a clean copy in a different directory, like /tmp. Run
292autogen.sh and configure with no special prefixes. Run make distcheck.
293This will make sure that all needed files are present, and do a
294general sanity check. Run make dist. This will produce a tarball.
295
Christian Egli9a3b3ce2009-05-27 13:46:37 +0000296 ./autogen.sh && ./configure && make && make distcheck && make dist
Christian Eglieddc4662009-03-09 13:27:20 +0000297
298** Upload
Christian Egli88bfad92015-06-01 11:16:46 +0200299Add the tarball to the github liblouis releases page, i.e. add it
300under https://github.com/liblouis/liblouis/releases with the specific
301release and add a link to it in $WEBSITE/downloads/index.md. See below
302for instructions on how to update the web site.
Christian Eglieddc4662009-03-09 13:27:20 +0000303
Christian Egli2ed702e2009-03-12 13:06:39 +0000304** Online documentation
Christian Egli71647d62014-05-20 09:20:28 +0200305The online documentation is part of the liblouis web site. To add it to the
306site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html.
307Make sure you add the proper YAML front matter. Again see below for
308instructions on how to update the web site.
Christian Egli2ed702e2009-03-12 13:06:39 +0000309
Christian Egli71647d62014-05-20 09:20:28 +0200310** Web site maintenance
311The liblouis web site at liblouis.org is maintained with the help of
312github pages (https://pages.github.com/). To edit the site just check
313out the repo at https://github.com/liblouis/liblouis.github.io. You'll
314need to know a few things about Jekyll (http://jekyllrb.com/) and
Christian Egli3725f222016-07-15 10:19:55 +0200315markdown, the markup that is used to edit the content. In order to
316update the site simply edit, commit and push.
Christian Egli2ed702e2009-03-12 13:06:39 +0000317
Christian Egli71647d62014-05-20 09:20:28 +0200318For the new release update the project web site. Add a post containing
319the current NEWS to the _posts directory.
Christian Egli2ed702e2009-03-12 13:06:39 +0000320
Christian Egli25419732011-05-09 07:38:14 +0000321** Announce
322Send an announcement to the liblouis list
323liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example.
324