1From 5f26eaf8d7be760fafe11ef4a6e0f907e7e8c3f0 Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Mon, 10 Jan 2022 23:17:45 +0100
4Subject: [PATCH] Makefile: add DISABLE_WERROR
5
6Allow the user to disable -Werror to avoid the following build failure
7with gcc 4.8 raised since version 0.6.0 and
8https://github.com/intel/tinycbor/commit/e2a4ed135c4d9101c4df83f2dd033cd249b6ef07:
9
10/home/buildroot/autobuild/instance-1/output-1/host/bin/arm-none-linux-gnueabi-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I./src -std=gnu99 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os -g0 -D_FORTIFY_SOURCE=1 -Werror=incompatible-pointer-types -Werror=implicit-function-declaration -Werror=int-conversion -fPIC  -c -o src/cborerrorstrings.pic.o src/cborerrorstrings.c
11cc1: error: -Werror=incompatible-pointer-types: no option -Wincompatible-pointer-types
12cc1: error: -Werror=int-conversion: no option -Wint-conversion
13
14Fixes:
15 - http://autobuild.buildroot.org/results/a9f/a9fe64c42bb96f9e7b4af3050464f6570c1c00fa
16
17Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
18[Retrieved from:
19https://github.com/intel/tinycbor/commit/5f26eaf8d7be760fafe11ef4a6e0f907e7e8c3f0]
20---
21 Makefile | 7 ++++++-
22 1 file changed, 6 insertions(+), 1 deletion(-)
23
24diff --git a/Makefile b/Makefile
25index 6492ea16..3cde2b3d 100644
26--- a/Makefile
27+++ b/Makefile
28@@ -236,10 +236,15 @@ tag: distcheck
29 .SECONDARY:
30
31 cflags := $(CPPFLAGS) -I$(SRCDIR)src
32-cflags += -std=gnu99 $(CFLAGS) \
33+cflags += -std=gnu99 $(CFLAGS)
34+
35+ifneq ($(DISABLE_WERROR),1)
36+cflags += \
37 	-Werror=incompatible-pointer-types \
38 	-Werror=implicit-function-declaration \
39 	-Werror=int-conversion
40+endif
41+
42 %.o: %.c
43 	@test -d $(@D) || $(MKDIR) $(@D)
44 	$(CC) $(cflags) $($(basename $(notdir $@))_CCFLAGS) -c -o $@ $<
45