Alex James has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/60220 )
Change subject: cbfstool: Fix compilation on macOS ......................................................................
cbfstool: Fix compilation on macOS
Change-Id: Id5997d6d00e12f9f960550e72333ec354593501c Signed-off-by: Alex James theracermaster@gmail.com --- M util/cbfstool/Makefile M util/cbfstool/Makefile.inc M util/cbfstool/flashmap/fmap.c M util/cbfstool/swab.h 4 files changed, 6 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/20/60220/1
diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile index e853ae5..6edaa0c 100644 --- a/util/cbfstool/Makefile +++ b/util/cbfstool/Makefile @@ -3,6 +3,7 @@
CONFIG_FMD_GENPARSER ?= n
+OS_ARCH = $(shell uname) HOSTCC ?= $(CC) PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin diff --git a/util/cbfstool/Makefile.inc b/util/cbfstool/Makefile.inc index 4651f51..43bc5a91 100644 --- a/util/cbfstool/Makefile.inc +++ b/util/cbfstool/Makefile.inc @@ -134,7 +134,7 @@ TOOLLDFLAGS ?= HOSTCFLAGS += -fms-extensions
-ifneq ($(shell uname -o 2>/dev/null), FreeBSD) +ifneq ($(OS_ARCH),$(filter $(OS_ARCH),Darwin FreeBSD)) TOOLCPPFLAGS += -D_XOPEN_SOURCE=700 # strdup() from string.h endif
diff --git a/util/cbfstool/flashmap/fmap.c b/util/cbfstool/flashmap/fmap.c index cb67b46..7010dbc 100644 --- a/util/cbfstool/flashmap/fmap.c +++ b/util/cbfstool/flashmap/fmap.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause or GPL-2.0-only */
#include <ctype.h> -#include <endian.h> #include <stdlib.h> #include <stdio.h> #include <string.h> diff --git a/util/cbfstool/swab.h b/util/cbfstool/swab.h index a45a767..88e41a4 100644 --- a/util/cbfstool/swab.h +++ b/util/cbfstool/swab.h @@ -21,8 +21,12 @@ #else #include <arpa/inet.h> #endif +#ifndef ntohll #define ntohll(x) (is_big_endian() ? (uint64_t)(x) : swab64(x)) +#endif +#ifndef htonll #define htonll(x) (is_big_endian() ? (uint64_t)(x) : swab64(x)) +#endif
/* casts are necessary for constants, because we never know how for sure * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way.