Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 1 | From c84480be8df6966c538d1fb67ccae2f42cc46421 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 22 Mar 2016 07:36:54 +0000 |
| 4 | Subject: [PATCH 1/2] configure: Detect headers before using them |
| 5 | |
| 6 | Current logic does not work when system does not have |
| 7 | sys/endian.h, since it tried to reuse the cached results |
| 8 | from first try of detecting htole64 in sys/endian.h which is |
| 9 | 'no' and hence the second try to look into endian.h also |
| 10 | comes out negative. |
| 11 | |
| 12 | So we check for header and then run the test for symbols |
| 13 | and these symbols are not standard and we need to define _GNU_SOURCE |
| 14 | for it to work, this issue is exposed by systems using musl e.g. |
| 15 | |
| 16 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 17 | --- |
| 18 | Upstream-Status: Submitted |
| 19 | |
| 20 | configure.ac | 13 +++++++++---- |
| 21 | 1 file changed, 9 insertions(+), 4 deletions(-) |
| 22 | |
| 23 | diff --git a/configure.ac b/configure.ac |
| 24 | index 4cb56bc..5e23c50 100644 |
| 25 | --- a/configure.ac |
| 26 | +++ b/configure.ac |
| 27 | @@ -69,12 +69,17 @@ AC_FUNC_MALLOC |
| 28 | AC_FUNC_REALLOC |
| 29 | AC_FUNC_STRTOD |
| 30 | AC_CHECK_FUNCS([memchr memmove memset strerror strtol]) |
| 31 | -AC_CHECK_DECLS([htole64, le64toh], |
| 32 | - [], |
| 33 | +AC_CHECK_HEADER([sys/endian.h], |
| 34 | [ |
| 35 | - AC_CHECK_DECLS([htole64, le64toh], [], [], [#include <endian.h>]) |
| 36 | + AC_CHECK_DECLS([htole64, le64toh], [], [], [#define _GNU_SOURCE 1 #include <sys/endian.h>]) |
| 37 | ], |
| 38 | - [#include <sys/endian.h>]) |
| 39 | + [], []) |
| 40 | + |
| 41 | +AC_CHECK_HEADER([endian.h], |
| 42 | + [ |
| 43 | + AC_CHECK_DECLS([htole64, le64toh], [], [], [#define _GNU_SOURCE 1 #include <endian.h>]) |
| 44 | + ], |
| 45 | + [], []) |
| 46 | |
| 47 | AC_CONFIG_FILES([Makefile |
| 48 | src/Makefile |
| 49 | -- |
| 50 | 1.8.3.1 |
| 51 | |