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