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