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