Files
guru/sys-fs/sdformatlinux/files/sdFormatLinux-0.2.0-unhardcode-compiler-flags.patch
T

65 lines
1.9 KiB
Diff

Make it possible to specify custom CFLAGS/CXXFLAGS/etc in the environment
Also remove problematic flags that override distribution toolchain
configurations (even though they are equivalent right now).
--- sdFormatLinux-0.2.0.orig/Makefile
+++ sdFormatLinux-0.2.0/Makefile
@@ -5,32 +5,32 @@
BUILD := build
INCLUDES := include
SOURCES := source
-DEFINES := -D_FORTIFY_SOURCE=2
+DEFINES :=
# Compiler settings
ARCH :=
-CFLAGS := $(ARCH) -std=c17 -O2 -g -fPIE -fstrict-aliasing \
- -ffunction-sections -fdata-sections -fstack-protector-strong \
- -Wall -Wextra -Wstrict-aliasing=2
-CXXFLAGS := $(ARCH) -std=c++20 -O2 -g -fPIE -fstrict-aliasing \
- -ffunction-sections -fdata-sections -fstack-protector-strong \
- -Wall -Wextra -Wstrict-aliasing=2
-ASFLAGS := $(ARCH) -O2 -g -fPIE -x assembler-with-cpp
+CFLAGS := $(ARCH) -std=c17 -O2 -g -fstrict-aliasing \
+ -ffunction-sections -fdata-sections \
+ -Wall -Wextra -Wstrict-aliasing=2 $(CFLAGS)
+CXXFLAGS := $(ARCH) -std=c++20 -O2 -g -fstrict-aliasing \
+ -ffunction-sections -fdata-sections \
+ -Wall -Wextra -Wstrict-aliasing=2 $(CXXFLAGS)
+ASFLAGS := $(ARCH) -O2 -g -x assembler-with-cpp $(ASFLAGS)
ARFLAGS := -rcs
-LDFLAGS := $(ARCH) -O2 -s -pie -fPIE -Wl,--gc-sections,-z,relro,-z,now,-z,noexecstack
+LDFLAGS := $(ARCH) -O2 -Wl,--gc-sections $(LDFLAGS)
PREFIX :=
ifneq ($(strip $(USE_CLANG)),)
-CC := $(PREFIX)clang
-CXX := $(PREFIX)clang++
-AS := $(PREFIX)clang
-AR := $(PREFIX)gcc-ar
+CC ?= $(PREFIX)clang
+CXX ?= $(PREFIX)clang++
+AS ?= $(PREFIX)clang
+AR ?= $(PREFIX)gcc-ar
else
-CC := $(PREFIX)gcc
-CXX := $(PREFIX)g++
-AS := $(PREFIX)gcc
-AR := $(PREFIX)gcc-ar
+CC ?= $(PREFIX)gcc
+CXX ?= $(PREFIX)g++
+AS ?= $(PREFIX)gcc
+AR ?= $(PREFIX)gcc-ar
endif
@@ -107,4 +107,4 @@
@echo $(notdir $@)
$(AR) $(ARFLAGS) $@ $^
-endif
\ No newline at end of file
+endif