]> git.notmuchmail.org Git - notmuch/blob - configure
Makefile: Switch from echo to printf for better portability.
[notmuch] / configure
1 #! /bin/sh
2
3 cat <<EOF
4 Welcome to Notmuch, a system for indexing, searching and tagging your email.
5
6 We hope that the process of building and installing notmuch is quick
7 and smooth so that you can soon be reading and processing your email
8 more efficiently than ever.
9
10 If anything goes wrong in the configure process, you can override any
11 decisions it makes by manually editing the Makefile.config file that
12 it creates. Also please do as much as you can to figure out what could
13 be different on your machine compared to those of the notmuch
14 developers. Then, please email those details to the Notmuch list
15 (notmuch@notmuchmail.org) so that we can hopefully make future
16 versions of notmuch easier for you to use.
17
18 We'll now investigate your system to verify that all required
19 dependencies are available:
20
21 EOF
22
23 errors=0
24
25 if pkg-config --version > /dev/null 2>&1; then
26     have_pkg_config=1
27 else
28     have_pkg_config=0
29 fi
30
31 printf "Checking for Xapian development files... "
32 if xapian-config --version > /dev/null 2>&1; then
33     printf "Yes.\n"
34     have_xapian=1
35 else
36     printf "No.\n"
37     have_xapian=0
38     errors=$((errors + 1))
39 fi
40
41 printf "Checking for GMime 2.4 development files... "
42 if pkg-config --modversion gmime-2.4 > /dev/null 2>&1; then
43     printf "Yes.\n"
44     have_gmime=1
45 else
46     printf "No.\n"
47     have_gmime=0
48     errors=$((errors + 1))
49 fi
50
51 printf "Checking for talloc development files... "
52 if pkg-config --modversion talloc > /dev/null 2>&1; then
53     printf "Yes.\n"
54     have_talloc=1
55 else
56     printf "No.\n"
57     have_talloc=0
58     errors=$((errors + 1))
59 fi
60
61 printf "Checking for valgrind development files... "
62 if pkg-config --modversion valgrind > /dev/null 2>&1; then
63     printf "Yes.\n"
64     have_valgrind=1
65     valgrind_flags=$(pkg-config --cflags valgrind)
66 else
67     printf "No (but that's fine).\n"
68     have_valgrind=0
69     valgrind_flags=
70 fi
71
72 if [ $errors -gt 0 ]; then
73     cat <<EOF
74
75 *** Error: The dependencies of notmuch could not be satisfied. You will
76 need to install the following packages before being able to compile
77 notmuch:
78
79 EOF
80     if [ $have_xapian -eq 0 ]; then
81         echo "  Xapian library (including development files such as headers)"
82         echo "  http://xapian.org/"
83     fi
84     if [ $have_gmime -eq 0 ]; then
85         echo "  GMime 2.4 library (including development files such as headers)"
86         echo "  http://spruce.sourceforge.net/gmime/"
87     fi
88     if [ $have_talloc -eq 0 ]; then
89         echo "  The talloc library (including development files such as headers)"
90         echo "  http://talloc.samba.org/"
91     fi
92     cat <<EOF
93
94 On a modern, package-based operating system such as Debian, you can
95 install all of the dependencies with the following simple command
96 line:
97
98         sudo apt-get install libxapian-dev libgmime-2.4-dev libtalloc-dev
99
100 On other systems, a similar command can be used, but the details of the 
101 package names may be different, (such as "devel" in place of "dev").
102
103 EOF
104     if [ $have_pkg_config -eq 0 ]; then
105 cat <<EOF
106 Note: the pkg-config program is not available. Both this configure
107 script and the Makefile of notmuch use pkg-config to find the
108 compilation flags required to link against the various libraries
109 needed by notmuch. It's possible you simply need to install pkg-config
110 with a command such as:
111
112         sudo apt-get install pkg-config
113
114 But if pkg-config is not available for your system, then you will need
115 to manually edit the notmuch Makefile to set the variables such as
116 CFLAGS and LDFLAGS to the correct values without calling pkg-config.
117
118 EOF
119     fi
120 cat <<EOF
121 When you have installed the necessary dependencies, you can run
122 configure again to ensure the packages can be found, or simply run
123 "make" to compile notmuch.
124
125 EOF
126     exit 1
127 fi
128
129 printf "Checking for getline... "
130 if ! gcc -o getlinetest getlinetest.c > /dev/null 2>&1
131 then
132     printf "No.\n"
133     have_getline=0
134 else
135     printf "Yes.\n"
136     have_getline=1
137 fi
138 rm -f getlinetest
139
140 cat <<EOF
141
142 All required packages were found. You may now run the following
143 commands to compile and install notmuch:
144
145         make
146         sudo make install
147
148 EOF
149
150 # construct the Makefile.config
151 cat > Makefile.config <<EOF
152 prefix = /usr/local
153 HAVE_GETLINE = ${have_getline}
154 override CFLAGS += -DHAVE_VALGRIND=${have_valgrind} ${valgrind_flags} -DHAVE_GETLINE=\$(HAVE_GETLINE)
155 EOF