From 110c28c547d43b40856c287aa9e11e18552eeffd Mon Sep 17 00:00:00 2001 From: Tomas Carnecky Date: Fri, 30 Apr 2010 21:00:24 +0200 Subject: [PATCH] [RFC] Add support for the Solaris platform --- 5c/f3af6e42f3fb7c442ce99540d0d3542520ab24 | 249 ++++++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 5c/f3af6e42f3fb7c442ce99540d0d3542520ab24 diff --git a/5c/f3af6e42f3fb7c442ce99540d0d3542520ab24 b/5c/f3af6e42f3fb7c442ce99540d0d3542520ab24 new file mode 100644 index 000000000..9acecbb74 --- /dev/null +++ b/5c/f3af6e42f3fb7c442ce99540d0d3542520ab24 @@ -0,0 +1,249 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 839844196F0 + for ; Fri, 30 Apr 2010 12:00:07 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.9 +X-Spam-Level: +X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 + tests=[BAYES_00=-1.9] autolearn=ham +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id nXmV+U+-f5wm for ; + Fri, 30 Apr 2010 12:00:06 -0700 (PDT) +Received: from scotch.caurea.org (ks311007.kimsufi.com [188.165.197.188]) + by olra.theworths.org (Postfix) with ESMTP id 55CAB431FC1 + for ; Fri, 30 Apr 2010 12:00:06 -0700 (PDT) +Received: by scotch.caurea.org (Postfix, from userid 101) + id B4B69131AB7; Fri, 30 Apr 2010 21:00:26 +0200 (CEST) +From: Tomas Carnecky +To: notmuch@notmuchmail.org +Subject: [RFC] Add support for the Solaris platform +Date: Fri, 30 Apr 2010 21:00:24 +0200 +Message-Id: <1272654024-5254-1-git-send-email-tom@dbservice.com> +X-Mailer: git-send-email 1.7.1 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 30 Apr 2010 19:00:07 -0000 + +Like on Mac OS X, the linker doesn't automatically resolve dependencies. + +Signed-off-by: Tomas Carnecky +--- + Makefile.local | 2 +- + configure | 28 ++++++++++++++------ + lib/Makefile.local | 2 +- + notmuch-new.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++------ + 4 files changed, 83 insertions(+), 19 deletions(-) + +diff --git a/Makefile.local b/Makefile.local +index 5bb570b..5bc872b 100644 +--- a/Makefile.local ++++ b/Makefile.local +@@ -255,7 +255,7 @@ notmuch_client_srcs = \ + notmuch_client_modules = $(notmuch_client_srcs:.c=.o) + + notmuch: $(notmuch_client_modules) lib/libnotmuch.a +- $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@ ++ $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@ + + notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME) + $(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@ +diff --git a/configure b/configure +index c522ad8..91e08dd 100755 +--- a/configure ++++ b/configure +@@ -257,15 +257,26 @@ else + have_emacs=0 + fi + +-printf "Checking for Mac OS X (for shared library)... " ++printf "Checking which platform we are on... " + if [ `uname` = "Darwin" ] ; then +- printf "Yes.\n" +- mac_os_x=1 ++ printf "Mac OS X.\n" ++ platform=MACOSX + linker_resolves_library_dependencies=0 +-else +- printf "No.\n" +- mac_os_x=0 ++elif [ `uname` = "SunOS" ] ; then ++ printf "Solaris.\n" ++ platform=SOLARIS ++ linker_resolves_library_dependencies=0 ++elif [ `uname` = "Linux" ] ; then ++ printf "Linux\n" ++ platform=LINUX + linker_resolves_library_dependencies=1 ++else ++ printf "Unknown.\n" ++ cat <d_name, (*b)->d_name); + } + ++/* Helper functions to test if a given dirent is of a certain type ++ */ ++static int ++_is_reg(const char *path, struct dirent *entry) ++{ ++#ifdef DT_REG ++ if (entry->d_type == DT_REG) ++ return 1; ++#endif ++ ++ char buffer[PATH_MAX]; ++ snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name); ++ ++ struct stat sbuf; ++ if (!stat(buffer, &sbuf)) ++ return S_ISREG(sbuf.st_mode); ++ ++ return 0; ++} ++ ++static int ++_is_dir(const char *path, struct dirent *entry) ++{ ++#ifdef DT_DIR ++ if (entry->d_type == DT_DIR) ++ return 1; ++#endif ++ ++ char buffer[PATH_MAX]; ++ snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name); ++ ++ struct stat sbuf; ++ if (!stat(buffer, &sbuf)) ++ return S_ISDIR(sbuf.st_mode); ++ ++ return 0; ++} ++ ++static int ++_is_lnk(const char *path, struct dirent *entry) ++{ ++#ifdef DT_LNK ++ if (entry->d_type == DT_LNK) ++ return 1; ++#endif ++ ++ char buffer[PATH_MAX]; ++ snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name); ++ ++ struct stat sbuf; ++ if (!stat(buffer, &sbuf)) ++ return S_ISLNK(sbuf.st_mode); ++ ++ return 0; ++} ++ + /* Test if the directory looks like a Maildir directory. + * + * Search through the array of directory entries to see if we can find all +@@ -143,12 +199,12 @@ dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b) + * Return 1 if the directory looks like a Maildir and 0 otherwise. + */ + static int +-_entries_resemble_maildir (struct dirent **entries, int count) ++_entries_resemble_maildir (const char *path, struct dirent **entries, int count) + { + int i, found = 0; + + for (i = 0; i < count; i++) { +- if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN) ++ if (!_is_dir(path, entries[i])) + continue; + + if (strcmp(entries[i]->d_name, "new") == 0 || +@@ -261,7 +317,7 @@ add_files_recursive (notmuch_database_t *notmuch, + } + + /* Pass 1: Recurse into all sub-directories. */ +- is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries); ++ is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries); + + for (i = 0; i < num_fs_entries; i++) { + if (interrupted) +@@ -276,9 +332,7 @@ add_files_recursive (notmuch_database_t *notmuch, + * scandir results, then it might be a directory (and if not, + * then we'll stat and return immediately in the next level of + * recursion). */ +- if (entry->d_type != DT_DIR && +- entry->d_type != DT_LNK && +- entry->d_type != DT_UNKNOWN) ++ if (!_is_dir(path, entry) && !_is_lnk(path, entry)) + { + continue; + } +@@ -356,7 +410,7 @@ add_files_recursive (notmuch_database_t *notmuch, + * + * In either case, a stat does the trick. + */ +- if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) { ++ if (_is_lnk(path, entry)) { + int err; + + next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name); +@@ -372,7 +426,7 @@ add_files_recursive (notmuch_database_t *notmuch, + + if (! S_ISREG (st.st_mode)) + continue; +- } else if (entry->d_type != DT_REG) { ++ } else if (!_is_reg(path, entry)) { + continue; + } + +-- +1.7.1 + -- 2.26.2