Repository: conan-io/conan-center-index

Issue:
[package] libuuid/1.0.3: apple_clang 12 build broken by patch
build of libuuid 1.0.3 is broken on macOS11 / apple-clang 12 due to applied patch
the define HAVE_SYS_TIME_H seems to be not defined but the include is valid

```
+#if defined(HAVE_SYS_TIME_H)
 #include <sys/time.h>
+#endif
```

this can be fixed by 

```
+#if defined(HAVE_SYS_TIME_H) || defined(__APPLE__)
 #include <sys/time.h>
+#endif
```

but I guess there is a better way to ensure the define is set for apple platform



Discussion:
Weird.
Can you please post the complete output of:
```
conan create recipes/libuuid/all libuuid/1.0.3@
```
And post the content of `config.log`, which can be found in:
```
~/.conan/data/libuuid/1.0.3/_/_/build/<your_build_hash>/source_subfolder/config.log
```
[config.log](https://github.com/conan-io/conan-center-index/files/5657718/config.log)
The log contains a HAVE_SYS_TIME_H 1 but build fails with:
```
...
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -DNDEBUG -I. -m64 -O3 -mstackrealign -fPIC -MT libuuid_la-parse.lo -MD -MP -MF .deps/libuuid_la-parse.Tpo -c parse.c -o libuuid_la-parse.o
randutils.c:41:2: error: implicit declaration of function 'gettimeofday' is
      invalid in C99 [-Werror,-Wimplicit-function-declaration]
        gettimeofday(&tv, 0);
        ^
1 error generated.
gen_uuid.c:362:34: warning: format specifies type 'unsigned long' but the
      argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]
                              clock_seq, last.tv_sec, last.tv_usec, adjustment);
                                                      ^~~~~~~~~~~~
```
seems that the define is not available in randutils.c error above is gone if sys/time.h include is available 

Resolving patch:
diff --git a/recipes/libuuid/all/conanfile.py b/recipes/libuuid/all/conanfile.py
--- a/recipes/libuuid/all/conanfile.py
+++ b/recipes/libuuid/all/conanfile.py
@@ -35,29 +35,34 @@ def configure(self):
         del self.settings.compiler.libcxx
         del self.settings.compiler.cppstd
 
+    def build_requirements(self):
+        self.build_requires("libtool/2.4.6")
+
     def _configure_autotools(self):
-        if not self._autotools:
-            configure_args = [
-                "--enable-shared=%s" % ("yes" if self.options.shared else "no"),
-                "--enable-static=%s" % ("no" if self.options.shared else "yes")
-                ]
-            self._autotools = AutoToolsBuildEnvironment(self)
-            if "x86" in self.settings.arch:
-                self._autotools.flags.append('-mstackrealign')
-            self._autotools.configure(args=configure_args)
+        if self._autotools:
+            return self._autotools
+        self._autotools = AutoToolsBuildEnvironment(self)
+        yes_no = lambda v: "yes" if v else "no"
+        configure_args = [
+            "--enable-shared={}".format(yes_no(self.options.shared)),
+            "--enable-static={}".format(yes_no(not self.options.shared)),
+        ]
+        if "x86" in self.settings.arch:
+            self._autotools.flags.append('-mstackrealign')
+        self._autotools.configure(args=configure_args, configure_dir=self._source_subfolder)
         return self._autotools
 
     def build(self):
         self._patch_sources()
         with tools.chdir(self._source_subfolder):
-            autotools = self._configure_autotools()
-            autotools.make()
+            self.run("autoreconf -fiv", run_environment=True)
+        autotools = self._configure_autotools()
+        autotools.make()
 
     def package(self):
         self.copy("COPYING", dst="licenses", src=self._source_subfolder)
-        with tools.chdir(self._source_subfolder):
-            autotools = self._configure_autotools()
-            autotools.install()
+        autotools = self._configure_autotools()
+        autotools.install()
         la_file = os.path.join(self.package_folder, "lib", "libuuid.la")
         if os.path.isfile(la_file):
             os.unlink(la_file)


Test patch: