1 From 6a90da118a7ab787c675e25ff871f7f8aa03dc53 Mon Sep 17 00:00:00 2001
2 From: Frederik Schwan <frederik.schwan@linux.com>
3 Date: Wed, 19 Oct 2022 12:18:28 +0200
4 Subject: [PATCH] use the systems CFLAGS and LDFLAGS
6 (cherry picked from commit 7895d73c94aebec4786ab5dbdcdac0361aa3c548)
8 buildSrc/linux.gradle | 8 ++++++--
9 .../gstreamer/projects/linux/avplugin/Makefile | 16 ++++++----------
10 .../gstreamer/projects/linux/fxplugins/Makefile | 17 ++++++-----------
11 .../projects/linux/gstreamer-lite/Makefile | 16 ++++++----------
12 .../native/jfxmedia/projects/linux/Makefile | 16 ++++++----------
13 5 files changed, 30 insertions(+), 43 deletions(-)
15 diff --git a/buildSrc/linux.gradle b/buildSrc/linux.gradle
16 index 387d5eee06..ac3be55f6a 100644
17 --- a/buildSrc/linux.gradle
18 +++ b/buildSrc/linux.gradle
19 @@ -43,8 +43,11 @@ LINUX.library = { name -> return (IS_STATIC_BUILD ? "lib${name}.a" : "lib${name}
21 "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags
23 + "-Wno-error=cast-function-type",
24 "-Wextra", "-Wall", "-Wformat-security", "-Wno-unused", "-Wno-parentheses", "-Werror=trampolines"] // warning flags
26 +commonFlags.addAll(System.getenv("CFLAGS").trim().replaceAll(" +", " ").split(" "))
31 @@ -70,6 +73,7 @@ def dynamicLinkFlags = ["-static-libgcc", "-static-libstdc++", "-shared", common
32 def staticLinkFlags = [].flatten()
34 def linkFlags = IS_STATIC_BUILD ? staticLinkFlags : dynamicLinkFlags;
35 +linkFlags.addAll(System.getenv("LDFLAGS").trim().split(" "))
37 if (IS_DEBUG_NATIVE) {
39 @@ -284,7 +288,7 @@ LINUX.iio.nativeSource = [
40 LINUX.iio.compiler = compiler
41 LINUX.iio.ccFlags = [cFlags, "-fvisibility=hidden"].flatten()
42 LINUX.iio.linker = IS_STATIC_BUILD ? "ld" : linker
43 -LINUX.iio.linkFlags = [linkFlags].flatten()
44 +LINUX.iio.linkFlags = [linkFlags, "-ljpeg"].flatten()
45 LINUX.iio.lib = "javafx_iio"
48 @@ -332,5 +336,5 @@ LINUX.media.ar = "${toolchainDir}ar"
50 LINUX.webkit.compiler = compiler
51 LINUX.webkit.linker = linker
52 -LINUX.webkit.ccFlags = commonFlags.flatten()
53 +LINUX.webkit.ccFlags = [commonFlags, "-fno-lto"].flatten()
54 LINUX.webkit.linkFlags = linkFlags.flatten()
55 diff --git a/modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile b/modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile
56 index fbc3f45650..0e674d27ff 100644
57 --- a/modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile
58 +++ b/modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile
59 @@ -17,7 +17,7 @@ TARGET = $(BUILD_DIR)/lib$(BASE_NAME).so
60 OBJBASE_DIR = $(BUILD_DIR)/obj/plugins/avplugin
68 @@ -31,18 +31,13 @@ CFLAGS = -fPIC \
70 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_48 \
71 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_48 \
72 - -ffunction-sections -fdata-sections
73 + -ffunction-sections -fdata-sections \
76 ifneq (,$(findstring $(ARCH), x64 x32))
80 -ifeq ($(BUILD_TYPE), Release)
86 PACKAGES_INCLUDES := $(shell pkg-config --cflags glib-2.0)
87 PACKAGES_LIBS := $(shell pkg-config --libs glib-2.0 gobject-2.0)
89 @@ -52,11 +47,12 @@ INCLUDES= -I../../../plugins \
90 -I../../../gstreamer-lite/gstreamer/libs \
93 -LDFLAGS = -L$(BUILD_DIR) \
94 +LDFLAGS := -L$(BUILD_DIR) \
98 - -static-libgcc -static-libstdc++ -Wl,--gc-sections
99 + -static-libgcc -static-libstdc++ -Wl,--gc-sections \
102 ifneq ($(strip $(LIBAV_DIR)),)
103 INCLUDES += -I$(LIBAV_DIR)/include
104 diff --git a/modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile b/modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile
105 index d831760bbc..d29e13c765 100644
106 --- a/modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile
107 +++ b/modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile
108 @@ -14,7 +14,7 @@ DIRLIST = progressbuffer \
110 TARGET = $(BUILD_DIR)/lib$(BASE_NAME).so
117 @@ -33,19 +33,13 @@ CFLAGS = -fPIC \
119 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_48 \
120 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_48 \
121 - -ffunction-sections -fdata-sections
122 + -ffunction-sections -fdata-sections \
125 ifneq (,$(findstring $(ARCH), x64 x32))
129 -ifeq ($(BUILD_TYPE), Release)
136 INCLUDES = -I$(SRCBASE_DIR) \
137 $(addprefix -I$(SRCBASE_DIR)/,$(DIRLIST)) \
138 -I../../../gstreamer-lite/gstreamer \
139 @@ -54,9 +48,10 @@ INCLUDES = -I$(SRCBASE_DIR) \
140 PACKAGES_INCLUDES := $(shell pkg-config --cflags glib-2.0)
141 PACKAGES_LIBS := $(shell pkg-config --libs glib-2.0 gobject-2.0)
143 -LDFLAGS = -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS) \
144 +LDFLAGS := -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS) \
146 - -static-libgcc -static-libstdc++ -Wl,--gc-sections
147 + -static-libgcc -static-libstdc++ -Wl,--gc-sections \
152 diff --git a/modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile b/modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile
153 index 86ef57d154..0942421aa0 100644
154 --- a/modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile
155 +++ b/modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile
156 @@ -37,7 +37,7 @@ DIRLIST = gstreamer/gst \
158 TARGET = $(BUILD_DIR)/lib$(BASE_NAME).so
165 @@ -55,13 +55,8 @@ CFLAGS =-fPIC \
166 -DGST_DISABLE_LOADSAVE \
167 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_48 \
168 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_48 \
169 - -ffunction-sections -fdata-sections
171 -ifeq ($(BUILD_TYPE), Release)
176 + -ffunction-sections -fdata-sections \
179 INCLUDES = -I$(BASE_DIR)/plugins \
180 -I$(SRCBASE_DIR)/projects/build/linux/common \
181 @@ -79,9 +74,10 @@ INCLUDES = -I$(BASE_DIR)/plugins \
182 PACKAGES_INCLUDES := $(shell pkg-config --cflags alsa glib-2.0)
183 PACKAGES_LIBS := $(shell pkg-config --libs alsa glib-2.0 gobject-2.0 gmodule-2.0 gthread-2.0)
185 -LDFLAGS = -L$(BUILD_DIR) -lm $(PACKAGES_LIBS) \
186 +LDFLAGS := -L$(BUILD_DIR) -lm $(PACKAGES_LIBS) \
188 - -static-libgcc -static-libstdc++ -Wl,--gc-sections
189 + -static-libgcc -static-libstdc++ -Wl,--gc-sections \
194 diff --git a/modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile b/modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile
195 index fc10e0f88b..e944f6e3ce 100644
196 --- a/modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile
197 +++ b/modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile
198 @@ -42,7 +42,7 @@ DIRLIST = jni \
200 TARGET = $(BUILD_DIR)/lib$(BASE_NAME).so
202 -CFLAGS = -DTARGET_OS_LINUX=1 \
203 +CFLAGS := -DTARGET_OS_LINUX=1 \
205 -DGST_REMOVE_DEPRECATED \
206 -DGST_DISABLE_GST_DEBUG \
207 @@ -54,7 +54,8 @@ CFLAGS = -DTARGET_OS_LINUX=1 \
208 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_48 \
209 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_48 \
210 -Werror=deprecated-declarations \
211 - -ffunction-sections -fdata-sections
212 + -ffunction-sections -fdata-sections \
215 CPPFLAGS = -fno-rtti -ffunction-sections -fdata-sections
217 @@ -89,21 +90,16 @@ ifdef HOST_COMPILE
221 - LDFLAGS = -Wl,-rpath,\$$ORIGIN -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS) \
222 + LDFLAGS := -Wl,-rpath,\$$ORIGIN -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS) \
224 - -static-libgcc -static-libstdc++ -Wl,--gc-sections
225 + -static-libgcc -static-libstdc++ -Wl,--gc-sections \
228 CFLAGS += $(EXTRA_CFLAGS)
229 INCLUDES = $(BASE_INCLUDES)
230 LDFLAGS = -Wl,-rpath,\$$ORIGIN -L$(BUILD_DIR) $(EXTRA_LDFLAGS)
233 -ifeq ($(BUILD_TYPE), Release)
236 - CFLAGS += -g -Wall -D_DEBUG