libfaketime: Fix build with clang

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2023-08-24 01:53:02 -07:00
parent 50b820e18e
commit 8b40d7c92f
2 changed files with 49 additions and 3 deletions

View File

@ -0,0 +1,45 @@
From 735bb5d053efad274aa4ea5a6682e656ff792909 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 24 Aug 2023 01:49:48 -0700
Subject: [PATCH] Makefile: Detect compiler in makefile
Add compiler specific options based on detected compiler gcc/clang
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/Makefile | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/Makefile b/src/Makefile
index 62e924c..c15eb33 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -110,7 +110,23 @@ PREFIX ?= /usr/local
LIBDIRNAME ?= /lib/faketime
PLATFORM ?=$(shell uname)
-CFLAGS += -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' $(FAKETIME_COMPILE_CFLAGS)
+ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
+COMPILER := clang
+else
+COMPILER := gcc
+endif
+export COMPILER
+
+CFLAGS += -std=gnu99 -Wall -Wextra -Werror -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' $(FAKETIME_COMPILE_CFLAGS)
+
+ifeq ($(COMPILER),clang)
+CFLAGS += -Wno-tautological-pointer-compare
+endif
+
+ifeq ($(COMPILER),gcc)
+CFLAGS += -Wno-nonnull-compare
+endif
+
ifeq ($(PLATFORM),SunOS)
CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
endif
--
2.42.0

View File

@ -4,9 +4,10 @@ LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRCREV = "d475b925943ad404c6c728ac868dc73949e7281c"
SRC_URI = "\
git://git@github.com/wolfcw/libfaketime.git;branch=master;protocol=https \
"
SRC_URI = "git://github.com/wolfcw/libfaketime.git;branch=master;protocol=https \
file://0001-Makefile-Detect-compiler-in-makefile.patch \
"
S = "${WORKDIR}/git"