unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Add SCons build files.
@ 2009-11-22 13:47 Jeffrey C. Ollie
  2009-11-22 14:15 ` Bart Trojanowski
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Jeffrey C. Ollie @ 2009-11-22 13:47 UTC (permalink / raw)
  To: Not Much Mail

The SCons build files included here *should* do everything that the
current Makefiles do, plus a little bit of configuration checking.  To
build/install:

scons all emacs
sudo scons install
sudo scons install-emacs
sudo scons install-desktop

Various installation directories can be customized:

sudo scons install DESTDIR=/tmp/buildroot prefix=/opt/notmuch

See the output of 'scons -h' for a complete list of the variables that
can be modified.

Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
---
 .gitignore     |    3 +
 SConstruct     |  226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/SConscript |   19 +++++
 3 files changed, 248 insertions(+), 0 deletions(-)
 create mode 100644 SConstruct
 create mode 100644 lib/SConscript

diff --git a/.gitignore b/.gitignore
index 8794354..6661b3b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,6 @@ notmuch.1.gz
 *~
 .*.swp
 *.elc
+.sconsign.dblite
+.sconf_temp
+config.log
diff --git a/SConstruct b/SConstruct
new file mode 100644
index 0000000..8d6960d
--- /dev/null
+++ b/SConstruct
@@ -0,0 +1,226 @@
+# -*- mode: python; coding: utf-8 -*-
+
+import os
+
+variables = Variables('custom.py')
+
+variables.Add('DESTDIR',
+              'Destination directory',
+              '')
+
+variables.Add('prefix',
+              'Installation prefix',
+              '/usr/local')
+
+variables.Add('bindir',
+              'Directory that user binaries go into',
+              '${prefix}/bin')
+
+variables.Add('datadir',
+              'Directory that static data files go into',
+              '${prefix}/share')
+
+variables.Add('mandir',
+              'Directory that manual pages go into',
+              '${datadir}/man')
+
+variables.Add('emacs_lispdir',
+              'Directory that Emacs LISP files go into',
+              '${default_emacs_lispdir}')
+
+variables.Add('sysconfdir',
+              'Directory that system configuration files go into',
+              '/etc')
+
+variables.Add('bash_completion_dir',
+              'Directory that Bash completion files go into',
+              '${sysconfdir}/bash_completion.d')
+
+variables.Add('desktop_dir',
+              'Directory that desktop files go into',
+              '${datadir}/applications')
+
+variables.Add('gzip',
+              'Gzip executable',
+              'gzip')
+
+variables.Add('emacs',
+              'Emacs executable',
+              'emacs')
+
+def InstallPerm(env, dest, files, perm):
+    obj = env.Install(dest, files)
+    for i in obj:
+        env.AddPostAction(i, Chmod(str(i), perm))
+    return dest
+
+def InstallAsPerm(env, dest, files, perm):
+    obj = env.InstallAs(dest, files)
+    for i in obj:
+        env.AddPostAction(i, Chmod(str(i), perm))
+    return dest
+
+topenv = Environment(variables = variables,
+                     BUILDERS = {'InstallPerm': InstallPerm,
+                                 'InstallAsPerm': InstallAsPerm})
+
+topenv.Append(CPPPATH=['#/lib'])
+
+cflags = None
+if os.environ.has_key('CFLAGS'):
+    cflags = topenv.ParseFlags(os.environ['CFLAGS'])
+    topenv.MergeFlags(cflags)
+
+if os.environ.has_key('CXXFLAGS'):
+    cxxflags = topenv.ParseFlags(os.environ['CXXFLAGS'])
+    topenv.MergeFlags(cxxflags)
+
+if cflags is None or cxxflags is None:
+    optflags = topenv.ParseFlags('-O2')
+    topenv.MergeFlags(optflags)
+
+warnflags = topenv.ParseFlags('-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum')
+topenv.MergeFlags(warnflags)
+
+def CheckPkgConfig(context, version):
+    context.Message('Checking for pkg-config... ')
+    result = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
+    context.Result(result)
+    return result
+ 
+def CheckPkg(context, name):
+    context.Message('Checking for %s... ' % name)
+    result = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
+    context.Result(result)
+    return result
+
+def CheckXapian(context):
+    context.Message('Checking for xapian-core... ')
+    for xapian_config in ['xapian-config-1.1', 'xapian-config']:
+        result, output = context.TryAction('%s --version > $TARGET' % xapian_config)
+        if result:
+            xapian_version = output.strip().split()[-1]
+            context.env['xapian_config'] = xapian_config
+            context.env['xapian_version'] = xapian_version
+            context.Result(xapian_version)
+            return result
+    context.Result(False)
+    return False
+
+def CheckEmacs(context):
+    context.Message('Checking for emacs... ')
+    context.env['default_emacs_lispdir'] = '${prefix}/share/emacs/site-lisp'
+    result = context.TryAction('pkg-config --exists emacs')
+    if result:
+        result, output = context.TryAction('pkg-config emacs --variable sitepkglispdir > $TARGET')
+        if result:
+            context.env['default_emacs_lispdir'] = output.strip()
+        context.Result(True)
+        return True
+    context.Result(False)
+    return False
+
+def CheckDesktopFileInstall(context):
+    context.Message('Checking for desktop-file-install... ')
+    result = context.TryAction('desktop-file-install -h')[0]
+    context.Result(result)
+    return result
+
+conf = Configure(topenv, custom_tests = {'CheckPkgConfig': CheckPkgConfig,
+                                         'CheckPkg': CheckPkg,
+                                         'CheckXapian': CheckXapian,
+                                         'CheckEmacs': CheckEmacs,
+                                         'CheckDesktopFileInstall': CheckDesktopFileInstall})
+
+if not conf.CheckPkgConfig('0.23'):
+    print 'pkg-config >= 0.23 not found.'
+    Exit(1)
+
+if not conf.CheckPkg('glib-2.0 >= 2.22'):
+    print 'glib-2.0 >= 2.22 not found'
+    Exit(1)
+
+if not conf.CheckPkg('gmime-2.4 >= 2.4.0'):
+    print 'gmime-2.4 >= 2.4.0 not found'
+    Exit(1)
+
+if not conf.CheckPkg('talloc >= 2.0.0'):
+    print 'talloc >= 2.0.0 not found'
+    Exit(1)
+
+if not conf.CheckXapian():
+    print 'xapian not found'
+    Exit(1)
+
+emacs = conf.CheckEmacs()
+
+valgrind = conf.CheckPkg('valgrind >= 3.5.0')
+
+desktop = conf.CheckDesktopFileInstall()
+
+if not conf.CheckFunc('strndup'):
+    conf.env.Append(CPPDEFINES = ['NEED_STRNDUP'])
+
+if not conf.CheckFunc('getline'):
+    conf.env.Append(CPPDEFINES = ['NEED_GETLINE'])
+
+topenv = conf.Finish()
+
+topenv.ParseConfig('pkg-config glib-2.0 --cflags --libs')
+topenv.ParseConfig('pkg-config gmime-2.4 --cflags --libs')
+topenv.ParseConfig('pkg-config talloc --cflags --libs')
+topenv.ParseConfig('${xapian_config} --cxxflags --libs')
+if valgrind:
+    topenv.ParseConfig('pkg-config valgrind --cflags')
+    topenv.Append(CPPDEFINES = ['HAVE_VALGRIND'])
+
+Help(variables.GenerateHelpText(topenv))
+
+Export('topenv')
+
+libnotmuch = SConscript(['lib/SConscript'])
+
+env = topenv.Clone()
+
+notmuch = env.Program('notmuch', ['debugger.c',
+                                  'gmime-filter-reply.c',
+                                  'notmuch.c',
+                                  'notmuch-config.c',
+                                  'notmuch-dump.c',
+                                  'notmuch-new.c',
+                                  'notmuch-reply.c',
+                                  'notmuch-restore.c',
+                                  'notmuch-search.c',
+                                  'notmuch-setup.c',
+                                  'notmuch-show.c',
+                                  'notmuch-tag.c',
+                                  'notmuch-time.c',
+                                  'query-string.c',
+                                  'show-message.c',
+                                  libnotmuch])
+env.Alias('all', notmuch)
+
+env.Install('${DESTDIR}${bindir}', notmuch)
+env.Alias('install', '${DESTDIR}${bindir}')
+
+manpage = env.Command('notmuch.1.gz', 'notmuch.1', '${gzip} -9 < $SOURCE > $TARGET')
+env.Alias('all', manpage)
+
+env.InstallPerm('${DESTDIR}${mandir}/man1', manpage, 0644)
+env.Alias('install', '${DESTDIR}${mandir}/man1')
+
+env.InstallAsPerm('${DESTDIR}${bash_completion_dir}/notmuch', 'contrib/notmuch-completion.bash', 0644)
+env.Alias('install', '${DESTDIR}${bash_completion_dir}')
+
+if desktop:
+    env.Command('${DESTDIR}${desktop_dir}/notmuch.desktop', 'notmuch.desktop', 'desktop-file-install --mode 0644 --dir ${DESTDIR}${desktop_dir} ${SOURCE}')
+    env.Alias('install-desktop', '${DESTDIR}${desktop_dir}')
+
+if emacs:
+    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')
+    env.Alias('emacs', elisp)
+    env.InstallPerm('${DESTDIR}${emacs_lispdir}', elisp, 0644)
+    env.InstallPerm('${DESTDIR}${emacs_lispdir}', 'notmuch.el', 0644)
+    env.Alias('install-emacs', '${DESTDIR}${emacs_lispdir}')
+
+Default('all')
diff --git a/lib/SConscript b/lib/SConscript
new file mode 100644
index 0000000..eb38516
--- /dev/null
+++ b/lib/SConscript
@@ -0,0 +1,19 @@
+# -*- mode: python; coding: utf-8 -*-
+
+Import('topenv')
+
+env = topenv.Clone()
+
+libnotmuch = env.Library('notmuch', ['libsha1.c',
+                                     'message-file.c',
+                                     'messages.c',
+                                     'sha1.c',
+                                     'tags.c',
+                                     'xutil.c',
+                                     'database.cc',
+                                     'index.cc',
+                                     'message.cc',
+                                     'query.cc',
+                                     'thread.cc'])
+
+Return('libnotmuch')
-- 
1.6.5.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-23  6:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-22 13:47 [PATCH] Add SCons build files Jeffrey C. Ollie
2009-11-22 14:15 ` Bart Trojanowski
2009-11-22 16:00   ` Jeffrey Ollie
2009-11-22 17:21     ` Jed Brown
2009-11-22 20:02       ` Jeffrey Ollie
2009-11-22 20:36     ` Bart Trojanowski
2009-11-22 20:43 ` Ingmar Vanhassel
2009-11-23  3:11 ` Carl Worth
2009-11-23  4:36   ` Jeffrey Ollie
2009-11-23  6:20     ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).