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