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