You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

673 lines
18 KiB

  1. From: Joe Orton <jorton@redhat.com>
  2. Date: Sun, 18 Oct 2015 02:15:17 +0200
  3. Subject: Add support for use of the system timezone database
  4. Add support for use of the system timezone database, rather
  5. than embedding a copy. Discussed upstream but was not desired.
  6. History:
  7. r13: adapt for upstream changes to use PHP allocator
  8. r12: adapt for upstream changes for new zic
  9. r11: use canonical names to avoid more case sensitivity issues
  10. round lat/long from zone.tab towards zero per builtin db
  11. r10: make timezone case insensitive
  12. r9: fix another compile error without --with-system-tzdata configured (Michael Heimpold)
  13. r8: fix compile error without --with-system-tzdata configured
  14. r7: improve check for valid timezone id to exclude directories
  15. r6: fix fd leak in r5, fix country code/BC flag use in
  16. timezone_identifiers_list() using system db,
  17. fix use of PECL timezonedb to override system db,
  18. r5: reverts addition of "System/Localtime" fake tzname.
  19. updated for 5.3.0, parses zone.tab to pick up mapping between
  20. timezone name, country code and long/lat coords
  21. r4: added "System/Localtime" tzname which uses /etc/localtime
  22. r3: fix a crash if /usr/share/zoneinfo doesn't exist (Raphael Geissert)
  23. r2: add filesystem trawl to set up name alias index
  24. r1: initial revision
  25. ---
  26. ext/date/lib/parse_tz.c | 549 +++++++++++++++++++++++++++++++++++++++++++++++-
  27. ext/date/lib/timelib.m4 | 14 ++
  28. 2 files changed, 552 insertions(+), 11 deletions(-)
  29. diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c
  30. index 20d7eea..6301dc5 100644
  31. --- a/ext/date/lib/parse_tz.c
  32. +++ b/ext/date/lib/parse_tz.c
  33. @@ -24,6 +24,16 @@
  34. #include "timelib.h"
  35. +#ifdef HAVE_SYSTEM_TZDATA
  36. +#include <sys/mman.h>
  37. +#include <sys/stat.h>
  38. +#include <limits.h>
  39. +#include <fcntl.h>
  40. +#include <unistd.h>
  41. +
  42. +#include "php_scandir.h"
  43. +#endif
  44. +
  45. #include <stdio.h>
  46. #ifdef HAVE_LOCALE_H
  47. @@ -36,8 +46,12 @@
  48. #include <strings.h>
  49. #endif
  50. +#ifndef HAVE_SYSTEM_TZDATA
  51. #define TIMELIB_SUPPORTS_V2DATA
  52. #include "timezonedb.h"
  53. +#endif
  54. +
  55. +#include <ctype.h>
  56. #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
  57. # if defined(__LITTLE_ENDIAN__)
  58. @@ -59,6 +73,11 @@ static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
  59. {
  60. uint32_t version;
  61. + if (memcmp(*tzf, "TZif", 4) == 0) {
  62. + *tzf += 20;
  63. + return 0;
  64. + }
  65. +
  66. /* read ID */
  67. version = (*tzf)[3] - '0';
  68. *tzf += 4;
  69. @@ -302,7 +321,418 @@ void timelib_dump_tzinfo(timelib_tzinfo *tz)
  70. }
  71. }
  72. -static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb)
  73. +#ifdef HAVE_SYSTEM_TZDATA
  74. +
  75. +#ifdef HAVE_SYSTEM_TZDATA_PREFIX
  76. +#define ZONEINFO_PREFIX HAVE_SYSTEM_TZDATA_PREFIX
  77. +#else
  78. +#define ZONEINFO_PREFIX "/usr/share/zoneinfo"
  79. +#endif
  80. +
  81. +/* System timezone database pointer. */
  82. +static const timelib_tzdb *timezonedb_system;
  83. +
  84. +/* Hash table entry for the cache of the zone.tab mapping table. */
  85. +struct location_info {
  86. + char code[2];
  87. + double latitude, longitude;
  88. + char name[64];
  89. + char *comment;
  90. + struct location_info *next;
  91. +};
  92. +
  93. +/* Cache of zone.tab. */
  94. +static struct location_info **system_location_table;
  95. +
  96. +/* Size of the zone.tab hash table; a random-ish prime big enough to
  97. + * prevent too many collisions. */
  98. +#define LOCINFO_HASH_SIZE (1021)
  99. +
  100. +/* Compute a case insensitive hash of str */
  101. +static uint32_t tz_hash(const char *str)
  102. +{
  103. + const unsigned char *p = (const unsigned char *)str;
  104. + uint32_t hash = 5381;
  105. + int c;
  106. +
  107. + while ((c = tolower(*p++)) != '\0') {
  108. + hash = (hash << 5) ^ hash ^ c;
  109. + }
  110. +
  111. + return hash % LOCINFO_HASH_SIZE;
  112. +}
  113. +
  114. +/* Parse an ISO-6709 date as used in zone.tab. Returns end of the
  115. + * parsed string on success, or NULL on parse error. On success,
  116. + * writes the parsed number to *result. */
  117. +static char *parse_iso6709(char *p, double *result)
  118. +{
  119. + double v, sign;
  120. + char *pend;
  121. + size_t len;
  122. +
  123. + if (*p == '+')
  124. + sign = 1.0;
  125. + else if (*p == '-')
  126. + sign = -1.0;
  127. + else
  128. + return NULL;
  129. +
  130. + p++;
  131. + for (pend = p; *pend >= '0' && *pend <= '9'; pend++)
  132. + ;;
  133. +
  134. + /* Annoying encoding used by zone.tab has no decimal point, so use
  135. + * the length to determine the format:
  136. + *
  137. + * 4 = DDMM
  138. + * 5 = DDDMM
  139. + * 6 = DDMMSS
  140. + * 7 = DDDMMSS
  141. + */
  142. + len = pend - p;
  143. + if (len < 4 || len > 7) {
  144. + return NULL;
  145. + }
  146. +
  147. + /* p => [D]DD */
  148. + v = (p[0] - '0') * 10.0 + (p[1] - '0');
  149. + p += 2;
  150. + if (len == 5 || len == 7)
  151. + v = v * 10.0 + (*p++ - '0');
  152. + /* p => MM[SS] */
  153. + v += (10.0 * (p[0] - '0')
  154. + + p[1] - '0') / 60.0;
  155. + p += 2;
  156. + /* p => [SS] */
  157. + if (len > 5) {
  158. + v += (10.0 * (p[0] - '0')
  159. + + p[1] - '0') / 3600.0;
  160. + p += 2;
  161. + }
  162. +
  163. + /* Round to five decimal place, not because it's a good idea,
  164. + * but, because the builtin data uses rounded data, so, match
  165. + * that. */
  166. + *result = trunc(v * sign * 100000.0) / 100000.0;
  167. +
  168. + return p;
  169. +}
  170. +
  171. +/* This function parses the zone.tab file to build up the mapping of
  172. + * timezone to country code and geographic location, and returns a
  173. + * hash table. The hash table is indexed by the function:
  174. + *
  175. + * tz_hash(timezone-name)
  176. + */
  177. +static struct location_info **create_location_table(void)
  178. +{
  179. + struct location_info **li, *i;
  180. + char zone_tab[PATH_MAX];
  181. + char line[512];
  182. + FILE *fp;
  183. +
  184. + strncpy(zone_tab, ZONEINFO_PREFIX "/zone.tab", sizeof zone_tab);
  185. +
  186. + fp = fopen(zone_tab, "r");
  187. + if (!fp) {
  188. + return NULL;
  189. + }
  190. +
  191. + li = calloc(LOCINFO_HASH_SIZE, sizeof *li);
  192. +
  193. + while (fgets(line, sizeof line, fp)) {
  194. + char *p = line, *code, *name, *comment;
  195. + uint32_t hash;
  196. + double latitude, longitude;
  197. +
  198. + while (isspace(*p))
  199. + p++;
  200. +
  201. + if (*p == '#' || *p == '\0' || *p == '\n')
  202. + continue;
  203. +
  204. + if (!isalpha(p[0]) || !isalpha(p[1]) || p[2] != '\t')
  205. + continue;
  206. +
  207. + /* code => AA */
  208. + code = p;
  209. + p[2] = 0;
  210. + p += 3;
  211. +
  212. + /* coords => [+-][D]DDMM[SS][+-][D]DDMM[SS] */
  213. + p = parse_iso6709(p, &latitude);
  214. + if (!p) {
  215. + continue;
  216. + }
  217. + p = parse_iso6709(p, &longitude);
  218. + if (!p) {
  219. + continue;
  220. + }
  221. +
  222. + if (!p || *p != '\t') {
  223. + continue;
  224. + }
  225. +
  226. + /* name = string */
  227. + name = ++p;
  228. + while (*p != '\t' && *p && *p != '\n')
  229. + p++;
  230. +
  231. + *p++ = '\0';
  232. +
  233. + /* comment = string */
  234. + comment = p;
  235. + while (*p != '\t' && *p && *p != '\n')
  236. + p++;
  237. +
  238. + if (*p == '\n' || *p == '\t')
  239. + *p = '\0';
  240. +
  241. + hash = tz_hash(name);
  242. + i = malloc(sizeof *i);
  243. + memcpy(i->code, code, 2);
  244. + strncpy(i->name, name, sizeof i->name);
  245. + i->comment = strdup(comment);
  246. + i->longitude = longitude;
  247. + i->latitude = latitude;
  248. + i->next = li[hash];
  249. + li[hash] = i;
  250. + /* printf("%s [%u, %f, %f]\n", name, hash, latitude, longitude); */
  251. + }
  252. +
  253. + fclose(fp);
  254. +
  255. + return li;
  256. +}
  257. +
  258. +/* Return location info from hash table, using given timezone name.
  259. + * Returns NULL if the name could not be found. */
  260. +const struct location_info *find_zone_info(struct location_info **li,
  261. + const char *name)
  262. +{
  263. + uint32_t hash = tz_hash(name);
  264. + const struct location_info *l;
  265. +
  266. + if (!li) {
  267. + return NULL;
  268. + }
  269. +
  270. + for (l = li[hash]; l; l = l->next) {
  271. + if (strcasecmp(l->name, name) == 0)
  272. + return l;
  273. + }
  274. +
  275. + return NULL;
  276. +}
  277. +
  278. +/* Filter out some non-tzdata files and the posix/right databases, if
  279. + * present. */
  280. +static int index_filter(const struct dirent *ent)
  281. +{
  282. + return strcmp(ent->d_name, ".") != 0
  283. + && strcmp(ent->d_name, "..") != 0
  284. + && strcmp(ent->d_name, "posix") != 0
  285. + && strcmp(ent->d_name, "posixrules") != 0
  286. + && strcmp(ent->d_name, "right") != 0
  287. + && strstr(ent->d_name, ".tab") == NULL;
  288. +}
  289. +
  290. +static int sysdbcmp(const void *first, const void *second)
  291. +{
  292. + const timelib_tzdb_index_entry *alpha = first, *beta = second;
  293. +
  294. + return strcasecmp(alpha->id, beta->id);
  295. +}
  296. +
  297. +
  298. +/* Create the zone identifier index by trawling the filesystem. */
  299. +static void create_zone_index(timelib_tzdb *db)
  300. +{
  301. + size_t dirstack_size, dirstack_top;
  302. + size_t index_size, index_next;
  303. + timelib_tzdb_index_entry *db_index;
  304. + char **dirstack;
  305. +
  306. + /* LIFO stack to hold directory entries to scan; each slot is a
  307. + * directory name relative to the zoneinfo prefix. */
  308. + dirstack_size = 32;
  309. + dirstack = malloc(dirstack_size * sizeof *dirstack);
  310. + dirstack_top = 1;
  311. + dirstack[0] = strdup("");
  312. +
  313. + /* Index array. */
  314. + index_size = 64;
  315. + db_index = malloc(index_size * sizeof *db_index);
  316. + index_next = 0;
  317. +
  318. + do {
  319. + struct dirent **ents;
  320. + char name[PATH_MAX], *top;
  321. + int count;
  322. +
  323. + /* Pop the top stack entry, and iterate through its contents. */
  324. + top = dirstack[--dirstack_top];
  325. + snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s", top);
  326. +
  327. + count = php_scandir(name, &ents, index_filter, php_alphasort);
  328. +
  329. + while (count > 0) {
  330. + struct stat st;
  331. + const char *leaf = ents[count - 1]->d_name;
  332. +
  333. + snprintf(name, sizeof name, ZONEINFO_PREFIX "/%s/%s",
  334. + top, leaf);
  335. +
  336. + if (strlen(name) && stat(name, &st) == 0) {
  337. + /* Name, relative to the zoneinfo prefix. */
  338. + const char *root = top;
  339. +
  340. + if (root[0] == '/') root++;
  341. +
  342. + snprintf(name, sizeof name, "%s%s%s", root,
  343. + *root ? "/": "", leaf);
  344. +
  345. + if (S_ISDIR(st.st_mode)) {
  346. + if (dirstack_top == dirstack_size) {
  347. + dirstack_size *= 2;
  348. + dirstack = realloc(dirstack,
  349. + dirstack_size * sizeof *dirstack);
  350. + }
  351. + dirstack[dirstack_top++] = strdup(name);
  352. + }
  353. + else {
  354. + if (index_next == index_size) {
  355. + index_size *= 2;
  356. + db_index = realloc(db_index,
  357. + index_size * sizeof *db_index);
  358. + }
  359. +
  360. + db_index[index_next++].id = strdup(name);
  361. + }
  362. + }
  363. +
  364. + free(ents[--count]);
  365. + }
  366. +
  367. + if (count != -1) free(ents);
  368. + free(top);
  369. + } while (dirstack_top);
  370. +
  371. + qsort(db_index, index_next, sizeof *db_index, sysdbcmp);
  372. +
  373. + db->index = db_index;
  374. + db->index_size = index_next;
  375. +
  376. + free(dirstack);
  377. +}
  378. +
  379. +#define FAKE_HEADER "1234\0??\1??"
  380. +#define FAKE_UTC_POS (7 - 4)
  381. +
  382. +/* Create a fake data segment for database 'sysdb'. */
  383. +static void fake_data_segment(timelib_tzdb *sysdb,
  384. + struct location_info **info)
  385. +{
  386. + size_t n;
  387. + char *data, *p;
  388. +
  389. + data = malloc(3 * sysdb->index_size + 7);
  390. +
  391. + p = mempcpy(data, FAKE_HEADER, sizeof(FAKE_HEADER) - 1);
  392. +
  393. + for (n = 0; n < sysdb->index_size; n++) {
  394. + const struct location_info *li;
  395. + timelib_tzdb_index_entry *ent;
  396. +
  397. + ent = (timelib_tzdb_index_entry *)&sysdb->index[n];
  398. +
  399. + /* Lookup the timezone name in the hash table. */
  400. + if (strcmp(ent->id, "UTC") == 0) {
  401. + ent->pos = FAKE_UTC_POS;
  402. + continue;
  403. + }
  404. +
  405. + li = find_zone_info(info, ent->id);
  406. + if (li) {
  407. + /* If found, append the BC byte and the
  408. + * country code; set the position for this
  409. + * section of timezone data. */
  410. + ent->pos = (p - data) - 4;
  411. + *p++ = '\1';
  412. + *p++ = li->code[0];
  413. + *p++ = li->code[1];
  414. + }
  415. + else {
  416. + /* If not found, the timezone data can
  417. + * point at the header. */
  418. + ent->pos = 0;
  419. + }
  420. + }
  421. +
  422. + sysdb->data = (unsigned char *)data;
  423. +}
  424. +
  425. +/* Returns true if the passed-in stat structure describes a
  426. + * probably-valid timezone file. */
  427. +static int is_valid_tzfile(const struct stat *st)
  428. +{
  429. + return S_ISREG(st->st_mode) && st->st_size > 20;
  430. +}
  431. +
  432. +/* To allow timezone names to be used case-insensitively, find the
  433. + * canonical name for this timezone, if possible. */
  434. +static const char *canonical_tzname(const char *timezone)
  435. +{
  436. + if (timezonedb_system) {
  437. + timelib_tzdb_index_entry *ent, lookup;
  438. +
  439. + lookup.id = (char *)timezone;
  440. +
  441. + ent = bsearch(&lookup, timezonedb_system->index,
  442. + timezonedb_system->index_size, sizeof lookup,
  443. + sysdbcmp);
  444. + if (ent) {
  445. + return ent->id;
  446. + }
  447. + }
  448. +
  449. + return timezone;
  450. +}
  451. +
  452. +/* Return the mmap()ed tzfile if found, else NULL. On success, the
  453. + * length of the mapped data is placed in *length. */
  454. +static char *map_tzfile(const char *timezone, size_t *length)
  455. +{
  456. + char fname[PATH_MAX];
  457. + struct stat st;
  458. + char *p;
  459. + int fd;
  460. +
  461. + if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
  462. + return NULL;
  463. + }
  464. +
  465. + snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone));
  466. +
  467. + fd = open(fname, O_RDONLY);
  468. + if (fd == -1) {
  469. + return NULL;
  470. + } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st)) {
  471. + close(fd);
  472. + return NULL;
  473. + }
  474. +
  475. + *length = st.st_size;
  476. + p = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
  477. + close(fd);
  478. +
  479. + return p != MAP_FAILED ? p : NULL;
  480. +}
  481. +
  482. +#endif
  483. +
  484. +static int inmem_seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb)
  485. {
  486. int left = 0, right = tzdb->index_size - 1;
  487. #ifdef HAVE_SETLOCALE
  488. @@ -341,21 +771,88 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
  489. return 0;
  490. }
  491. +static int seek_to_tz_position(const unsigned char **tzf, char *timezone,
  492. + char **map, size_t *maplen,
  493. + const timelib_tzdb *tzdb)
  494. +{
  495. +#ifdef HAVE_SYSTEM_TZDATA
  496. + if (tzdb == timezonedb_system) {
  497. + char *orig;
  498. +
  499. + orig = map_tzfile(timezone, maplen);
  500. + if (orig == NULL) {
  501. + return 0;
  502. + }
  503. +
  504. + (*tzf) = (unsigned char *)orig;
  505. + *map = orig;
  506. + return 1;
  507. + }
  508. + else
  509. +#endif
  510. + {
  511. + return inmem_seek_to_tz_position(tzf, timezone, tzdb);
  512. + }
  513. +}
  514. +
  515. const timelib_tzdb *timelib_builtin_db(void)
  516. {
  517. +#ifdef HAVE_SYSTEM_TZDATA
  518. + if (timezonedb_system == NULL) {
  519. + timelib_tzdb *tmp = malloc(sizeof *tmp);
  520. +
  521. + tmp->version = "0.system";
  522. + tmp->data = NULL;
  523. + create_zone_index(tmp);
  524. + system_location_table = create_location_table();
  525. + fake_data_segment(tmp, system_location_table);
  526. + timezonedb_system = tmp;
  527. + }
  528. +
  529. + return timezonedb_system;
  530. +#else
  531. return &timezonedb_builtin;
  532. +#endif
  533. }
  534. const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count)
  535. {
  536. +#ifdef HAVE_SYSTEM_TZDATA
  537. + *count = timezonedb_system->index_size;
  538. + return timezonedb_system->index;
  539. +#else
  540. *count = sizeof(timezonedb_idx_builtin) / sizeof(*timezonedb_idx_builtin);
  541. return timezonedb_idx_builtin;
  542. +#endif
  543. }
  544. int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb)
  545. {
  546. const unsigned char *tzf;
  547. - return (seek_to_tz_position(&tzf, timezone, tzdb));
  548. +
  549. +#ifdef HAVE_SYSTEM_TZDATA
  550. + if (tzdb == timezonedb_system) {
  551. + char fname[PATH_MAX];
  552. + struct stat st;
  553. +
  554. + if (timezone[0] == '\0' || strstr(timezone, "..") != NULL) {
  555. + return 0;
  556. + }
  557. +
  558. + if (system_location_table) {
  559. + if (find_zone_info(system_location_table, timezone) != NULL) {
  560. + /* found in cache */
  561. + return 1;
  562. + }
  563. + }
  564. +
  565. + snprintf(fname, sizeof fname, ZONEINFO_PREFIX "/%s", canonical_tzname(timezone));
  566. +
  567. + return stat(fname, &st) == 0 && is_valid_tzfile(&st);
  568. + }
  569. +#endif
  570. +
  571. + return (inmem_seek_to_tz_position(&tzf, timezone, tzdb));
  572. }
  573. static void skip_64bit_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
  574. @@ -380,24 +877,54 @@ static void read_64bit_header(const unsigned char **tzf, timelib_tzinfo *tz)
  575. timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb)
  576. {
  577. const unsigned char *tzf;
  578. + char *memmap = NULL;
  579. + size_t maplen;
  580. timelib_tzinfo *tmp;
  581. int version;
  582. - if (seek_to_tz_position(&tzf, timezone, tzdb)) {
  583. + if (seek_to_tz_position(&tzf, timezone, &memmap, &maplen, tzdb)) {
  584. tmp = timelib_tzinfo_ctor(timezone);
  585. version = read_preamble(&tzf, tmp);
  586. read_header(&tzf, tmp);
  587. read_transistions(&tzf, tmp);
  588. read_types(&tzf, tmp);
  589. - if (version == 2) {
  590. - skip_64bit_preamble(&tzf, tmp);
  591. - read_64bit_header(&tzf, tmp);
  592. - skip_64bit_transistions(&tzf, tmp);
  593. - skip_64bit_types(&tzf, tmp);
  594. - skip_posix_string(&tzf, tmp);
  595. - }
  596. - read_location(&tzf, tmp);
  597. +
  598. +#ifdef HAVE_SYSTEM_TZDATA
  599. + if (memmap) {
  600. + const struct location_info *li;
  601. +
  602. + /* TZif-style - grok the location info from the system database,
  603. + * if possible. */
  604. +
  605. + if ((li = find_zone_info(system_location_table, timezone)) != NULL) {
  606. + tmp->location.comments = timelib_strdup(li->comment);
  607. + strncpy(tmp->location.country_code, li->code, 2);
  608. + tmp->location.longitude = li->longitude;
  609. + tmp->location.latitude = li->latitude;
  610. + tmp->bc = 1;
  611. + }
  612. + else {
  613. + strcpy(tmp->location.country_code, "??");
  614. + tmp->bc = 0;
  615. + tmp->location.comments = timelib_strdup("");
  616. + }
  617. +
  618. + /* Now done with the mmap segment - discard it. */
  619. + munmap(memmap, maplen);
  620. + } else
  621. +#endif
  622. + {
  623. + /* PHP-style - use the embedded info. */
  624. + if (version == 2) {
  625. + skip_64bit_preamble(&tzf, tmp);
  626. + read_64bit_header(&tzf, tmp);
  627. + skip_64bit_transistions(&tzf, tmp);
  628. + skip_64bit_types(&tzf, tmp);
  629. + skip_posix_string(&tzf, tmp);
  630. + }
  631. + read_location(&tzf, tmp);
  632. + }
  633. } else {
  634. tmp = NULL;
  635. }
  636. diff --git a/ext/date/lib/timelib.m4 b/ext/date/lib/timelib.m4
  637. index c725572..4c837c7 100644
  638. --- a/ext/date/lib/timelib.m4
  639. +++ b/ext/date/lib/timelib.m4
  640. @@ -78,3 +78,17 @@ stdlib.h
  641. dnl Check for strtoll, atoll
  642. AC_CHECK_FUNCS(strtoll atoll strftime)
  643. +
  644. +PHP_ARG_WITH(system-tzdata, for use of system timezone data,
  645. +[ --with-system-tzdata[=DIR] to specify use of system timezone data],
  646. +no, no)
  647. +
  648. +if test "$PHP_SYSTEM_TZDATA" != "no"; then
  649. + AC_DEFINE(HAVE_SYSTEM_TZDATA, 1, [Define if system timezone data is used])
  650. +
  651. + if test "$PHP_SYSTEM_TZDATA" != "yes"; then
  652. + AC_DEFINE_UNQUOTED(HAVE_SYSTEM_TZDATA_PREFIX, "$PHP_SYSTEM_TZDATA",
  653. + [Define for location of system timezone data])
  654. + fi
  655. +fi
  656. +