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