1 /* 2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 ext.LINUX = [:] 27 28 // Declare whether this particular target file applies to the current system 29 LINUX.canBuild = IS_LINUX; 30 if (!LINUX.canBuild) return; 31 32 // All desktop related packages should be built 33 LINUX.compileSwing = true; 34 LINUX.compileSWT = true; 35 LINUX.compileFXPackager = true; 36 37 // Libraries end up in the lib/$OS_ARCH directory for Linux 38 LINUX.libDest = "lib/$OS_ARCH" 39 LINUX.modulesArch = "$OS_ARCH" 40 41 // Lambda for naming the generated libs 42 LINUX.library = { name -> return "lib${name}.so" as String } 43 44 // A set of common parameters to use for both compiling and linking 45 def commonFlags = [ 46 "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags 47 "-Wextra", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags 48 49 if (!IS_64) { 50 commonFlags += "-m32" 51 } 52 53 // Specify the compilation parameters and link parameters 54 def ccFlags = [ 55 commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", 56 IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten() 57 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"]) 58 def linkFlags = ["-shared", commonFlags].flatten() 59 60 if (IS_DEBUG_NATIVE) { 61 linkFlags += "-g" 62 } 63 64 // Create $buildDir/linux_tools.properties file and load props from it 65 setupTools("linux_tools", 66 { propFile -> 67 ByteArrayOutputStream results = new ByteArrayOutputStream(); 68 exec { 69 commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst"); 70 setStandardOutput(results); 71 } 72 propFile << "cflags=" << results.toString().trim() << "\n"; 73 74 results = new ByteArrayOutputStream(); 75 exec { 76 commandLine "pkg-config", "--libs", "pangocairo", "gio-2.0", "gthread-2.0", "xtst" 77 standardOutput = results 78 } 79 propFile << "libs=" << results.toString().trim(); 80 }, 81 { properties -> 82 ccFlags.addAll(properties.getProperty("cflags").split(" ")) 83 linkFlags.addAll(properties.getProperty("libs").split(" ")) 84 } 85 ) 86 87 def pangoCCFlags = ["-D_ENABLE_PANGO"]; 88 def pangoLinkFlags = []; 89 setupTools("linux_pango_tools", 90 { propFile -> 91 ByteArrayOutputStream results = new ByteArrayOutputStream(); 92 exec { 93 commandLine "pkg-config", "--cflags", "pangoft2" 94 standardOutput = results 95 } 96 propFile << "cflags=" << results.toString().trim() << "\n"; 97 98 results = new ByteArrayOutputStream(); 99 exec { 100 commandLine "pkg-config", "--libs", "pangoft2" 101 standardOutput = results 102 } 103 propFile << "libs=" << results.toString().trim(); 104 }, 105 { properties -> 106 pangoCCFlags.addAll(properties.getProperty("cflags").split(" ")) 107 pangoLinkFlags.addAll(properties.getProperty("libs").split(" ")) 108 } 109 ) 110 111 def freetypeCCFlags = [ext.IS_COMPILE_PANGO ? "-D_ENABLE_PANGO" : 112 ext.IS_COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""] 113 def freetypeLinkFlags = [] 114 setupTools("linux_freetype_tools", 115 { propFile -> 116 ByteArrayOutputStream results = new ByteArrayOutputStream(); 117 exec { 118 commandLine "pkg-config", "--cflags", "freetype2" 119 standardOutput = results 120 } 121 propFile << "cflags=" << results.toString().trim() << "\n"; 122 123 results = new ByteArrayOutputStream(); 124 exec { 125 commandLine "pkg-config", "--libs", "freetype2" 126 standardOutput = results 127 } 128 propFile << "libs=" << results.toString().trim(); 129 }, 130 { properties -> 131 freetypeCCFlags.addAll(properties.getProperty("cflags").split(" ")) 132 freetypeLinkFlags.addAll(properties.getProperty("libs").split(" ")) 133 } 134 ) 135 136 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc"; 137 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++"; 138 139 LINUX.glass = [:] 140 LINUX.glass.javahInclude = [ 141 "com/sun/glass/events/**", 142 "com/sun/glass/ui/*", 143 "com/sun/glass/ui/gtk/*"] 144 LINUX.glass.nativeSource = file("${project(":graphics").projectDir}/src/main/native-glass/gtk") 145 LINUX.glass.compiler = compiler 146 LINUX.glass.ccFlags = [ccFlags, "-Werror"].flatten() 147 LINUX.glass.linker = linker 148 LINUX.glass.linkFlags = [linkFlags ].flatten() 149 LINUX.glass.lib = "glass" 150 151 LINUX.decora = [:] 152 LINUX.decora.compiler = compiler 153 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten() 154 LINUX.decora.linker = linker 155 LINUX.decora.linkFlags = [linkFlags].flatten() 156 LINUX.decora.lib = "decora_sse" 157 158 LINUX.prism = [:] 159 LINUX.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 160 LINUX.prism.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism") 161 LINUX.prism.compiler = compiler 162 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 163 LINUX.prism.linker = linker 164 LINUX.prism.linkFlags = [linkFlags].flatten() 165 LINUX.prism.lib = "prism_common" 166 167 LINUX.prismSW = [:] 168 LINUX.prismSW.javahInclude = ["com/sun/pisces/**/*"] 169 LINUX.prismSW.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism-sw") 170 LINUX.prismSW.compiler = compiler 171 LINUX.prismSW.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 172 LINUX.prismSW.linker = linker 173 LINUX.prismSW.linkFlags = [linkFlags].flatten() 174 LINUX.prismSW.lib = "prism_sw" 175 176 LINUX.launcher = [:] 177 LINUX.launcher.compiler = compiler 178 LINUX.launcher.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c"] 179 LINUX.launcher.linker = linker 180 LINUX.launcher.linkFlags = ["-ldl"] 181 if (!IS_64) { 182 LINUX.launcher.ccFlags += "-m32" 183 LINUX.launcher.linkFlags += "-m32" 184 } 185 186 LINUX.launcherlibrary = [:] 187 LINUX.launcherlibrary.compiler = compiler 188 LINUX.launcherlibrary.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC"] 189 LINUX.launcherlibrary.linker = linker 190 LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared"] 191 if (!IS_64) { 192 LINUX.launcherlibrary.ccFlags += "-m32" 193 LINUX.launcherlibrary.linkFlags += "-m32" 194 } 195 196 LINUX.iio = [:] 197 LINUX.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 198 LINUX.iio.nativeSource = [ 199 file("${project("graphics").projectDir}/src/main/native-iio"), 200 file("${project("graphics").projectDir}/src/main/native-iio/libjpeg7")] 201 LINUX.iio.compiler = compiler 202 LINUX.iio.ccFlags = [ccFlags].flatten() 203 LINUX.iio.linker = linker 204 LINUX.iio.linkFlags = [linkFlags].flatten() 205 LINUX.iio.lib = "javafx_iio" 206 207 LINUX.prismES2 = [:] 208 LINUX.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 209 LINUX.prismES2.nativeSource = [ 210 file("${project("graphics").projectDir}/src/main/native-prism-es2"), 211 file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"), 212 file("${project("graphics").projectDir}/src/main/native-prism-es2/x11") 213 ] 214 LINUX.prismES2.compiler = compiler 215 LINUX.prismES2.ccFlags = ["-DLINUX", ccFlags].flatten() 216 LINUX.prismES2.linker = linker 217 LINUX.prismES2.linkFlags = [linkFlags, "-lX11", "-lXxf86vm", "-lGL"].flatten() 218 LINUX.prismES2.lib = "prism_es2" 219 220 def closedDir = file("$projectDir/../rt-closed") 221 LINUX.font = [:] 222 LINUX.font.javahInclude = [ 223 "com/sun/javafx/font/**/*", 224 "com/sun/javafx/text/**/*"] 225 LINUX.font.compiler = compiler 226 LINUX.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")] 227 LINUX.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten() 228 LINUX.font.linker = linker 229 LINUX.font.linkFlags = [linkFlags].flatten() 230 LINUX.font.lib = "javafx_font" 231 232 LINUX.fontT2K = [:] 233 LINUX.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"] 234 LINUX.fontT2K.nativeSource = [ 235 file("$closedDir/javafx-font-t2k-native/src"), 236 file("$closedDir/javafx-font-t2k-native/src/layout")] 237 LINUX.fontT2K.compiler = compiler 238 LINUX.fontT2K.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags].flatten() 239 LINUX.fontT2K.linker = linker 240 LINUX.fontT2K.linkFlags = [linkFlags].flatten() 241 LINUX.fontT2K.lib = "javafx_font_t2k" 242 243 LINUX.fontFreetype = [:] 244 LINUX.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class"] 245 LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"] 246 LINUX.fontFreetype.compiler = compiler 247 LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, freetypeCCFlags].flatten() 248 LINUX.fontFreetype.linker = linker 249 LINUX.fontFreetype.linkFlags = [linkFlags, freetypeLinkFlags].flatten() 250 LINUX.fontFreetype.lib = "javafx_font_freetype" 251 252 LINUX.fontPango = [:] 253 LINUX.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"] 254 LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"] 255 LINUX.fontPango.compiler = compiler 256 LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten() 257 LINUX.fontPango.linker = linker 258 LINUX.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten() 259 LINUX.fontPango.lib = "javafx_font_pango" 260 261 LINUX.media = [:] 262 LINUX.media.compiler = compiler 263 LINUX.media.linker = linker 264 LINUX.media.ar = "ar"