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