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 sdk/lib/$OS_ARCH directory for Linux 38 LINUX.libDest = "lib/$OS_ARCH" 39 40 // Lambda for naming the generated libs 41 LINUX.library = { name -> return "lib${name}.so" as String } 42 43 // A set of common parameters to use for both compiling and linking 44 def commonFlags = [ 45 "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags 46 "-Wextra", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags 47 48 if (!IS_64) { 49 commonFlags += "-m32" 50 } 51 52 // Specify the compilation parameters and link parameters 53 def ccFlags = [ 54 commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", 55 IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten() 56 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"]) 57 def linkFlags = ["-shared", commonFlags].flatten() 58 59 if (IS_DEBUG_NATIVE) { 60 linkFlags += "-g" 61 } 62 63 // Create $buildDir/linux_tools.properties file and load props from it 64 setupTools("linux_tools", 65 { propFile -> 66 ByteArrayOutputStream results = new ByteArrayOutputStream(); 67 exec { 68 commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst"); 69 setStandardOutput(results); 70 } 71 propFile << "cflags=" << results.toString().trim() << "\n"; 72 73 results = new ByteArrayOutputStream(); 74 exec { 75 commandLine "pkg-config", "--libs", "pangocairo", "gio-2.0", "gthread-2.0", "xtst" 76 standardOutput = results 77 } 78 propFile << "libs=" << results.toString().trim(); 79 }, 80 { properties -> 81 ccFlags.addAll(properties.getProperty("cflags").split(" ")) 82 linkFlags.addAll(properties.getProperty("libs").split(" ")) 83 } 84 ) 85 86 def pangoCCFlags = ["-D_ENABLE_PANGO"]; 87 def pangoLinkFlags = []; 88 setupTools("linux_pango_tools", 89 { propFile -> 90 ByteArrayOutputStream results = new ByteArrayOutputStream(); 91 exec { 92 commandLine "pkg-config", "--cflags", "pangoft2" 93 standardOutput = results 94 } 95 propFile << "cflags=" << results.toString().trim() << "\n"; 96 97 results = new ByteArrayOutputStream(); 98 exec { 99 commandLine "pkg-config", "--libs", "pangoft2" 100 standardOutput = results 101 } 102 propFile << "libs=" << results.toString().trim(); 103 }, 104 { properties -> 105 pangoCCFlags.addAll(properties.getProperty("cflags").split(" ")) 106 pangoLinkFlags.addAll(properties.getProperty("libs").split(" ")) 107 } 108 ) 109 110 def freetypeCCFlags = [ext.IS_COMPILE_PANGO ? "-D_ENABLE_PANGO" : 111 ext.IS_COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""] 112 def freetypeLinkFlags = [] 113 setupTools("linux_freetype_tools", 114 { propFile -> 115 ByteArrayOutputStream results = new ByteArrayOutputStream(); 116 exec { 117 commandLine "pkg-config", "--cflags", "freetype2" 118 standardOutput = results 119 } 120 propFile << "cflags=" << results.toString().trim() << "\n"; 121 122 results = new ByteArrayOutputStream(); 123 exec { 124 commandLine "pkg-config", "--libs", "freetype2" 125 standardOutput = results 126 } 127 propFile << "libs=" << results.toString().trim(); 128 }, 129 { properties -> 130 freetypeCCFlags.addAll(properties.getProperty("cflags").split(" ")) 131 freetypeLinkFlags.addAll(properties.getProperty("libs").split(" ")) 132 } 133 ) 134 135 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc"; 136 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++"; 137 138 LINUX.glass = [:] 139 LINUX.glass.javahInclude = [ 140 "com/sun/glass/events/**", 141 "com/sun/glass/ui/*", 142 "com/sun/glass/ui/gtk/*"] 143 LINUX.glass.nativeSource = file("${project(":graphics").projectDir}/src/main/native-glass/gtk") 144 LINUX.glass.compiler = compiler 145 LINUX.glass.ccFlags = [ccFlags, "-Werror"].flatten() 146 LINUX.glass.linker = linker 147 LINUX.glass.linkFlags = [linkFlags ].flatten() 148 LINUX.glass.lib = "glass" 149 150 LINUX.decora = [:] 151 LINUX.decora.compiler = compiler 152 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten() 153 LINUX.decora.linker = linker 154 LINUX.decora.linkFlags = [linkFlags].flatten() 155 LINUX.decora.lib = "decora_sse" 156 157 LINUX.prism = [:] 158 LINUX.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 159 LINUX.prism.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism") 160 LINUX.prism.compiler = compiler 161 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 162 LINUX.prism.linker = linker 163 LINUX.prism.linkFlags = [linkFlags].flatten() 164 LINUX.prism.lib = "prism_common" 165 166 LINUX.prismSW = [:] 167 LINUX.prismSW.javahInclude = ["com/sun/pisces/**/*"] 168 LINUX.prismSW.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism-sw") 169 LINUX.prismSW.compiler = compiler 170 LINUX.prismSW.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 171 LINUX.prismSW.linker = linker 172 LINUX.prismSW.linkFlags = [linkFlags].flatten() 173 LINUX.prismSW.lib = "prism_sw" 174 175 LINUX.launcher = [:] 176 LINUX.launcher.compiler = compiler 177 LINUX.launcher.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c"] 178 LINUX.launcher.linker = linker 179 LINUX.launcher.linkFlags = ["-ldl"] 180 if (!IS_64) { 181 LINUX.launcher.ccFlags += "-m32" 182 LINUX.launcher.linkFlags += "-m32" 183 } 184 185 LINUX.launcherlibrary = [:] 186 LINUX.launcherlibrary.compiler = compiler 187 LINUX.launcherlibrary.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC"] 188 LINUX.launcherlibrary.linker = linker 189 LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared"] 190 if (!IS_64) { 191 LINUX.launcherlibrary.ccFlags += "-m32" 192 LINUX.launcherlibrary.linkFlags += "-m32" 193 } 194 195 LINUX.iio = [:] 196 LINUX.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 197 LINUX.iio.nativeSource = [ 198 file("${project("graphics").projectDir}/src/main/native-iio"), 199 file("${project("graphics").projectDir}/src/main/native-iio/libjpeg7")] 200 LINUX.iio.compiler = compiler 201 LINUX.iio.ccFlags = [ccFlags].flatten() 202 LINUX.iio.linker = linker 203 LINUX.iio.linkFlags = [linkFlags].flatten() 204 LINUX.iio.lib = "javafx_iio" 205 206 LINUX.prismES2 = [:] 207 LINUX.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 208 LINUX.prismES2.nativeSource = [ 209 file("${project("graphics").projectDir}/src/main/native-prism-es2"), 210 file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"), 211 file("${project("graphics").projectDir}/src/main/native-prism-es2/x11") 212 ] 213 LINUX.prismES2.compiler = compiler 214 LINUX.prismES2.ccFlags = ["-DLINUX", ccFlags].flatten() 215 LINUX.prismES2.linker = linker 216 LINUX.prismES2.linkFlags = [linkFlags, "-lX11", "-lXxf86vm", "-lGL"].flatten() 217 LINUX.prismES2.lib = "prism_es2" 218 219 def closedDir = file("$projectDir/../rt-closed") 220 LINUX.font = [:] 221 LINUX.font.javahInclude = [ 222 "com/sun/javafx/font/**/*", 223 "com/sun/javafx/text/**/*"] 224 LINUX.font.compiler = compiler 225 LINUX.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")] 226 LINUX.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten() 227 LINUX.font.linker = linker 228 LINUX.font.linkFlags = [linkFlags].flatten() 229 LINUX.font.lib = "javafx_font" 230 231 LINUX.fontT2K = [:] 232 LINUX.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"] 233 LINUX.fontT2K.nativeSource = [ 234 file("$closedDir/javafx-font-t2k-native/src"), 235 file("$closedDir/javafx-font-t2k-native/src/layout")] 236 LINUX.fontT2K.compiler = compiler 237 LINUX.fontT2K.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags].flatten() 238 LINUX.fontT2K.linker = linker 239 LINUX.fontT2K.linkFlags = [linkFlags].flatten() 240 LINUX.fontT2K.lib = "javafx_font_t2k" 241 242 LINUX.fontFreetype = [:] 243 LINUX.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class"] 244 LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"] 245 LINUX.fontFreetype.compiler = compiler 246 LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, freetypeCCFlags].flatten() 247 LINUX.fontFreetype.linker = linker 248 LINUX.fontFreetype.linkFlags = [linkFlags, freetypeLinkFlags].flatten() 249 LINUX.fontFreetype.lib = "javafx_font_freetype" 250 251 LINUX.fontPango = [:] 252 LINUX.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"] 253 LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"] 254 LINUX.fontPango.compiler = compiler 255 LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten() 256 LINUX.fontPango.linker = linker 257 LINUX.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten() 258 LINUX.fontPango.lib = "javafx_font_pango" 259 260 LINUX.media = [:] 261 LINUX.media.compiler = compiler 262 LINUX.media.linker = linker 263 LINUX.media.ar = "ar"