- Improve portability.

# TODO: The standalone lib needs it's own build stuff, pretty much same as
#       Zend has for standalone builds.
This commit is contained in:
foobar 2005-06-16 23:12:10 +00:00
parent 7a7cda7a4c
commit a736f99e2f
13 changed files with 161 additions and 19 deletions

View File

@ -1,9 +1,22 @@
dnl $Id$
dnl config.m4 for date extension
PHP_DATE_CFLAGS="-I@ext_srcdir@/lib"
sinclude(ext/date/lib/timelib.m4)
sinclude(lib/timelib.m4)
PHP_DATE_CFLAGS="-I@ext_builddir@/lib"
timelib_sources="lib/dow.c lib/parse_date.c lib/parse_tz.c
lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c"
PHP_NEW_EXTENSION(date, php_date.c $timelib_sources, no,, $PHP_DATE_CFLAGS)
PHP_ADD_BUILD_DIR([$ext_builddir/lib])
PHP_ADD_BUILD_DIR([$ext_builddir/lib], 1)
cat >> $ext_builddir/lib/tl_config.h <<EOF
#if PHP_WIN32
# include "config.w32.h"
#elif defined(NETWARE)
# include "config.nw.h"
#else
# include <php_config.h>
#endif
EOF

View File

@ -18,6 +18,8 @@
/* $Id$ */
#include <tl_config.h>
#include "timelib_structs.h"
static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */

View File

@ -20,9 +20,19 @@
/* $Id$ */
#include <stdlib.h>
#include <tl_config.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include "timelib.h"
#if defined(_MSC_VER)

View File

@ -18,9 +18,19 @@
/* $Id$ */
#include <stdlib.h>
#include <tl_config.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include "timelib.h"
#if defined(_MSC_VER)

View File

@ -18,13 +18,15 @@
/* $Id$ */
#include <tl_config.h>
#include <stdio.h>
#ifdef WIN32
#include <winsock2.h>
#else
#include <inttypes.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include "timelib.h"
#include "timezonedb.h"

View File

@ -18,9 +18,19 @@
/* $Id$ */
#include <stdlib.h>
#include <tl_config.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include "timelib.h"
#if defined(_MSC_VER)

View File

@ -18,6 +18,8 @@
/* $Id$ */
#include <tl_config.h>
#include "timelib_structs.h"
#include "timelib.h"
#include <ctype.h>

View File

@ -18,6 +18,9 @@
/* $Id$ */
#ifndef __TIMELIB_H__
#define __TIMELIB_H__
#include "timelib_structs.h"
#define TIMELIB_NONE 0x00
@ -31,7 +34,6 @@
#define LONG_MIN (- LONG_MAX - 1)
#endif
/* From dow.c */
timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
@ -71,3 +73,4 @@ void timelib_time_offset_dtor(timelib_time_offset* t);
signed long timelib_date_to_int(timelib_time *d, int *error);
void timelib_dump_date(timelib_time *d, int options);
#endif

50
ext/date/lib/timelib.m4 Normal file
View File

@ -0,0 +1,50 @@
dnl
dnl $Id$
dnl
dnl
dnl TL_DEF_HAVE(what [, why])
dnl
dnl Generates 'AC_DEFINE(HAVE_WHAT, 1, [WHY])'
dnl
AC_DEFUN([TL_DEF_HAVE],[AC_DEFINE([HAVE_]translit($1,a-z_.-,A-Z___),1,[ $2 ])])dnl
dnl
dnl TL_CHECK_INT_TYPE(type)
dnl
AC_DEFUN([TL_CHECK_INT_TYPE],[
AC_CACHE_CHECK([for $1], ac_cv_int_type_$1, [
AC_TRY_COMPILE([
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#elif HAVE_STDINT_H
# include <stdint.h>
#endif],
[if (($1 *) 0)
return 0;
if (sizeof ($1))
return 0;
], [ac_cv_int_type_$1=yes], [ac_cv_int_type_$1=no])
])
if test "$ac_cv_int_type_$1" = "yes"; then
TL_DEF_HAVE($1, [Define if $1 type is present.])
fi
])dnl
dnl Check for types, sizes, etc. needed by timelib
AC_CHECK_SIZEOF(long, 8)
AC_CHECK_SIZEOF(int, 4)
TL_CHECK_INT_TYPE(int32_t)
TL_CHECK_INT_TYPE(uint32_t)
dnl Check for headers needed by timelib
AC_CHECK_HEADERS([ \
sys/types.h \
inttypes.h \
stdint.h \
string.h \
stdlib.h
])

View File

@ -21,13 +21,42 @@
#ifndef __TIMELIB_STRUCTS_H__
#define __TIMELIB_STRUCTS_H__
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <winsock2.h>
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#elif defined(HAVE_STDINT_H)
#include <stdint.h>
#endif
#ifndef HAVE_INT32_T
# if SIZEOF_INT == 4
typedef int int32_t;
# elif SIZEOF_LONG == 4
typedef long int int32_t;
# endif
#endif
#ifndef HAVE_UINT32_T
# if SIZEOF_INT == 4
typedef unsigned int uint32_t;
# elif SIZEOF_LONG == 4
typedef unsigned long int uint32_t;
# endif
#endif
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#if defined(_MSC_VER) && _MSC_VER < 1300
@ -125,4 +154,5 @@ typedef struct timelib_time {
#define is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
#define DEBUG(s) if (0) { s }
#endif

View File

@ -18,6 +18,7 @@
/* $Id$ */
#include <tl_config.h>
#include "timelib.h"
/* jan feb mrt apr may jun jul aug sep oct nov dec */

View File

@ -18,9 +18,19 @@
/* $Id$ */
#include <stdlib.h>
#include <tl_config.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#if defined(_MSC_VER)
#define TIMELIB_LL_CONST(n) n ## i64

View File

@ -25,7 +25,6 @@
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_date.h"
#include "lib/timelib_structs.h"
#include "lib/timelib.h"
#include <time.h>