/
tutorial.texi
164 lines (115 loc) · 3.05 KB
/
tutorial.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename gnudance.info
@settitle Doing the @sc{gnu} Dance
@include version.texi
@c %**end of header
@copying
Copyright © 2008 Michael Schürig
@end copying
@titlepage
@title Doing the @sc{gnu} Dance
@subtitle A Few Quick Steps Through a @sc{gnu}-ified and @i{Debian}-ized Project
@insertcopying
@end titlepage
@contents
@node Rationale
@chapter Rationale
@node Infrastructure
@chapter Infrastructure
@node A sample program
@section A Sample Program
@node git it
@section @t{git} it!
@node Nobody expects the autoconf-iscation
@section Nobody Expects the @t{autoconf}-iscation
@node Languages aplenty
@section Languages Aplenty
@node On being testy
@section On Being Testy
@node Sticking it into the man page
@section Sticking it into the @t{man} page
@node For your info
@section For Your @t{info}
@node Packing it for Debian
@section Packing it for Debian
@node Program
@chapter Program
@bye
$ git init
Initialized empty Git repository in /home/michael/projects/hangon/.git/
$ git commit
# Autotools
$ touch NEWS README AUTHORS ChangeLog
$ autoreconf --install
$ git commit
--> .gitignore
# debugging & fortification
# internationalization
#include <stdio.h>
#include <libintl.h>
#include <locale.h>
#include "config.h"
#define _(msgid) gettext(msgid)
#define N_(msgid) msgid
int
main(int argc, char *argv[])
{
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
printf(_("Hello, World!\n"));
}
$ gettextize
$ autoreconf --install
# add generated files to git
# -> src/Makefile.am
localedir = $(datadir)/locale
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
$ mv po/Makevars.template po/Makevars
# src/hangon.c -> po/POTFILES.in
# de -> po/LINGUAS
$ cd po && msginit -l de && cd -
# translate po/de.po
# re-config so that the new language is picked up
$ ./config.status
$ cd po && make update-po && cd -
# *.gmo -> po/.gitignore
$ mkdir build.test
$ cd build.test
$ ../configure --prefix=/tmp/test
$ make
$ make install
$ LC_MESSAGES=de_DE.UTF-8 /tmp/test/bin/hangon
Hallo, Welt!
### Write some real code and translations
### Add a bunch of autotest tests
# -> configure.ac
AC_CONFIG_TESTDIR([tests], [tests:src])
AC_CONFIG_FILES([tests/Makefile])
# Define additional programs needed for hacking on this project,
# but not required for simply building it.
# autom4te: used for merging tests into a suite
AM_MISSING_PROG([AUTOM4TE], [autom4te])
$ autoreconf
$ make check
### Add a man page
# -> configure.ac
# help2man: used for deriving man pages from --help and --version output
AM_MISSING_PROG([HELP2MAN], [help2man])
# -> Makefile.am
man_page = $(PACKAGE).1
man_MANS = $(man_page)
CLEANFILES = $(man_page)
EXTRA_DIST = config.rpath m4/ChangeLog $(man_MANS)
# Create the man page from --help and --version output
common_dep = $(top_srcdir)/configure.ac
### TODO remove the explicit name
$(man_page): $(common_dep) $(srcdir)/hangon.x $(srcdir)/src/hangon.c
SUFFIXES = .x .1
.x.1:
$(HELP2MAN) \
--no-info \
--include=$(srcdir)/$*.x \
--output=$@ src/$*
### Debian package