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