Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / e6 / fbe9dd333692b8df51eab871ff6906deedb120
1 Return-Path: <jeff@ocjtech.us>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 28B3E431FBC\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 05:47:25 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id gXAYGLVMsW09 for <notmuch@notmuchmail.org>;\r
11         Sun, 22 Nov 2009 05:47:23 -0800 (PST)\r
12 Received: from mail-yx0-f204.google.com (mail-yx0-f204.google.com\r
13         [209.85.210.204])\r
14         by olra.theworths.org (Postfix) with ESMTP id C0824431FAE\r
15         for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 05:47:23 -0800 (PST)\r
16 Received: by yxe42 with SMTP id 42so4759357yxe.22\r
17         for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 05:47:23 -0800 (PST)\r
18 Received: by 10.150.5.35 with SMTP id 35mr6517765ybe.84.1258897643335;\r
19         Sun, 22 Nov 2009 05:47:23 -0800 (PST)\r
20 Received: from lt26923.campus.dmacc.edu ([69.57.47.215])\r
21         by mx.google.com with ESMTPS id 13sm1625198gxk.1.2009.11.22.05.47.20\r
22         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
23         Sun, 22 Nov 2009 05:47:21 -0800 (PST)\r
24 Received: from localhost ([127.0.0.1] helo=localhost.localdomain)\r
25         by lt26923.campus.dmacc.edu with esmtps (TLSv1:AES256-SHA:256)\r
26         (Exim 4.69) (envelope-from <jeff@ocjtech.us>)\r
27         id 1NCCmc-0005o7-PG; Sun, 22 Nov 2009 07:47:18 -0600\r
28 From: "Jeffrey C. Ollie" <jeff@ocjtech.us>\r
29 To: Not Much Mail <notmuch@notmuchmail.org>\r
30 Date: Sun, 22 Nov 2009 07:47:10 -0600\r
31 Message-Id: <1258897630-22282-1-git-send-email-jeff@ocjtech.us>\r
32 X-Mailer: git-send-email 1.6.5.2\r
33 Subject: [notmuch] [PATCH] Add SCons build files.\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.12\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38         <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sun, 22 Nov 2009 13:47:25 -0000\r
47 \r
48 The SCons build files included here *should* do everything that the\r
49 current Makefiles do, plus a little bit of configuration checking.  To\r
50 build/install:\r
51 \r
52 scons all emacs\r
53 sudo scons install\r
54 sudo scons install-emacs\r
55 sudo scons install-desktop\r
56 \r
57 Various installation directories can be customized:\r
58 \r
59 sudo scons install DESTDIR=/tmp/buildroot prefix=/opt/notmuch\r
60 \r
61 See the output of 'scons -h' for a complete list of the variables that\r
62 can be modified.\r
63 \r
64 Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>\r
65 ---\r
66  .gitignore     |    3 +\r
67  SConstruct     |  226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
68  lib/SConscript |   19 +++++\r
69  3 files changed, 248 insertions(+), 0 deletions(-)\r
70  create mode 100644 SConstruct\r
71  create mode 100644 lib/SConscript\r
72 \r
73 diff --git a/.gitignore b/.gitignore\r
74 index 8794354..6661b3b 100644\r
75 --- a/.gitignore\r
76 +++ b/.gitignore\r
77 @@ -8,3 +8,6 @@ notmuch.1.gz\r
78  *~\r
79  .*.swp\r
80  *.elc\r
81 +.sconsign.dblite\r
82 +.sconf_temp\r
83 +config.log\r
84 diff --git a/SConstruct b/SConstruct\r
85 new file mode 100644\r
86 index 0000000..8d6960d\r
87 --- /dev/null\r
88 +++ b/SConstruct\r
89 @@ -0,0 +1,226 @@\r
90 +# -*- mode: python; coding: utf-8 -*-\r
91 +\r
92 +import os\r
93 +\r
94 +variables = Variables('custom.py')\r
95 +\r
96 +variables.Add('DESTDIR',\r
97 +              'Destination directory',\r
98 +              '')\r
99 +\r
100 +variables.Add('prefix',\r
101 +              'Installation prefix',\r
102 +              '/usr/local')\r
103 +\r
104 +variables.Add('bindir',\r
105 +              'Directory that user binaries go into',\r
106 +              '${prefix}/bin')\r
107 +\r
108 +variables.Add('datadir',\r
109 +              'Directory that static data files go into',\r
110 +              '${prefix}/share')\r
111 +\r
112 +variables.Add('mandir',\r
113 +              'Directory that manual pages go into',\r
114 +              '${datadir}/man')\r
115 +\r
116 +variables.Add('emacs_lispdir',\r
117 +              'Directory that Emacs LISP files go into',\r
118 +              '${default_emacs_lispdir}')\r
119 +\r
120 +variables.Add('sysconfdir',\r
121 +              'Directory that system configuration files go into',\r
122 +              '/etc')\r
123 +\r
124 +variables.Add('bash_completion_dir',\r
125 +              'Directory that Bash completion files go into',\r
126 +              '${sysconfdir}/bash_completion.d')\r
127 +\r
128 +variables.Add('desktop_dir',\r
129 +              'Directory that desktop files go into',\r
130 +              '${datadir}/applications')\r
131 +\r
132 +variables.Add('gzip',\r
133 +              'Gzip executable',\r
134 +              'gzip')\r
135 +\r
136 +variables.Add('emacs',\r
137 +              'Emacs executable',\r
138 +              'emacs')\r
139 +\r
140 +def InstallPerm(env, dest, files, perm):\r
141 +    obj = env.Install(dest, files)\r
142 +    for i in obj:\r
143 +        env.AddPostAction(i, Chmod(str(i), perm))\r
144 +    return dest\r
145 +\r
146 +def InstallAsPerm(env, dest, files, perm):\r
147 +    obj = env.InstallAs(dest, files)\r
148 +    for i in obj:\r
149 +        env.AddPostAction(i, Chmod(str(i), perm))\r
150 +    return dest\r
151 +\r
152 +topenv = Environment(variables = variables,\r
153 +                     BUILDERS = {'InstallPerm': InstallPerm,\r
154 +                                 'InstallAsPerm': InstallAsPerm})\r
155 +\r
156 +topenv.Append(CPPPATH=['#/lib'])\r
157 +\r
158 +cflags = None\r
159 +if os.environ.has_key('CFLAGS'):\r
160 +    cflags = topenv.ParseFlags(os.environ['CFLAGS'])\r
161 +    topenv.MergeFlags(cflags)\r
162 +\r
163 +if os.environ.has_key('CXXFLAGS'):\r
164 +    cxxflags = topenv.ParseFlags(os.environ['CXXFLAGS'])\r
165 +    topenv.MergeFlags(cxxflags)\r
166 +\r
167 +if cflags is None or cxxflags is None:\r
168 +    optflags = topenv.ParseFlags('-O2')\r
169 +    topenv.MergeFlags(optflags)\r
170 +\r
171 +warnflags = topenv.ParseFlags('-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum')\r
172 +topenv.MergeFlags(warnflags)\r
173 +\r
174 +def CheckPkgConfig(context, version):\r
175 +    context.Message('Checking for pkg-config... ')\r
176 +    result = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]\r
177 +    context.Result(result)\r
178 +    return result\r
179\r
180 +def CheckPkg(context, name):\r
181 +    context.Message('Checking for %s... ' % name)\r
182 +    result = context.TryAction('pkg-config --exists \'%s\'' % name)[0]\r
183 +    context.Result(result)\r
184 +    return result\r
185 +\r
186 +def CheckXapian(context):\r
187 +    context.Message('Checking for xapian-core... ')\r
188 +    for xapian_config in ['xapian-config-1.1', 'xapian-config']:\r
189 +        result, output = context.TryAction('%s --version > $TARGET' % xapian_config)\r
190 +        if result:\r
191 +            xapian_version = output.strip().split()[-1]\r
192 +            context.env['xapian_config'] = xapian_config\r
193 +            context.env['xapian_version'] = xapian_version\r
194 +            context.Result(xapian_version)\r
195 +            return result\r
196 +    context.Result(False)\r
197 +    return False\r
198 +\r
199 +def CheckEmacs(context):\r
200 +    context.Message('Checking for emacs... ')\r
201 +    context.env['default_emacs_lispdir'] = '${prefix}/share/emacs/site-lisp'\r
202 +    result = context.TryAction('pkg-config --exists emacs')\r
203 +    if result:\r
204 +        result, output = context.TryAction('pkg-config emacs --variable sitepkglispdir > $TARGET')\r
205 +        if result:\r
206 +            context.env['default_emacs_lispdir'] = output.strip()\r
207 +        context.Result(True)\r
208 +        return True\r
209 +    context.Result(False)\r
210 +    return False\r
211 +\r
212 +def CheckDesktopFileInstall(context):\r
213 +    context.Message('Checking for desktop-file-install... ')\r
214 +    result = context.TryAction('desktop-file-install -h')[0]\r
215 +    context.Result(result)\r
216 +    return result\r
217 +\r
218 +conf = Configure(topenv, custom_tests = {'CheckPkgConfig': CheckPkgConfig,\r
219 +                                         'CheckPkg': CheckPkg,\r
220 +                                         'CheckXapian': CheckXapian,\r
221 +                                         'CheckEmacs': CheckEmacs,\r
222 +                                         'CheckDesktopFileInstall': CheckDesktopFileInstall})\r
223 +\r
224 +if not conf.CheckPkgConfig('0.23'):\r
225 +    print 'pkg-config >= 0.23 not found.'\r
226 +    Exit(1)\r
227 +\r
228 +if not conf.CheckPkg('glib-2.0 >= 2.22'):\r
229 +    print 'glib-2.0 >= 2.22 not found'\r
230 +    Exit(1)\r
231 +\r
232 +if not conf.CheckPkg('gmime-2.4 >= 2.4.0'):\r
233 +    print 'gmime-2.4 >= 2.4.0 not found'\r
234 +    Exit(1)\r
235 +\r
236 +if not conf.CheckPkg('talloc >= 2.0.0'):\r
237 +    print 'talloc >= 2.0.0 not found'\r
238 +    Exit(1)\r
239 +\r
240 +if not conf.CheckXapian():\r
241 +    print 'xapian not found'\r
242 +    Exit(1)\r
243 +\r
244 +emacs = conf.CheckEmacs()\r
245 +\r
246 +valgrind = conf.CheckPkg('valgrind >= 3.5.0')\r
247 +\r
248 +desktop = conf.CheckDesktopFileInstall()\r
249 +\r
250 +if not conf.CheckFunc('strndup'):\r
251 +    conf.env.Append(CPPDEFINES = ['NEED_STRNDUP'])\r
252 +\r
253 +if not conf.CheckFunc('getline'):\r
254 +    conf.env.Append(CPPDEFINES = ['NEED_GETLINE'])\r
255 +\r
256 +topenv = conf.Finish()\r
257 +\r
258 +topenv.ParseConfig('pkg-config glib-2.0 --cflags --libs')\r
259 +topenv.ParseConfig('pkg-config gmime-2.4 --cflags --libs')\r
260 +topenv.ParseConfig('pkg-config talloc --cflags --libs')\r
261 +topenv.ParseConfig('${xapian_config} --cxxflags --libs')\r
262 +if valgrind:\r
263 +    topenv.ParseConfig('pkg-config valgrind --cflags')\r
264 +    topenv.Append(CPPDEFINES = ['HAVE_VALGRIND'])\r
265 +\r
266 +Help(variables.GenerateHelpText(topenv))\r
267 +\r
268 +Export('topenv')\r
269 +\r
270 +libnotmuch = SConscript(['lib/SConscript'])\r
271 +\r
272 +env = topenv.Clone()\r
273 +\r
274 +notmuch = env.Program('notmuch', ['debugger.c',\r
275 +                                  'gmime-filter-reply.c',\r
276 +                                  'notmuch.c',\r
277 +                                  'notmuch-config.c',\r
278 +                                  'notmuch-dump.c',\r
279 +                                  'notmuch-new.c',\r
280 +                                  'notmuch-reply.c',\r
281 +                                  'notmuch-restore.c',\r
282 +                                  'notmuch-search.c',\r
283 +                                  'notmuch-setup.c',\r
284 +                                  'notmuch-show.c',\r
285 +                                  'notmuch-tag.c',\r
286 +                                  'notmuch-time.c',\r
287 +                                  'query-string.c',\r
288 +                                  'show-message.c',\r
289 +                                  libnotmuch])\r
290 +env.Alias('all', notmuch)\r
291 +\r
292 +env.Install('${DESTDIR}${bindir}', notmuch)\r
293 +env.Alias('install', '${DESTDIR}${bindir}')\r
294 +\r
295 +manpage = env.Command('notmuch.1.gz', 'notmuch.1', '${gzip} -9 < $SOURCE > $TARGET')\r
296 +env.Alias('all', manpage)\r
297 +\r
298 +env.InstallPerm('${DESTDIR}${mandir}/man1', manpage, 0644)\r
299 +env.Alias('install', '${DESTDIR}${mandir}/man1')\r
300 +\r
301 +env.InstallAsPerm('${DESTDIR}${bash_completion_dir}/notmuch', 'contrib/notmuch-completion.bash', 0644)\r
302 +env.Alias('install', '${DESTDIR}${bash_completion_dir}')\r
303 +\r
304 +if desktop:\r
305 +    env.Command('${DESTDIR}${desktop_dir}/notmuch.desktop', 'notmuch.desktop', 'desktop-file-install --mode 0644 --dir ${DESTDIR}${desktop_dir} ${SOURCE}')\r
306 +    env.Alias('install-desktop', '${DESTDIR}${desktop_dir}')\r
307 +\r
308 +if emacs:\r
309 +    elisp = env.Command('notmuch.elc', 'notmuch.el', '${emacs} --no-window-system --no-site-file --no-init-file --no-splash --batch --funcall batch-byte-compile $SOURCE')\r
310 +    env.Alias('emacs', elisp)\r
311 +    env.InstallPerm('${DESTDIR}${emacs_lispdir}', elisp, 0644)\r
312 +    env.InstallPerm('${DESTDIR}${emacs_lispdir}', 'notmuch.el', 0644)\r
313 +    env.Alias('install-emacs', '${DESTDIR}${emacs_lispdir}')\r
314 +\r
315 +Default('all')\r
316 diff --git a/lib/SConscript b/lib/SConscript\r
317 new file mode 100644\r
318 index 0000000..eb38516\r
319 --- /dev/null\r
320 +++ b/lib/SConscript\r
321 @@ -0,0 +1,19 @@\r
322 +# -*- mode: python; coding: utf-8 -*-\r
323 +\r
324 +Import('topenv')\r
325 +\r
326 +env = topenv.Clone()\r
327 +\r
328 +libnotmuch = env.Library('notmuch', ['libsha1.c',\r
329 +                                     'message-file.c',\r
330 +                                     'messages.c',\r
331 +                                     'sha1.c',\r
332 +                                     'tags.c',\r
333 +                                     'xutil.c',\r
334 +                                     'database.cc',\r
335 +                                     'index.cc',\r
336 +                                     'message.cc',\r
337 +                                     'query.cc',\r
338 +                                     'thread.cc'])\r
339 +\r
340 +Return('libnotmuch')\r
341 -- \r
342 1.6.5.2\r
343 \r