Skip to content

Instantly share code, notes, and snippets.

@e-nomem
Created February 15, 2013 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-nomem/4958223 to your computer and use it in GitHub Desktop.
Save e-nomem/4958223 to your computer and use it in GitHub Desktop.
diff --git a/config.m4 b/config.m4
index fca4c2e..92dd8ed 100644
--- a/config.m4
+++ b/config.m4
@@ -9,15 +9,30 @@ if test "$PHP_UUID" != "no"; then
PHP_CHECK_FUNC_LIB(uuid_type, uuid)
PHP_CHECK_FUNC_LIB(uuid_variant, uuid)
+ PHP_CHECK_FUNC_LIB(uuid_time, uuid)
+ PHP_CHECK_FUNC_LIB(uuid_mac, uuid)
+
PHP_ADD_INCLUDE($PHP_UUID_DIR/include)
export OLD_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_UUID"
AC_CHECK_HEADER([uuid/uuid.h], [], AC_MSG_ERROR('uuid/uuid.h' header not found))
- PHP_SUBST(UUID_SHARED_LIBADD)
- PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD)
+ AC_MSG_CHECKING(PHP version)
+ AC_TRY_COMPILE([], [
+#ifdef __APPLE__
+#error compiling on darwin
+#endif
+],
+[],
+[export UUID_ON_MAC=true])
+
+
+ if test $UUID_ON_MAC != "true"; then
+ PHP_SUBST(UUID_SHARED_LIBADD)
+ PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD)
+ fi
export CPPFLAGS="$OLD_CPPFLAGS"
export OLD_CPPFLAGS="$CPPFLAGS"
@@ -35,7 +50,6 @@ if test "$PHP_UUID" != "no"; then
export CPPFLAGS="$OLD_CPPFLAGS"
- PHP_SUBST(UUID_SHARED_LIBADD)
AC_DEFINE(HAVE_UUID, 1, [ ])
PHP_NEW_EXTENSION(uuid, uuid.c , $ext_shared)
diff --git a/php_uuid.h b/php_uuid.h
index 5a7d208..29c8805 100644
--- a/php_uuid.h
+++ b/php_uuid.h
@@ -146,6 +146,7 @@ ZEND_END_ARG_INFO()
#endif
#endif /* HAVE_UUID_VARIANT */
+#if HAVE_UUID_TIME
PHP_FUNCTION(uuid_time);
#if (PHP_MAJOR_VERSION >= 5)
ZEND_BEGIN_ARG_INFO_EX(uuid_time_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -155,6 +156,8 @@ ZEND_END_ARG_INFO()
#define uuid_time_arg_info NULL
#endif
+#endif /* HAVE_UUID_TIME */
+#if HAVE_UUID_MAC
PHP_FUNCTION(uuid_mac);
#if (PHP_MAJOR_VERSION >= 5)
ZEND_BEGIN_ARG_INFO_EX(uuid_mac_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -164,6 +167,7 @@ ZEND_END_ARG_INFO()
#define uuid_mac_arg_info NULL
#endif
+#endif /* HAVE_UUID_MAC */
PHP_FUNCTION(uuid_parse);
#if (PHP_MAJOR_VERSION >= 5)
ZEND_BEGIN_ARG_INFO_EX(uuid_parse_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -186,6 +190,14 @@ ZEND_END_ARG_INFO()
} // extern "C"
#endif
+#ifndef UUID_TYPE_DCE_TIME
+#ifdef __APPLE__
+/* UUID Type definitions */
+#define UUID_TYPE_DCE_TIME 1
+#define UUID_TYPE_DCE_RANDOM 4
+#endif /* __APPLE__ */
+#endif /* UUID_TYPE_DCE_TIME */
+
/* mirrored PHP Constants */
#define UUID_TYPE_DEFAULT 0
#define UUID_TYPE_TIME UUID_TYPE_DCE_TIME
diff --git a/tests/uuid_mac.phpt b/tests/uuid_mac.phpt
index 3d704ca..a4631de 100644
--- a/tests/uuid_mac.phpt
+++ b/tests/uuid_mac.phpt
@@ -5,6 +5,8 @@ uuid_mac() function
if(!extension_loaded('uuid')) die('skip ');
+if(!function_exists('uuid_mac')) die('skip not compiled in (HAVE_UUID_MAC)');
+
?>
--FILE--
<?php
diff --git a/tests/uuid_time.phpt b/tests/uuid_time.phpt
index 0a4f7e0..744c7eb 100644
--- a/tests/uuid_time.phpt
+++ b/tests/uuid_time.phpt
@@ -5,6 +5,8 @@ uuid_time() function
if(!extension_loaded('uuid')) die('skip ');
+if(!function_exists('uuid_time')) die('skip not compiled in (HAVE_UUID_TIME)');
+
?>
--FILE--
<?php
diff --git a/uuid.c b/uuid.c
index 5b05c28..cbc3655 100644
--- a/uuid.c
+++ b/uuid.c
@@ -40,8 +40,12 @@ zend_function_entry uuid_functions[] = {
#if HAVE_UUID_VARIANT
PHP_FE(uuid_variant , uuid_variant_arg_info)
#endif /* HAVE_UUID_VARIANT */
+#if HAVE_UUID_TIME
PHP_FE(uuid_time , uuid_time_arg_info)
+#endif /* HAVE_UUID_TIME */
+#if HAVE_UUID_MAC
PHP_FE(uuid_mac , uuid_mac_arg_info)
+#endif /* HAVE_UUID_MAC */
PHP_FE(uuid_parse , uuid_parse_arg_info)
PHP_FE(uuid_unparse , uuid_unparse_arg_info)
{ NULL, NULL, NULL }
diff --git a/uuid-1.0.3/config.m4 b/uuid-1.0.3/config.m4
index fca4c2e..92dd8ed 100644
--- a/uuid-1.0.3/config.m4
+++ b/uuid-1.0.3/config.m4
@@ -9,15 +9,30 @@ if test "$PHP_UUID" != "no"; then
PHP_CHECK_FUNC_LIB(uuid_type, uuid)
PHP_CHECK_FUNC_LIB(uuid_variant, uuid)
+ PHP_CHECK_FUNC_LIB(uuid_time, uuid)
+ PHP_CHECK_FUNC_LIB(uuid_mac, uuid)
+
PHP_ADD_INCLUDE($PHP_UUID_DIR/include)
export OLD_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_UUID"
AC_CHECK_HEADER([uuid/uuid.h], [], AC_MSG_ERROR('uuid/uuid.h' header not found))
- PHP_SUBST(UUID_SHARED_LIBADD)
- PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD)
+ AC_MSG_CHECKING(PHP version)
+ AC_TRY_COMPILE([], [
+#ifdef __APPLE__
+#error compiling on darwin
+#endif
+],
+[],
+[export UUID_ON_MAC=true])
+
+
+ if test $UUID_ON_MAC != "true"; then
+ PHP_SUBST(UUID_SHARED_LIBADD)
+ PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD)
+ fi
export CPPFLAGS="$OLD_CPPFLAGS"
export OLD_CPPFLAGS="$CPPFLAGS"
@@ -35,7 +50,6 @@ if test "$PHP_UUID" != "no"; then
export CPPFLAGS="$OLD_CPPFLAGS"
- PHP_SUBST(UUID_SHARED_LIBADD)
AC_DEFINE(HAVE_UUID, 1, [ ])
PHP_NEW_EXTENSION(uuid, uuid.c , $ext_shared)
diff --git a/uuid-1.0.3/php_uuid.h b/uuid-1.0.3/php_uuid.h
index 0b71d20..88b7584 100644
--- a/uuid-1.0.3/php_uuid.h
+++ b/uuid-1.0.3/php_uuid.h
@@ -145,6 +145,7 @@ ZEND_END_ARG_INFO()
#endif
#endif /* HAVE_UUID_VARIANT */
+#if HAVE_UUID_TIME
PHP_FUNCTION(uuid_time);
#if (PHP_MAJOR_VERSION >= 5)
ZEND_BEGIN_ARG_INFO_EX(uuid_time_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -154,6 +155,8 @@ ZEND_END_ARG_INFO()
#define uuid_time_arg_info NULL
#endif
+#endif /* HAVE_UUID_TIME */
+#if HAVE_UUID_MAC
PHP_FUNCTION(uuid_mac);
#if (PHP_MAJOR_VERSION >= 5)
ZEND_BEGIN_ARG_INFO_EX(uuid_mac_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -163,6 +166,7 @@ ZEND_END_ARG_INFO()
#define uuid_mac_arg_info NULL
#endif
+#endif /* HAVE_UUID_MAC */
PHP_FUNCTION(uuid_parse);
#if (PHP_MAJOR_VERSION >= 5)
ZEND_BEGIN_ARG_INFO_EX(uuid_parse_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -185,6 +189,14 @@ ZEND_END_ARG_INFO()
} // extern "C"
#endif
+#ifndef UUID_TYPE_DCE_TIME
+#ifdef __APPLE__
+/* UUID Type definitions */
+#define UUID_TYPE_DCE_TIME 1
+#define UUID_TYPE_DCE_RANDOM 4
+#endif /* __APPLE__ */
+#endif /* UUID_TYPE_DCE_TIME */
+
/* mirrored PHP Constants */
#define UUID_TYPE_DEFAULT 0
#define UUID_TYPE_TIME UUID_TYPE_DCE_TIME
diff --git a/uuid-1.0.3/tests/uuid_mac.phpt b/uuid-1.0.3/tests/uuid_mac.phpt
index 3d704ca..a4631de 100644
--- a/uuid-1.0.3/tests/uuid_mac.phpt
+++ b/uuid-1.0.3/tests/uuid_mac.phpt
@@ -5,6 +5,8 @@ uuid_mac() function
if(!extension_loaded('uuid')) die('skip ');
+if(!function_exists('uuid_mac')) die('skip not compiled in (HAVE_UUID_MAC)');
+
?>
--FILE--
<?php
diff --git a/uuid-1.0.3/tests/uuid_time.phpt b/uuid-1.0.3/tests/uuid_time.phpt
index 0a4f7e0..fe37468 100644
--- a/uuid-1.0.3/tests/uuid_time.phpt
+++ b/uuid-1.0.3/tests/uuid_time.phpt
@@ -5,6 +5,8 @@ uuid_time() function
if(!extension_loaded('uuid')) die('skip ');
+if(!function_exists('uuid_mac')) die('skip not compiled in (HAVE_UUID_TIME)');
+
?>
--FILE--
<?php
diff --git a/uuid-1.0.3/uuid.c b/uuid-1.0.3/uuid.c
index c09d2d3..8b6dc09 100644
--- a/uuid-1.0.3/uuid.c
+++ b/uuid-1.0.3/uuid.c
@@ -40,8 +40,12 @@ zend_function_entry uuid_functions[] = {
#if HAVE_UUID_VARIANT
PHP_FE(uuid_variant , uuid_variant_arg_info)
#endif /* HAVE_UUID_VARIANT */
+#if HAVE_UUID_TIME
PHP_FE(uuid_time , uuid_time_arg_info)
+#endif /* HAVE_UUID_TIME */
+#if HAVE_UUID_MAC
PHP_FE(uuid_mac , uuid_mac_arg_info)
+#endif /* HAVE_UUID_MAC */
PHP_FE(uuid_parse , uuid_parse_arg_info)
PHP_FE(uuid_unparse , uuid_unparse_arg_info)
{ NULL, NULL, NULL }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment