]> git.notmuchmail.org Git - notmuch/blob - configure
Merge branch 'debian' into rebuild
[notmuch] / configure
1 #! /bin/sh
2
3 # Set several defaults (optionally specified by the user in
4 # environemnt variables)
5 CC=${CC:-gcc}
6 CXX=${CXX:-g++}
7 CFLAGS=${CFLAGS:--O2}
8 CXXFLAGS=${CXXFLAGS:-\$(CFLAGS)}
9 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config-1.1 xapian-config}
10
11 # We don't allow the EMACS or GZIP Makefile variables inherit values
12 # from the environment as we do with CC and CXX above. The reason is
13 # that these names as environment variables have existing uses other
14 # than the program name that we want. (EMACS is set to 't' when a
15 # shell is running within emacs and GZIP specifies arguments to pass
16 # on the gzip command line).
17
18 # Set the defaults for values the user can specify with command-line
19 # options.
20 PREFIX=/usr/local
21 LIBDIR=
22
23 usage ()
24 {
25     cat <<EOF
26 Usage: ./configure [options]...
27
28 This script configures notmuch to build on your system.
29
30 It verifies that dependencies are available, determines flags needed
31 to compile and link against various required libraries, and identifies
32 whether various system functions can be used or if locally-provided
33 replacements will be built instead.
34
35 Finally, it allows you to control various aspects of the build and
36 installation process.
37
38 First, some common variables can specified via environment variables:
39
40         CC              The C compiler to use
41         CFLAGS          Flags to pass to the C compiler
42         CXX             The C++ compiler to use
43         CXXFLAGS        Flags to pass to the C compiler
44         LDFLAGS         Flags to pass when linking
45
46 Each of these values can further be controlled by specifying them
47 later on the "make" command line.
48
49 Other environment variables can be used to control configure itself,
50 (and for which there is no equivalent build-time control):
51
52         XAPIAN_CONFIG   The program to use to determine flags for
53                         compiling and linking against the Xapian
54                         library. [$XAPIAN_CONFIG]
55
56 Additionally, various options can be specified on the configure
57 command line.
58
59         --prefix=PREFIX Install files in PREFIX [$PREFIX]
60
61 By default, "make install" will install the resulting program to
62 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
63 specify an installation prefix other than $PREFIX using
64 --prefix, for instance:
65
66         ./configure --prefix=\$HOME
67
68 Fine tuning of some installation directories is available:
69
70         --libdir=DIR    Install libraries in LIBDIR [PREFIX/lib]
71
72 EOF
73 }
74
75 # Parse command-line options
76 for option; do
77     if [ "${option}" = '--help' ] ; then
78         usage
79         exit 0
80     elif [ "${option%%=*}" = '--prefix' ] ; then
81         PREFIX="${option#*=}"
82     elif [ "${option%%=*}" = '--libdir' ] ; then
83         LIBDIR="${option#*=}"
84     else
85         echo "Unrecognized option: ${option}."
86         echo "See:"
87         echo "  $0 --help"
88         echo ""
89         exit 1
90     fi
91 done
92
93 cat <<EOF
94 Welcome to Notmuch, a system for indexing, searching and tagging your email.
95
96 We hope that the process of building and installing notmuch is quick
97 and smooth so that you can soon be reading and processing your email
98 more efficiently than ever.
99
100 If anything goes wrong in the configure process, you can override any
101 decisions it makes by manually editing the Makefile.config file that
102 it creates. Also please do as much as you can to figure out what could
103 be different on your machine compared to those of the notmuch
104 developers. Then, please email those details to the Notmuch list
105 (notmuch@notmuchmail.org) so that we can hopefully make future
106 versions of notmuch easier for you to use.
107
108 We'll now investigate your system to verify that all required
109 dependencies are available:
110
111 EOF
112
113 errors=0
114
115 if pkg-config --version > /dev/null 2>&1; then
116     have_pkg_config=1
117 else
118     have_pkg_config=0
119 fi
120
121 printf "Checking for Xapian development files... "
122 have_xapian=0
123 for xapian_config in ${XAPIAN_CONFIG}; do
124     if ${xapian_config} --version > /dev/null 2>&1; then
125         printf "Yes.\n"
126         have_xapian=1
127         xapian_cxxflags=$(${xapian_config} --cxxflags)
128         xapian_ldflags=$(${xapian_config} --libs)
129         break
130     fi
131 done
132 if [ ${have_xapian} = "0" ]; then
133     printf "No.\n"
134     errors=$((errors + 1))
135 fi
136
137 printf "Checking for GMime 2.4 development files... "
138 if pkg-config --modversion gmime-2.4 > /dev/null 2>&1; then
139     printf "Yes.\n"
140     have_gmime=1
141     gmime_cflags=$(pkg-config --cflags gmime-2.4)
142     gmime_ldflags=$(pkg-config --libs gmime-2.4)
143 else
144     printf "No.\n"
145     have_gmime=0
146     errors=$((errors + 1))
147 fi
148
149 printf "Checking for talloc development files... "
150 if pkg-config --modversion talloc > /dev/null 2>&1; then
151     printf "Yes.\n"
152     have_talloc=1
153     talloc_cflags=$(pkg-config --cflags talloc)
154     talloc_ldflags=$(pkg-config --libs talloc)
155 else
156     printf "No.\n"
157     have_talloc=0
158     talloc_cflags=
159     errors=$((errors + 1))
160 fi
161
162 printf "Checking for valgrind development files... "
163 if pkg-config --modversion valgrind > /dev/null 2>&1; then
164     printf "Yes.\n"
165     have_valgrind=1
166     valgrind_cflags=$(pkg-config --cflags valgrind)
167 else
168     printf "No (but that's fine).\n"
169     have_valgrind=0
170 fi
171
172 if pkg-config --modversion emacs > /dev/null 2>&1; then
173     emacs_lispdir=$(pkg-config emacs --variable sitepkglispdir)
174 else
175     emacs_lispdir='$(prefix)/share/emacs/site-lisp'
176 fi
177
178 printf "Checking if emacs is available... "
179 if emacs --quick --batch > /dev/null 2>&1; then
180     printf "Yes.\n"
181     have_emacs=1
182 else
183     printf "No (so will not byte-compile emacs code)\n"
184     have_emacs=0
185 fi
186
187 if [ $errors -gt 0 ]; then
188     cat <<EOF
189
190 *** Error: The dependencies of notmuch could not be satisfied. You will
191 need to install the following packages before being able to compile
192 notmuch:
193
194 EOF
195     if [ $have_xapian -eq 0 ]; then
196         echo "  Xapian library (including development files such as headers)"
197         echo "  http://xapian.org/"
198     fi
199     if [ $have_gmime -eq 0 ]; then
200         echo "  GMime 2.4 library (including development files such as headers)"
201         echo "  http://spruce.sourceforge.net/gmime/"
202     fi
203     if [ $have_talloc -eq 0 ]; then
204         echo "  The talloc library (including development files such as headers)"
205         echo "  http://talloc.samba.org/"
206     fi
207     cat <<EOF
208
209 With any luck, you're using a modern, package-based operating system
210 that has all of these packages available in the distribution. In that
211 case a simple command will install everything you need. For example:
212
213 On Debian and similar systems:
214
215         sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
216
217 Or on Fedora and similar systems:
218
219         sudo yum install xapian-core-devel gmime-devel libtalloc-devel
220
221 On other systems, similar commands can be used, but the details of the
222 package names may be different.
223
224 EOF
225     if [ $have_pkg_config -eq 0 ]; then
226 cat <<EOF
227 Note: the pkg-config program is not available. This configure script
228 uses pkg-config to find the compilation flags required to link against
229 the various libraries needed by notmuch. It's possible you simply need
230 to install pkg-config with a command such as:
231
232         sudo apt-get install pkg-config
233 Or:
234         sudo yum install pkgconfig
235
236 But if pkg-config is not available for your system, then you will need
237 to modify the configure script to manually set the cflags and ldflags
238 variables to the correct values to link against each library in each
239 case that pkg-config could not be used to determine those values.
240
241 EOF
242     fi
243 cat <<EOF
244 When you have installed the necessary dependencies, you can run
245 configure again to ensure the packages can be found, or simply run
246 "make" to compile notmuch.
247
248 EOF
249     exit 1
250 fi
251
252 printf "Checking for getline... "
253 if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
254 then
255     printf "Yes.\n"
256     have_getline=1
257 else
258     printf "No (will use our own instead).\n"
259     have_getline=0
260 fi
261 rm -f compat/have_getline
262
263 cat <<EOF
264
265 All required packages were found. You may now run the following
266 commands to compile and install notmuch:
267
268         make
269         sudo make install
270
271 EOF
272
273 # construct the Makefile.config
274 cat > Makefile.config <<EOF
275 # This Makefile.config was automatically generated by the ./configure
276 # script of notmuch. If the configure script identified anything
277 # incorrectly, then you can edit this file to try to correct things,
278 # but be warned that if configure is run again it will destroy your
279 # changes, (and this could happen by simply calling "make" if the
280 # configure script is updated).
281
282 # The C compiler to use
283 CC = ${CC}
284
285 # The C++ compiler to use
286 CXX = ${CXX}
287
288 # Command to execute emacs from Makefiles
289 EMACS = emacs --quick
290
291 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
292 CFLAGS = ${CFLAGS}
293
294 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
295 CXXFLAGS = ${CXXFLAGS}
296
297 # Flags to enable warnings when using the C++ compiler
298 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
299
300 # Flags to enable warnings when using the C compiler
301 WARN_CFLAGS=\$(WARN_CXXFLAGS) -Wmissing-declarations
302
303 # The prefix to which notmuch should be installed
304 prefix = ${PREFIX}
305
306 # The directory to which notmuch libraries should be installed
307 libdir = ${LIBDIR:=\$(prefix)/lib}
308
309 # The directory to which emacs lisp files should be installed
310 emacs_lispdir=${emacs_lispdir}
311
312 # Whether there's an emacs binary available for byte-compiling
313 HAVE_EMACS = ${have_emacs}
314
315 # The directory to which desktop files should be installed
316 desktop_dir = \$(prefix)/share/applications
317
318 # The directory to which bash completions files should be installed
319 bash_completion_dir = /etc/bash_completion.d
320
321 # The directory to which zsh completions files should be installed
322 zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
323
324 # Whether the getline function is available (if not, then notmuch will
325 # build its own version)
326 HAVE_GETLINE = ${have_getline}
327
328 # Flags needed to compile and link against Xapian
329 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
330 XAPIAN_LDFLAGS = ${xapian_ldflags}
331
332 # Flags needed to compile and link against GMime-2.4
333 GMIME_CFLAGS = ${gmime_cflags}
334 GMIME_LDFLAGS = ${gmime_ldflags}
335
336 # Flags needed to compile and link against talloc
337 TALLOC_CFLAGS = ${talloc_cflags}
338 TALLOC_LDFLAGS = ${talloc_ldflags}
339
340 # Whether valgrind header files are available
341 HAVE_VALGRIND = ${have_valgrind}
342
343 # And if so, flags needed at compile time for valgrind macros
344 VALGRIND_CFLAGS = ${valgrind_cflags}
345
346 # Combined flags for compiling and linking against all of the above
347 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
348                    \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
349                    \$(VALGRIND_CFLAGS)
350 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
351                      \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
352                      \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)
353 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
354 EOF