1 Return-Path: <tomc@caurea.org>
\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 839844196F0
\r
6 for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 12:00:07 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id nXmV+U+-f5wm for <notmuch@notmuchmail.org>;
\r
16 Fri, 30 Apr 2010 12:00:06 -0700 (PDT)
\r
17 Received: from scotch.caurea.org (ks311007.kimsufi.com [188.165.197.188])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 55CAB431FC1
\r
19 for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 12:00:06 -0700 (PDT)
\r
20 Received: by scotch.caurea.org (Postfix, from userid 101)
\r
21 id B4B69131AB7; Fri, 30 Apr 2010 21:00:26 +0200 (CEST)
\r
22 From: Tomas Carnecky <tom@dbservice.com>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [RFC] Add support for the Solaris platform
\r
25 Date: Fri, 30 Apr 2010 21:00:24 +0200
\r
26 Message-Id: <1272654024-5254-1-git-send-email-tom@dbservice.com>
\r
27 X-Mailer: git-send-email 1.7.1
\r
28 X-BeenThere: notmuch@notmuchmail.org
\r
29 X-Mailman-Version: 2.1.13
\r
31 List-Id: "Use and development of the notmuch mail system."
\r
32 <notmuch.notmuchmail.org>
\r
33 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
34 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
35 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
36 List-Post: <mailto:notmuch@notmuchmail.org>
\r
37 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
38 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
40 X-List-Received-Date: Fri, 30 Apr 2010 19:00:07 -0000
\r
42 Like on Mac OS X, the linker doesn't automatically resolve dependencies.
\r
44 Signed-off-by: Tomas Carnecky <tom@dbservice.com>
\r
46 Makefile.local | 2 +-
\r
47 configure | 28 ++++++++++++++------
\r
48 lib/Makefile.local | 2 +-
\r
49 notmuch-new.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++------
\r
50 4 files changed, 83 insertions(+), 19 deletions(-)
\r
52 diff --git a/Makefile.local b/Makefile.local
\r
53 index 5bb570b..5bc872b 100644
\r
54 --- a/Makefile.local
\r
55 +++ b/Makefile.local
\r
56 @@ -255,7 +255,7 @@ notmuch_client_srcs = \
\r
57 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
\r
59 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
\r
60 - $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
\r
61 + $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@
\r
63 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
\r
64 $(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
\r
65 diff --git a/configure b/configure
\r
66 index c522ad8..91e08dd 100755
\r
69 @@ -257,15 +257,26 @@ else
\r
73 -printf "Checking for Mac OS X (for shared library)... "
\r
74 +printf "Checking which platform we are on... "
\r
75 if [ `uname` = "Darwin" ] ; then
\r
78 + printf "Mac OS X.\n"
\r
80 linker_resolves_library_dependencies=0
\r
84 +elif [ `uname` = "SunOS" ] ; then
\r
85 + printf "Solaris.\n"
\r
87 + linker_resolves_library_dependencies=0
\r
88 +elif [ `uname` = "Linux" ] ; then
\r
91 linker_resolves_library_dependencies=1
\r
93 + printf "Unknown.\n"
\r
96 +*** Warning: Unknown platform. Notmuch might or might not build correctly.
\r
101 if [ $errors -gt 0 ]; then
\r
102 @@ -433,9 +444,8 @@ HAVE_GETLINE = ${have_getline}
\r
103 # build its own version)
\r
104 HAVE_STRCASESTR = ${have_strcasestr}
\r
106 -# Whether we are building on OS X. This will affect how we build the
\r
108 -MAC_OS_X = ${mac_os_x}
\r
109 +# Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
\r
110 +PLATFORM = ${platform}
\r
112 # Whether the linker will automatically resolve the dependency of one
\r
113 # library on another (if not, then linking a binary requires linking
\r
114 diff --git a/lib/Makefile.local b/lib/Makefile.local
\r
115 index 0cc1d39..62f2316 100644
\r
116 --- a/lib/Makefile.local
\r
117 +++ b/lib/Makefile.local
\r
118 @@ -22,7 +22,7 @@ LIBNOTMUCH_VERSION_MINOR = 1
\r
119 # simply compatible changes to the implementation).
\r
120 LIBNOTMUCH_VERSION_RELEASE = 0
\r
122 -ifeq ($(MAC_OS_X),1)
\r
123 +ifeq ($(PLATFORM),MACOSX)
\r
124 LIBRARY_SUFFIX = dylib
\r
125 # On OS X, library version numbers go before suffix.
\r
126 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
\r
127 diff --git a/notmuch-new.c b/notmuch-new.c
\r
128 index 8818728..aacb5a6 100644
\r
129 --- a/notmuch-new.c
\r
130 +++ b/notmuch-new.c
\r
131 @@ -135,6 +135,62 @@ dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b)
\r
132 return strcmp ((*a)->d_name, (*b)->d_name);
\r
135 +/* Helper functions to test if a given dirent is of a certain type
\r
138 +_is_reg(const char *path, struct dirent *entry)
\r
141 + if (entry->d_type == DT_REG)
\r
145 + char buffer[PATH_MAX];
\r
146 + snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
\r
148 + struct stat sbuf;
\r
149 + if (!stat(buffer, &sbuf))
\r
150 + return S_ISREG(sbuf.st_mode);
\r
156 +_is_dir(const char *path, struct dirent *entry)
\r
159 + if (entry->d_type == DT_DIR)
\r
163 + char buffer[PATH_MAX];
\r
164 + snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
\r
166 + struct stat sbuf;
\r
167 + if (!stat(buffer, &sbuf))
\r
168 + return S_ISDIR(sbuf.st_mode);
\r
174 +_is_lnk(const char *path, struct dirent *entry)
\r
177 + if (entry->d_type == DT_LNK)
\r
181 + char buffer[PATH_MAX];
\r
182 + snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
\r
184 + struct stat sbuf;
\r
185 + if (!stat(buffer, &sbuf))
\r
186 + return S_ISLNK(sbuf.st_mode);
\r
191 /* Test if the directory looks like a Maildir directory.
\r
193 * Search through the array of directory entries to see if we can find all
\r
194 @@ -143,12 +199,12 @@ dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b)
\r
195 * Return 1 if the directory looks like a Maildir and 0 otherwise.
\r
198 -_entries_resemble_maildir (struct dirent **entries, int count)
\r
199 +_entries_resemble_maildir (const char *path, struct dirent **entries, int count)
\r
203 for (i = 0; i < count; i++) {
\r
204 - if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)
\r
205 + if (!_is_dir(path, entries[i]))
\r
208 if (strcmp(entries[i]->d_name, "new") == 0 ||
\r
209 @@ -261,7 +317,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
212 /* Pass 1: Recurse into all sub-directories. */
\r
213 - is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);
\r
214 + is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries);
\r
216 for (i = 0; i < num_fs_entries; i++) {
\r
218 @@ -276,9 +332,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
219 * scandir results, then it might be a directory (and if not,
\r
220 * then we'll stat and return immediately in the next level of
\r
222 - if (entry->d_type != DT_DIR &&
\r
223 - entry->d_type != DT_LNK &&
\r
224 - entry->d_type != DT_UNKNOWN)
\r
225 + if (!_is_dir(path, entry) && !_is_lnk(path, entry))
\r
229 @@ -356,7 +410,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
231 * In either case, a stat does the trick.
\r
233 - if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
\r
234 + if (_is_lnk(path, entry)) {
\r
237 next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
\r
238 @@ -372,7 +426,7 @@ add_files_recursive (notmuch_database_t *notmuch,
\r
240 if (! S_ISREG (st.st_mode))
\r
242 - } else if (entry->d_type != DT_REG) {
\r
243 + } else if (!_is_reg(path, entry)) {
\r