--- config.m4.orig	2015-05-08 09:51:01.000000000 -0500
+++ config.m4	2016-09-27 06:45:51.000000000 -0500
@@ -21,16 +21,28 @@
   PHP_ADD_INCLUDE($PHP_UUID_DIR/include)
   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)
 
   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/$PHP_LIBDIR, 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/$PHP_LIBDIR, UUID_SHARED_LIBADD)
+  fi
   export CPPFLAGS="$OLD_CPPFLAGS"
 
-  PHP_SUBST(UUID_SHARED_LIBADD)
   AC_DEFINE(HAVE_UUID, 1, [ ])
 
   PHP_NEW_EXTENSION(uuid, uuid.c , $ext_shared)
--- php_uuid.h.orig	2015-05-08 09:51:01.000000000 -0500
+++ php_uuid.h	2016-09-27 07:07:15.000000000 -0500
@@ -124,15 +124,19 @@
 ZEND_END_ARG_INFO()
 #endif /* HAVE_UUID_VARIANT */
 
+#if HAVE_UUID_TIME
 PHP_FUNCTION(uuid_time);
 ZEND_BEGIN_ARG_INFO_EX(uuid_time_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
   ZEND_ARG_INFO(0, uuid)
 ZEND_END_ARG_INFO()
+#endif /* HAVE_UUID_TIME */
 
+#if HAVE_UUID_MAC
 PHP_FUNCTION(uuid_mac);
 ZEND_BEGIN_ARG_INFO_EX(uuid_mac_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
   ZEND_ARG_INFO(0, uuid)
 ZEND_END_ARG_INFO()
+#endif /* HAVE_UUID_MAC */
 
 PHP_FUNCTION(uuid_parse);
 ZEND_BEGIN_ARG_INFO_EX(uuid_parse_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
@@ -148,6 +152,14 @@
 } // 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 /* __MACOS__ */
+#endif /* UUID_TYPE_DCE_TIME */
+
 /* mirrored PHP Constants */
 #define UUID_TYPE_DEFAULT 0
 #define UUID_TYPE_TIME UUID_TYPE_DCE_TIME
@@ -157,8 +169,6 @@
 #define UUID_TYPE_NULL -1
 #define UUID_TYPE_INVALID -42
 
-#endif /* PHP_HAVE_UUID */
-
 #if PHP_MAJOR_VERSION < 7
 typedef long zend_long;
 typedef int  strsize;
@@ -170,6 +180,8 @@
 #define UUID_RETSTRL(a,l) RETURN_STRINGL(a,l)
 #endif
 
+#endif /* HAVE_UUID */
+
 #endif /* PHP_UUID_H */
 
 
--- tests/uuid_mac.phpt	2008-04-01 08:59:22.000000000 -0700
+++ tests/uuid_mac.phpt	2008-08-14 10:21:57.000000000 -0700
@@ -5,6 +5,8 @@
 
 if(!extension_loaded('uuid')) die('skip ');
 
+if(!function_exists('uuid_mac')) die('skip not compiled in (HAVE_UUID_MAC)');
+
  ?>
 --FILE--
 <?php
--- tests/uuid_time.phpt	2008-04-01 08:59:22.000000000 -0700
+++ tests/uuid_time.phpt	2008-08-14 10:22:50.000000000 -0700 
@@ -5,6 +5,8 @@
 
 if(!extension_loaded('uuid')) die('skip ');
 
+if(!function_exists('uuid_time')) die('skip not compiled in (HAVE_UUID_TIME)');
+
  ?>
 --FILE--
 <?php
--- uuid.c	2008-04-01 08:59:22.000000000 -0700
+++ uuid.c	2008-08-14 08:52:05.000000000 -0700
@@ -40,8 +40,12 @@
 #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 }