From bf9878d6a02d781bda240432017bf7659b42bd75 Mon Sep 17 00:00:00 2001
From: Ioannis Kappas <ioannis.kappas@gmamil.com>
Date: Sat, 18 Jun 2022 14:39:18 +0100
Subject: [PATCH v5 2/3] Fix openjfx build issues occuring from merge

This is because the guix syntax or inputs have changed/updated since Alexey's
v4 patch.
---
 gnu/packages/java.scm | 88 +++++++++++++++++++++++++++++++++----------
 1 file changed, 69 insertions(+), 19 deletions(-)

diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 5185967960..8ac501252c 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2621,8 +2621,7 @@ (define-public java-openjfx-graphics
                   (ice-9 regex)
                   (ice-9 match))
        #:phases
-       (let* ((jdk (assoc-ref %build-inputs "jdk"))
-              (javac/h-flags
+       (let* ((javac/h-flags
                '(;; When javac is compiling code it doesn't link
                  ;; against rt.jar by default. Instead it uses special
                  ;; symbol file lib/ct.sym with class stubs.
@@ -2639,10 +2638,6 @@ (define-public java-openjfx-graphics
                '("-fno-strict-aliasing" "-fPIC" "-fno-omit-frame-pointer" ;; optimization flags
                  "-fstack-protector"
                  "-W" "-Wall" "-Wno-unused" "-Wno-parentheses"))
-              (cc-flags
-               `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
-                                "-I" ,(string-append jdk "/include")
-                                "-I" ,(string-append jdk "/include/linux")))
               (link-flags
                `("-static-libgcc" "-static-libstdc++" "-shared" ,@common-flags
                  "-z" "relro"
@@ -2832,6 +2827,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (decora-native-src "modules/graphics/src/main/native-decora")
                       (decora-src "modules/graphics/src/main/jsl-decora/")
                       (decora-classes "modules/graphics/build/classes/jsl-decora/")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (decora-cc-flags `(,@cc-flags "-ffast-math")))
                  (mkdir-p decora-gen-headers)
                  (apply invoke "javah"
@@ -2864,6 +2864,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (font-native-obj "modules/graphics/build/native/font/linux")
                       (font-native-src "modules/graphics/src/main/native-font")
                       ;;
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (font-cc-flags `("-DJFXFONT_PLUS" ,@cc-flags)))
                  (mkdir-p font-gen-headers)
                  (apply invoke "javah"
@@ -2898,6 +2903,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (font-freetype-native-lib "modules/graphics/build/libs/fontFreetype/linux/libjavafx_font_freetype.so")
                       (font-freetype-native-obj "modules/graphics/build/native/fontFreetype/linux")
                       (font-freetype-native-src "modules/graphics/src/main/native-font/freetype.c")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (font-freetype-cc-flags `("-DJFXFONT_PLUS" "-D_ENABLE_PANGO"
                                                 "$(pkg-config --cflags freetype2)" ,@cc-flags))
                       (font-freetype-link-flags `("$(pkg-config --libs freetype2)" ,@link-flags)))
@@ -2932,6 +2942,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (font-pango-native-lib "modules/graphics/build/libs/fontPango/linux/libjavafx_font_pango.so")
                       (font-pango-native-obj "modules/graphics/build/native/fontPango/linux")
                       (font-pango-native-src "modules/graphics/src/main/native-font/pango.c")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (font-pango-cc-flags `("-DJFXFONT_PLUS" "-D_ENABLE_PANGO"
                                              "$(pkg-config --cflags pangoft2)" ,@cc-flags))
                       (font-pango-link-flags `("$(pkg-config --libs pangoft2)" ,@link-flags)))
@@ -2967,10 +2982,17 @@ (class (match:suffix (regexp-exec rx class))))
                       (glass-native-lib "modules/graphics/build/libs/glass/linux/libglass.so")
                       (glass-native-obj "modules/graphics/build/native/glass/linux/glass")
                       (glass-native-src "modules/graphics/src/main/native-glass/gtk/launcher.c")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (glass-cc-flags
                        `(,@cc-flags
                          "$(pkg-config --cflags glib-2.0 gdk-2.0 gtk+-2.0 gthread-2.0 xtst)"
-                         "-Werror"))
+                         "-Werror"
+                         "-Wno-cast-function-type"
+                         ))
                       (glass-link-flags
                        `(,@link-flags "$(pkg-config --libs x11)" "-ldl"))
                       ;; glass-gtk2
@@ -2985,7 +3007,9 @@ (class (match:suffix (regexp-exec rx class))))
                          ;; version 2.62. GTimeVal s not year-2038-safe. Gtk
                          ;; 2.24 uses GTimeVal so our build is also failing.
                          "-Wno-deprecated-declarations"
-                         "-Werror"))
+                         "-Werror"
+                         "-Wno-cast-function-type"
+                         ))
                       (glass-gtk2-link-flags
                        `(,@link-flags
                          "$(pkg-config --libs gtk+-2.0 gthread-2.0 xtst)"))
@@ -2997,7 +3021,9 @@ (class (match:suffix (regexp-exec rx class))))
                       (glass-gtk3-cc-flags
                        `(,@cc-flags
                          "$(pkg-config --cflags gtk+-3.0 gthread-2.0 xtst)"
-                         "-Wno-deprecated-declarations" "-Werror"))
+                         "-Wno-deprecated-declarations" "-Werror"
+                         "-Wno-cast-function-type"
+                         ))
                       (glass-gtk3-link-flags
                        `(,@link-flags "$(pkg-config --libs gtk+-3.0 gthread-2.0 xtst)")))
                  ;; glass
@@ -3069,6 +3095,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (iio-native-lib "modules/graphics/build/libs/iio/linux/libjavafx_iio.so")
                       (iio-native-obj "modules/graphics/build/native/iio/linux")
                       (iio-native-src "modules/graphics/src/main/native-iio")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (iio-cc-flags cc-flags)
                       (iio-link-flags link-flags))
                  (mkdir-p iio-gen-headers)
@@ -3103,6 +3134,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (prism-native-lib "modules/graphics/build/libs/prism/linux/libprism_common.so")
                       (prism-native-obj "modules/graphics/build/native/prism/linux")
                       (prism-native-src "modules/graphics/src/main/native-prism")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (prism-cc-flags `(,@cc-flags "-DINLINE=inline"))
                       (prism-link-flags link-flags))
                  (mkdir-p prism-gen-headers)
@@ -3140,6 +3176,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (prism-es2-native-lib "modules/graphics/build/libs/prism/linux/libprism_es2.so")
                       (prism-es2-native-obj "modules/graphics/build/native/prismES2/linux")
                       (prism-es2-native-src "modules/graphics/src/main/native-prism-es2")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       (prism-es2-cc-flags `("-DLINUX" ,@cc-flags))
                       (prism-es2-link-flags
                        `(,@link-flags "$(pkg-config --libs x11 xxf86vm gl)"))
@@ -3184,6 +3225,11 @@ (class (match:suffix (regexp-exec rx class))))
                       (prism-sw-native-lib "modules/graphics/build/libs/prism/linux/libprism_sw.so")
                       (prism-sw-native-obj "modules/graphics/build/native/prismSW/linux")
                       (prism-sw-native-src "modules/graphics/src/main/native-prism-sw")
+                      (jdk (assoc-ref inputs "jdk"))
+                      (cc-flags
+                       `(,@common-flags "-c" "-ffunction-sections" "-fdata-sections"
+                                        "-I" ,(string-append jdk "/include")
+                                        "-I" ,(string-append jdk "/include/linux")))
                       ;;
                       (prism-sw-cc-flags `(,@cc-flags "-DINLINE=inline"))
                       (prism-sw-link-flags link-flags))
@@ -3418,16 +3464,20 @@ (define-public java-openjfx-web
                                               "\"-Wl,-rpath=" lib "\"")
                                (string-append "-DCMAKE_SYSTEM_PROCESSOR=" machine)
                                "-DJAVAFX_RELEASE_VERSION=8.0"
-                               "-W"
-                               "-Wall"
-                               "-Werror=implicit-function-declaration"
-                               "-Wl,--gc-sections"
-                               "-Wno-parentheses"
-                               "-Wno-unused"
-                               "-fPIC"
-                               "-fno-omit-frame-pointer"
-                               "-fno-strict-aliasing"
-                               "-fstack-protector")))))
+                               "-DCMAKE_CXX_FLAGS=\""
+                               (string-join (list "-W"
+                                                  "-DU_DEFINE_FALSE_AND_TRUE=1"
+                                                  "-Wall"
+                                                  "-Werror=implicit-function-declaration"
+                                                  "-Wl,--gc-sections"
+                                                  "-Wno-parentheses"
+                                                  "-Wno-unused"
+                                                  "-fPIC"
+                                                  "-fno-omit-frame-pointer"
+                                                  "-fno-strict-aliasing"
+                                                  "-fstack-protector")
+                                            " ")
+                               "\"")))))
              #t))
 
          (add-after 'compile-native-linux 'install-native
-- 
2.34.0

