Re: [RFC] Add support for the Solaris platform

2010-06-03 Thread Carl Worth
On Fri, 30 Apr 2010 21:00:24 +0200, Tomas Carnecky  wrote:
> Like on Mac OS X, the linker doesn't automatically resolve
> dependencies.

Thanks for this fix, Tomas!

I like the fix described above, but you seem to have sent a patch with
three independent changes, only one of which was described. See below
for what I've done...

>  notmuch: $(notmuch_client_modules) lib/libnotmuch.a
> - $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
> + $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@

That seems to be correct. Could you describe what problem you ran into
that motivated you to find this fix? I have not committed this piece.

> -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
...
> -ifeq ($(MAC_OS_X),1)
> +ifeq ($(PLATFORM),MACOSX)
>  LIBRARY_SUFFIX = dylib
>  # On OS X, library version numbers go before suffix.
>  LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)

That hunk was all described by your original commit message. So I've
applied this part with your original commit message and will be pushing
it soon.

> +/* Helper functions to test if a given dirent is of a certain type
> + */
> +static int
> +_is_reg(const char *path, struct dirent *entry)
...
> @@ -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;
>   }

This all might be well and good, but is also not described by the commit
message. So I have not committed this either. If you resend with an
actual description of the change, I'll be happy to take a closer look.

Thanks again,

-Carl

-- 
[email protected]


pgpJg5sOQyF35.pgp
Description: PGP signature
___
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch


[RFC] Add support for the Solaris platform

2010-06-03 Thread Carl Worth
On Fri, 30 Apr 2010 21:00:24 +0200, Tomas Carnecky  wrote:
> Like on Mac OS X, the linker doesn't automatically resolve
> dependencies.

Thanks for this fix, Tomas!

I like the fix described above, but you seem to have sent a patch with
three independent changes, only one of which was described. See below
for what I've done...

>  notmuch: $(notmuch_client_modules) lib/libnotmuch.a
> - $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
> + $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@

That seems to be correct. Could you describe what problem you ran into
that motivated you to find this fix? I have not committed this piece.

> -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
...
> -ifeq ($(MAC_OS_X),1)
> +ifeq ($(PLATFORM),MACOSX)
>  LIBRARY_SUFFIX = dylib
>  # On OS X, library version numbers go before suffix.
>  LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)

That hunk was all described by your original commit message. So I've
applied this part with your original commit message and will be pushing
it soon.

> +/* Helper functions to test if a given dirent is of a certain type
> + */
> +static int
> +_is_reg(const char *path, struct dirent *entry)
...
> @@ -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;
>   }

This all might be well and good, but is also not described by the commit
message. So I have not committed this either. If you resend with an
actual description of the change, I'll be happy to take a closer look.

Thanks again,

-Carl

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[RFC] Add support for the Solaris platform

2010-04-30 Thread Tomas Carnecky
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);
 }

+/* 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;
}

-- 

[RFC] Add support for the Solaris platform

2010-04-30 Thread Tomas Carnecky
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);
 }
 
+/* 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;