]> git.notmuchmail.org Git - notmuch/blob - configure
Merge branch '0.3.x' immediately after the 0.3.1 release
[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 to DIR [PREFIX/lib]
71         --includedir=DIR        Install header files to DIR [PREFIX/include]
72         --mandir=DIR            Install man pages to DIR [PREFIX/share/man]
73         --sysconfdir=DIR        Read-only single-machine data [PREFIX/etc]
74         --emacslispdir=DIR      Emacs code [PREFIX/share/emacs/site-lisp]
75
76 Additional options are accepted for compatibility with other
77 configure-script calling conventions, but don't do anything yet:
78
79         --build=<cpu>-<vendor>-<os>     Currently ignored
80         --host=<cpu>-<vendor>-<os>      Currently ignored
81         --infodir=DIR                   Currently ignored
82         --datadir=DIR                   Currently ignored
83         --localstatedir=DIR             Currently ignored
84         --libexecdir=DIR                Currently ignored
85         --disable-maintainer-mode       Currently ignored
86         --disable-dependency-tracking   Currently ignored
87
88 EOF
89 }
90
91 # Parse command-line options
92 for option; do
93     if [ "${option}" = '--help' ] ; then
94         usage
95         exit 0
96     elif [ "${option%%=*}" = '--prefix' ] ; then
97         PREFIX="${option#*=}"
98     elif [ "${option%%=*}" = '--libdir' ] ; then
99         LIBDIR="${option#*=}"
100     elif [ "${option%%=*}" = '--includedir' ] ; then
101         INCLUDEDIR="${option#*=}"
102     elif [ "${option%%=*}" = '--mandir' ] ; then
103         MANDIR="${option#*=}"
104     elif [ "${option%%=*}" = '--sysconfdir' ] ; then
105         SYSCONFDIR="${option#*=}"
106     elif [ "${option%%=*}" = '--emacslispdir' ] ; then
107         EMACSLISPDIR="${option#*=}"
108     elif [ "${option%%=*}" = '--build' ] ; then
109         build_option="${option#*=}"
110         case ${build_option} in
111             *-*-*) ;;
112             *)
113                 echo "Unrecognized value for --build option: ${build_option}"
114                 echo "Should be: <cpu>-<vendor>-<os>"
115                 echo "See:"
116                 echo "  $0 --help"
117                 echo ""
118                 exit 1
119         esac
120         build_cpu=${build_option%%-*}
121         build_option=${build_option#*-}
122         build_vendor=${build_option%%-*}
123         build_os=${build_option#*-}
124     elif [ "${option%%=*}" = '--host' ] ; then
125         host_option="${option#*=}"
126         case ${host_option} in
127             *-*-*) ;;
128             *)
129                 echo "Unrecognized value for --host option: ${host_option}"
130                 echo "Should be: <cpu>-<vendor>-<os>"
131                 echo "See:"
132                 echo "  $0 --help"
133                 echo ""
134                 exit 1
135         esac
136         host_cpu=${host_option%%-*}
137         host_option=${host_option#*-}
138         host_vendor=${host_option%%-*}
139         host_os=${host_option#*-}
140     elif [ "${option%%=*}" = '--infodir' ] ; then
141         true
142     elif [ "${option%%=*}" = '--datadir' ] ; then
143         true
144     elif [ "${option%%=*}" = '--localstatedir' ] ; then
145         true
146     elif [ "${option%%=*}" = '--libexecdir' ] ; then
147         true
148     elif [ "${option}" = '--disable-maintainer-mode' ] ; then
149         true
150     elif [ "${option}" = '--disable-dependency-tracking' ] ; then
151         true
152     else
153         echo "Unrecognized option: ${option}"
154         echo "See:"
155         echo "  $0 --help"
156         echo ""
157         exit 1
158     fi
159 done
160
161 cat <<EOF
162 Welcome to Notmuch, a system for indexing, searching and tagging your email.
163
164 We hope that the process of building and installing notmuch is quick
165 and smooth so that you can soon be reading and processing your email
166 more efficiently than ever.
167
168 If anything goes wrong in the configure process, you can override any
169 decisions it makes by manually editing the Makefile.config file that
170 it creates. Also please do as much as you can to figure out what could
171 be different on your machine compared to those of the notmuch
172 developers. Then, please email those details to the Notmuch list
173 (notmuch@notmuchmail.org) so that we can hopefully make future
174 versions of notmuch easier for you to use.
175
176 We'll now investigate your system to verify that all required
177 dependencies are available:
178
179 EOF
180
181 errors=0
182
183 if pkg-config --version > /dev/null 2>&1; then
184     have_pkg_config=1
185 else
186     have_pkg_config=0
187 fi
188
189 printf "Checking for Xapian development files... "
190 have_xapian=0
191 for xapian_config in ${XAPIAN_CONFIG}; do
192     if ${xapian_config} --version > /dev/null 2>&1; then
193         printf "Yes (%s).\n" $(${xapian_config} --version | sed -e 's/.* //')
194         have_xapian=1
195         xapian_cxxflags=$(${xapian_config} --cxxflags)
196         xapian_ldflags=$(${xapian_config} --libs)
197         break
198     fi
199 done
200 if [ ${have_xapian} = "0" ]; then
201     printf "No.\n"
202     errors=$((errors + 1))
203 fi
204
205 printf "Checking for GMime development files... "
206 have_gmime=0
207 for gmimepc in gmime-2.6 gmime-2.4; do
208     if pkg-config --modversion $gmimepc > /dev/null 2>&1; then
209         printf "Yes ($gmimepc).\n"
210         have_gmime=1
211         gmime_cflags=$(pkg-config --cflags $gmimepc)
212         gmime_ldflags=$(pkg-config --libs $gmimepc)
213     fi
214 done
215 if [ "$have_gmime" = "0" ]; then
216     printf "No.\n"
217     errors=$((errors + 1))
218 fi
219
220 printf "Checking for talloc development files... "
221 if pkg-config --modversion talloc > /dev/null 2>&1; then
222     printf "Yes.\n"
223     have_talloc=1
224     talloc_cflags=$(pkg-config --cflags talloc)
225     talloc_ldflags=$(pkg-config --libs talloc)
226 else
227     printf "No.\n"
228     have_talloc=0
229     talloc_cflags=
230     errors=$((errors + 1))
231 fi
232
233 printf "Checking for valgrind development files... "
234 if pkg-config --modversion valgrind > /dev/null 2>&1; then
235     printf "Yes.\n"
236     have_valgrind=1
237     valgrind_cflags=$(pkg-config --cflags valgrind)
238 else
239     printf "No (but that's fine).\n"
240     have_valgrind=0
241 fi
242
243 if [ -z "${EMACSLISPDIR}" ]; then
244     if pkg-config --modversion emacs > /dev/null 2>&1; then
245         EMACSLISPDIR=$(pkg-config emacs --variable sitepkglispdir)
246     else
247         EMACSLISPDIR='$(prefix)/share/emacs/site-lisp'
248     fi
249 fi
250
251 printf "Checking if emacs is available... "
252 if emacs --quick --batch > /dev/null 2>&1; then
253     printf "Yes.\n"
254     have_emacs=1
255 else
256     printf "No (so will not byte-compile emacs code)\n"
257     have_emacs=0
258 fi
259
260 printf "Checking for Mac OS X (for shared library)... "
261 if [ `uname` = "Darwin" ] ; then
262     printf "Yes.\n"
263     mac_os_x=1
264     linker_resolves_library_dependencies=0
265 else
266     printf "No.\n"
267     mac_os_x=0
268     linker_resolves_library_dependencies=1
269 fi
270
271 if [ $errors -gt 0 ]; then
272     cat <<EOF
273
274 *** Error: The dependencies of notmuch could not be satisfied. You will
275 need to install the following packages before being able to compile
276 notmuch:
277
278 EOF
279     if [ $have_xapian -eq 0 ]; then
280         echo "  Xapian library (including development files such as headers)"
281         echo "  http://xapian.org/"
282     fi
283     if [ $have_gmime -eq 0 ]; then
284         echo "  GMime 2.4 library (including development files such as headers)"
285         echo "  http://spruce.sourceforge.net/gmime/"
286     fi
287     if [ $have_talloc -eq 0 ]; then
288         echo "  The talloc library (including development files such as headers)"
289         echo "  http://talloc.samba.org/"
290     fi
291     cat <<EOF
292
293 With any luck, you're using a modern, package-based operating system
294 that has all of these packages available in the distribution. In that
295 case a simple command will install everything you need. For example:
296
297 On Debian and similar systems:
298
299         sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
300
301 Or on Fedora and similar systems:
302
303         sudo yum install xapian-core-devel gmime-devel libtalloc-devel
304
305 On other systems, similar commands can be used, but the details of the
306 package names may be different.
307
308 EOF
309     if [ $have_pkg_config -eq 0 ]; then
310 cat <<EOF
311 Note: the pkg-config program is not available. This configure script
312 uses pkg-config to find the compilation flags required to link against
313 the various libraries needed by notmuch. It's possible you simply need
314 to install pkg-config with a command such as:
315
316         sudo apt-get install pkg-config
317 Or:
318         sudo yum install pkgconfig
319
320 But if pkg-config is not available for your system, then you will need
321 to modify the configure script to manually set the cflags and ldflags
322 variables to the correct values to link against each library in each
323 case that pkg-config could not be used to determine those values.
324
325 EOF
326     fi
327 cat <<EOF
328 When you have installed the necessary dependencies, you can run
329 configure again to ensure the packages can be found, or simply run
330 "make" to compile notmuch.
331
332 EOF
333     exit 1
334 fi
335
336 printf "Checking for getline... "
337 if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
338 then
339     printf "Yes.\n"
340     have_getline=1
341 else
342     printf "No (will use our own instead).\n"
343     have_getline=0
344 fi
345 rm -f compat/have_getline
346
347 printf "Checking for strcasestr... "
348 if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
349 then
350     printf "Yes.\n"
351     have_strcasestr=1
352 else
353     printf "No (will use our own instead).\n"
354     have_strcasestr=0
355 fi
356 rm -f compat/have_strcasestr
357
358 cat <<EOF
359
360 All required packages were found. You may now run the following
361 commands to compile and install notmuch:
362
363         make
364         sudo make install
365
366 EOF
367
368 # construct the Makefile.config
369 cat > Makefile.config <<EOF
370 # This Makefile.config was automatically generated by the ./configure
371 # script of notmuch. If the configure script identified anything
372 # incorrectly, then you can edit this file to try to correct things,
373 # but be warned that if configure is run again it will destroy your
374 # changes, (and this could happen by simply calling "make" if the
375 # configure script is updated).
376
377 # The C compiler to use
378 CC = ${CC}
379
380 # The C++ compiler to use
381 CXX = ${CXX}
382
383 # Command to execute emacs from Makefiles
384 EMACS = emacs --quick
385
386 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
387 CFLAGS = ${CFLAGS}
388
389 # Default FLAGS for C++ compiler (can be overridden by user such as "make CXXFLAGS=-g")
390 CXXFLAGS = ${CXXFLAGS}
391
392 # Flags to enable warnings when using the C++ compiler
393 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
394
395 # Flags to enable warnings when using the C compiler
396 WARN_CFLAGS=\$(WARN_CXXFLAGS) -Wmissing-declarations
397
398 # The prefix to which notmuch should be installed
399 prefix = ${PREFIX}
400
401 # The directory to which libraries should be installed
402 libdir = ${LIBDIR:=\$(prefix)/lib}
403
404 # The directory to which header files should be installed
405 includedir = ${INCLUDEDIR:=\$(prefix)/include}
406
407 # The directory to which man pages should be installed
408 mandir = ${MANDIR:=\$(prefix)/share/man}
409
410 # The directory to which read-only (configuration) filesshould be installed
411 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
412
413 # The directory to which emacs lisp files should be installed
414 emacslispdir=${EMACSLISPDIR}
415
416 # Whether there's an emacs binary available for byte-compiling
417 HAVE_EMACS = ${have_emacs}
418
419 # The directory to which desktop files should be installed
420 desktop_dir = \$(prefix)/share/applications
421
422 # The directory to which bash completions files should be installed
423 bash_completion_dir = \$(sysconfdir)/bash_completion.d
424
425 # The directory to which zsh completions files should be installed
426 zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
427
428 # Whether the getline function is available (if not, then notmuch will
429 # build its own version)
430 HAVE_GETLINE = ${have_getline}
431
432 # Whether the strcasestr function is available (if not, then notmuch will
433 # build its own version)
434 HAVE_STRCASESTR = ${have_strcasestr}
435
436 # Whether we are building on OS X.  This will affect how we build the
437 # shared library.
438 MAC_OS_X = ${mac_os_x}
439
440 # Whether the linker will automatically resolve the dependency of one
441 # library on another (if not, then linking a binary requires linking
442 # directly against both)
443 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
444
445 # Flags needed to compile and link against Xapian
446 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
447 XAPIAN_LDFLAGS = ${xapian_ldflags}
448
449 # Flags needed to compile and link against GMime-2.4
450 GMIME_CFLAGS = ${gmime_cflags}
451 GMIME_LDFLAGS = ${gmime_ldflags}
452
453 # Flags needed to compile and link against talloc
454 TALLOC_CFLAGS = ${talloc_cflags}
455 TALLOC_LDFLAGS = ${talloc_ldflags}
456
457 # Whether valgrind header files are available
458 HAVE_VALGRIND = ${have_valgrind}
459
460 # And if so, flags needed at compile time for valgrind macros
461 VALGRIND_CFLAGS = ${valgrind_cflags}
462
463 # Combined flags for compiling and linking against all of the above
464 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
465                    \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
466                    \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
467 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
468                      \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
469                      \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
470                      -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
471 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
472 EOF