[Patch v6 2/8] test: add support for compiling and running C snippets
[notmuch-archives.git] / ab / 047700b7ed60795c46b73d3e5940391144785f
1 Return-Path: <amdragon@mit.edu>\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 4005D431FBD\r
6         for <notmuch@notmuchmail.org>; Wed, 12 Feb 2014 22:51:16 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 1uTjYMs3b3Z1 for <notmuch@notmuchmail.org>;\r
16         Wed, 12 Feb 2014 22:51:10 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
18         [18.9.25.15])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id D19F4431FAE\r
22         for <notmuch@notmuchmail.org>; Wed, 12 Feb 2014 22:51:09 -0800 (PST)\r
23 X-AuditID: 1209190f-f790b6d000000c3a-e6-52fc6b5b5c9e\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id F6.16.03130.B5B6CF25; Thu, 13 Feb 2014 01:51:07 -0500 (EST)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s1D6p3Ej007008; \r
31         Thu, 13 Feb 2014 01:51:03 -0500\r
32 Received: from drake.dyndns.org\r
33         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
34         [216.15.114.40]) (authenticated bits=0)\r
35         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
36         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s1D6p0KX018783\r
37         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
38         Thu, 13 Feb 2014 01:51:02 -0500\r
39 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
40         (envelope-from <amdragon@mit.edu>)\r
41         id 1WDq8S-0005B0-Pa; Thu, 13 Feb 2014 01:51:00 -0500\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v2] new: Detect dirent.d_type support at configure time\r
45 Date: Thu, 13 Feb 2014 01:50:59 -0500\r
46 Message-Id: <1392274259-19765-1-git-send-email-amdragon@mit.edu>\r
47 X-Mailer: git-send-email 1.8.4.rc3\r
48 X-Brightmail-Tracker:\r
49  H4sIAAAAAAAAA+NgFlrPIsWRmVeSWpSXmKPExsUixCmqrBud/SfI4PB2QYum6c4W12/OZLZ4\r
50         s3IeqwOzx+GvC1k8bt1/ze7xbNUt5gDmKC6blNSczLLUIn27BK6MOa0dTAX3pSuWTnnM3MB4\r
51         UKSLkZNDQsBEYsvOVYwQtpjEhXvr2boYuTiEBGYzSbxY9IYRwtnIKHFk9nco5w6TxJmD31kh\r
52         nLmMEoeOTWMD6WcT0JDYtn852CwRAWmJnXdns4LYzALeEm+uHgSrERZwl5jx9w4TiM0ioCox\r
53         /28/WA2vgINEQ8diJog7lCQWntrGOoGRdwEjwypG2ZTcKt3cxMyc4tRk3eLkxLy81CJdE73c\r
54         zBK91JTSTYzgcJHk38H47aDSIUYBDkYlHl6NGb+DhFgTy4orcw8xSnIwKYny7sn4EyTEl5Sf\r
55         UpmRWJwRX1Sak1p8iFGCg1lJhFdGAijHm5JYWZValA+TkuZgURLnrbX4FSQkkJ5YkpqdmlqQ\r
56         WgSTleHgUJLg/ZEJ1ChYlJqeWpGWmVOCkGbi4AQZzgM0/BFIDW9xQWJucWY6RP4Uo6KUOO9p\r
57         kIsEQBIZpXlwvbB4fsUoDvSKMO9vkHYeYCqA634FNJgJaHBq1G+QwSWJCCmpBsYar8e5My/8\r
58         +X1djWntI8/tJ7U2ypv+6VbWvxWqF5mmv6/gfVfaXs+zTmsEfj54Jh89bfl+5+nz0059v7/9\r
59         4cYlebnvHVM1tH5v6LX9aZHsZvVJRF2rg/ur/uEVWUlda/beUN/3u9ByS7lEfrD4vZtG+StP\r
60         CGptMrlo696attZWIVjqU8aW1AglluKMREMt5qLiRAAWBRTKwgIAAA==\r
61 Cc: tomi.ollila@iki.fi\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Thu, 13 Feb 2014 06:51:16 -0000\r
75 \r
76 Support for dirent.d_type is OS-specific.  Previously, we used\r
77 _DIRENT_HAVE_D_TYPE to detect support for this, but this is apparently\r
78 a glic-ism (FreeBSD, for example, supports d_type, but does not define\r
79 this).  Since there's no cross-platform way to detect support for\r
80 dirent.d_type, detect it using a test compile at configure time.\r
81 ---\r
82 This is a trivial rebase of\r
83 id:1385262952-29240-1-git-send-email-amdragon@mit.edu, which I\r
84 apparently never got around to sending.  Tomi and Jani checked off v1\r
85 of this patch, so I'm marking it ready.\r
86 \r
87  compat/have_d_type.c | 10 ++++++++++\r
88  configure            | 16 ++++++++++++++++\r
89  notmuch-new.c        |  2 +-\r
90  3 files changed, 27 insertions(+), 1 deletion(-)\r
91  create mode 100644 compat/have_d_type.c\r
92 \r
93 diff --git a/compat/have_d_type.c b/compat/have_d_type.c\r
94 new file mode 100644\r
95 index 0000000..9ca6c6e\r
96 --- /dev/null\r
97 +++ b/compat/have_d_type.c\r
98 @@ -0,0 +1,10 @@\r
99 +#include <dirent.h>\r
100 +\r
101 +int main()\r
102 +{\r
103 +    struct dirent ent;\r
104 +\r
105 +    (void) ent.d_type;\r
106 +\r
107 +    return 0;\r
108 +}\r
109 diff --git a/configure b/configure\r
110 index 66aaedb..2eaed4a 100755\r
111 --- a/configure\r
112 +++ b/configure\r
113 @@ -578,6 +578,17 @@ else\r
114  fi\r
115  rm -f compat/have_timegm\r
116  \r
117 +printf "Checking for dirent.d_type... "\r
118 +if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1\r
119 +then\r
120 +    printf "Yes.\n"\r
121 +    have_d_type="1"\r
122 +else\r
123 +    printf "No (will use stat instead).\n"\r
124 +    have_d_type="0"\r
125 +fi\r
126 +rm -f compat/have_d_type\r
127 +\r
128  printf "Checking for standard version of getpwuid_r... "\r
129  if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1\r
130  then\r
131 @@ -769,6 +780,9 @@ HAVE_STRCASESTR = ${have_strcasestr}\r
132  # build its own version)\r
133  HAVE_STRSEP = ${have_strsep}\r
134  \r
135 +# Whether struct dirent has d_type (if not, then notmuch will use stat)\r
136 +HAVE_D_TYPE = ${have_d_type}\r
137 +\r
138  # Whether the Xapian version in use supports compaction\r
139  HAVE_XAPIAN_COMPACT = ${have_xapian_compact}\r
140  \r
141 @@ -829,6 +843,7 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\\r
142                    \$(VALGRIND_CFLAGS)                                   \\\r
143                    -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)                 \\\r
144                    -DHAVE_STRSEP=\$(HAVE_STRSEP)                         \\\r
145 +                  -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                         \\\r
146                    -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\\r
147                    -DSTD_ASCTIME=\$(STD_ASCTIME)                         \\\r
148                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)         \\\r
149 @@ -839,6 +854,7 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\\r
150                      \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\\r
151                      -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)               \\\r
152                      -DHAVE_STRSEP=\$(HAVE_STRSEP)                       \\\r
153 +                    -DHAVE_D_TYPE=\$(HAVE_D_TYPE)                       \\\r
154                      -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\\r
155                      -DSTD_ASCTIME=\$(STD_ASCTIME)                       \\\r
156                      -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)       \\\r
157 diff --git a/notmuch-new.c b/notmuch-new.c\r
158 index cd74489..8529fdd 100644\r
159 --- a/notmuch-new.c\r
160 +++ b/notmuch-new.c\r
161 @@ -173,7 +173,7 @@ dirent_type (const char *path, const struct dirent *entry)\r
162      char *abspath;\r
163      int err, saved_errno;\r
164  \r
165 -#ifdef _DIRENT_HAVE_D_TYPE\r
166 +#if HAVE_D_TYPE\r
167      /* Mapping from d_type to stat mode_t.  We omit DT_LNK so that\r
168       * we'll fall through to stat and get the real file type. */\r
169      static const mode_t modes[] = {\r
170 -- \r
171 1.8.4.rc3\r
172 \r