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