From 3bf376c0573bce8e5a7f348c2adfea2950a1b869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Tue, 3 Aug 2021 06:04:11 +0200 Subject: [PATCH] Don't use conditional assignment operator for CFLAGS/LDFLAGS The conditional variable assignment operator in Makefiles (`?=`) will only assign a value if its not defined yet. However, CFLAGS/LDFLAGS are commonly defined as environment variables to pass custom compiler/linker flags (e.g. `-Os`). Unfortunately, Cyclone adds mandatory compiler flags (without which it doesn't compile) via the conditional variable assignment operator which is incorrect as these flags will not be added if CFLAGS/LDFLAGS is defined in the environment. This commit fixes this issue by appending flags to CFLAGS/LDFLAGS instead of using the conditional assignment operator. --- Makefile.config | 4 ++-- Makefile.config.raspberry-pi-2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.config b/Makefile.config index 20d5b79c..8a2871ae 100644 --- a/Makefile.config +++ b/Makefile.config @@ -23,7 +23,7 @@ LIBS += -ldl endif # Compiler options -CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -Iinclude +CFLAGS += $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -Iinclude BASE_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -fPIC -Wall -Wno-shift-negative-value -Wno-unused-command-line-argument -I$(PREFIX)/include # Used by Cyclone to compile programs, no need for PIC there BASE_PROG_CFLAGS ?= $(CYC_PROFILING) $(CYC_GCC_OPT_FLAGS) -Wall -I$(PREFIX)/include @@ -40,7 +40,7 @@ endif #CFLAGS = -g -pg -Wall # Linker options -LDFLAGS ?= -L. $(CYC_PROFILING) +LDFLAGS += -L. $(CYC_PROFILING) LIBRARY_OUTPUT_FILE = libcyclone.a ifeq ($(OS),Darwin) LDFLAGS += -Wl,-undefined -Wl,dynamic_lookup diff --git a/Makefile.config.raspberry-pi-2 b/Makefile.config.raspberry-pi-2 index 13951db0..ddf51749 100644 --- a/Makefile.config.raspberry-pi-2 +++ b/Makefile.config.raspberry-pi-2 @@ -20,14 +20,14 @@ CREATE_LIBRARY_COMMAND = $(AR) CREATE_LIBRARY_FLAGS = rcs # Compiler options -CFLAGS ?= -O2 -fPIC -Wall -march=armv6k -Iinclude +CFLAGS += -O2 -fPIC -Wall -march=armv6k -Iinclude COMP_CFLAGS ?= -O2 -fPIC -Wall -march=armv6k -I$(PREFIX)/include -L$(PREFIX)/lib # Use these lines instead for debugging or profiling #CFLAGS = -g -Wall #CFLAGS = -g -pg -Wall # Linker options -LDFLAGS ?= -L. +LDFLAGS += -L. ifeq ($(OS),Darwin) LDFLAGS += -Wl,-export_dynamic -Wl,-undefined -Wl,dynamic_lookup COMP_CFLAGS += -Wl,-export_dynamic