1 /* 2 * Copyright (c) 2013, 2015, 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/rt/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 "-W", "-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 // Create $buildDir/linux_tools.properties file and load props from it 60 setupTools("linux_tools", 61 { propFile -> 62 ByteArrayOutputStream results = new ByteArrayOutputStream(); 63 exec { 64 commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst"); 65 setStandardOutput(results); 66 } 67 propFile << "cflags=" << results.toString().trim() << "\n"; 68 69 results = new ByteArrayOutputStream(); 70 exec { 71 commandLine "pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst" 72 standardOutput = results 73 } 74 propFile << "libs=" << results.toString().trim(); 75 }, 76 { properties -> 77 ccFlags.addAll(properties.getProperty("cflags").split(" ")) 78 linkFlags.addAll(properties.getProperty("libs").split(" ")) 79 } 80 ) 81 82 def pangoCCFlags = ["-D_ENABLE_PANGO"]; 83 def pangoLinkFlags = []; 84 setupTools("linux_pango_tools", 85 { propFile -> 86 ByteArrayOutputStream results = new ByteArrayOutputStream(); 87 exec { 88 commandLine "pkg-config", "--cflags", "pangoft2" 89 standardOutput = results 90 } 91 propFile << "cflags=" << results.toString().trim() << "\n"; 92 93 results = new ByteArrayOutputStream(); 94 exec { 95 commandLine "pkg-config", "--libs", "pangoft2" 96 standardOutput = results 97 } 98 propFile << "libs=" << results.toString().trim(); 99 }, 100 { properties -> 101 pangoCCFlags.addAll(properties.getProperty("cflags").split(" ")) 102 pangoLinkFlags.addAll(properties.getProperty("libs").split(" ")) 103 } 104 ) 105 106 def freetypeCCFlags = [ext.IS_COMPILE_PANGO ? "-D_ENABLE_PANGO" : 107 ext.IS_COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""] 108 def freetypeLinkFlags = [] 109 setupTools("linux_freetype_tools", 110 { propFile -> 111 ByteArrayOutputStream results = new ByteArrayOutputStream(); 112 exec { 113 commandLine "pkg-config", "--cflags", "freetype2" 114 standardOutput = results 115 } 116 propFile << "cflags=" << results.toString().trim() << "\n"; 117 118 results = new ByteArrayOutputStream(); 119 exec { 120 commandLine "pkg-config", "--libs", "freetype2" 121 standardOutput = results 122 } 123 propFile << "libs=" << results.toString().trim(); 124 }, 125 { properties -> 126 freetypeCCFlags.addAll(properties.getProperty("cflags").split(" ")) 127 freetypeLinkFlags.addAll(properties.getProperty("libs").split(" ")) 128 } 129 ) 130 131 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc"; 132 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++"; 133 134 LINUX.glass = [:] 135 LINUX.glass.javahInclude = [ 136 "com/sun/glass/events/**", 137 "com/sun/glass/ui/*", 138 "com/sun/glass/ui/gtk/*"] 139 LINUX.glass.nativeSource = file("modules/graphics/src/main/native-glass/gtk") 140 LINUX.glass.compiler = compiler 141 LINUX.glass.ccFlags = [ccFlags, "-Werror"].flatten() 142 LINUX.glass.linker = linker 143 LINUX.glass.linkFlags = [linkFlags].flatten() 144 LINUX.glass.lib = "glass" 145 146 LINUX.decora = [:] 147 LINUX.decora.compiler = compiler 148 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten() 149 LINUX.decora.linker = linker 150 LINUX.decora.linkFlags = [linkFlags].flatten() 151 LINUX.decora.lib = "decora_sse" 152 153 LINUX.prism = [:] 154 LINUX.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 155 LINUX.prism.nativeSource = file("modules/graphics/src/main/native-prism") 156 LINUX.prism.compiler = compiler 157 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 158 LINUX.prism.linker = linker 159 LINUX.prism.linkFlags = [linkFlags].flatten() 160 LINUX.prism.lib = "prism_common" 161 162 LINUX.prismSW = [:] 163 LINUX.prismSW.javahInclude = ["com/sun/pisces/**/*"] 164 LINUX.prismSW.nativeSource = file("modules/graphics/src/main/native-prism-sw") 165 LINUX.prismSW.compiler = compiler 166 LINUX.prismSW.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 167 LINUX.prismSW.linker = linker 168 LINUX.prismSW.linkFlags = [linkFlags].flatten() 169 LINUX.prismSW.lib = "prism_sw" 170 171 LINUX.launcher = [:] 172 LINUX.launcher.compiler = compiler 173 LINUX.launcher.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c"] 174 LINUX.launcher.linker = linker 175 LINUX.launcher.linkFlags = ["-ldl"] 176 if (!IS_64) { 177 LINUX.launcher.ccFlags += "-m32" 178 LINUX.launcher.linkFlags += "-m32" 179 } 180 181 LINUX.launcherlibrary = [:] 182 LINUX.launcherlibrary.compiler = compiler 183 LINUX.launcherlibrary.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC"] 184 LINUX.launcherlibrary.linker = linker 185 LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared"] 186 if (!IS_64) { 187 LINUX.launcherlibrary.ccFlags += "-m32" 188 LINUX.launcherlibrary.linkFlags += "-m32" 189 } 190 191 LINUX.iio = [:] 192 LINUX.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 193 LINUX.iio.nativeSource = [ 194 file("modules/graphics/src/main/native-iio"), 195 file("modules/graphics/src/main/native-iio/libjpeg7")] 196 LINUX.iio.compiler = compiler 197 LINUX.iio.ccFlags = [ccFlags].flatten() 198 LINUX.iio.linker = linker 199 LINUX.iio.linkFlags = [linkFlags].flatten() 200 LINUX.iio.lib = "javafx_iio" 201 202 LINUX.prismES2 = [:] 203 LINUX.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 204 LINUX.prismES2.nativeSource = [ 205 file("modules/graphics/src/main/native-prism-es2"), 206 file("modules/graphics/src/main/native-prism-es2/GL"), 207 file("modules/graphics/src/main/native-prism-es2/x11") 208 ] 209 LINUX.prismES2.compiler = compiler 210 LINUX.prismES2.ccFlags = ["-DLINUX", ccFlags].flatten() 211 LINUX.prismES2.linker = linker 212 LINUX.prismES2.linkFlags = [linkFlags, "-lX11", "-lXxf86vm", "-lGL"].flatten() 213 LINUX.prismES2.lib = "prism_es2" 214 215 def closedDir = file("$projectDir/../rt-closed") 216 LINUX.font = [:] 217 LINUX.font.javahInclude = [ 218 "com/sun/javafx/font/**/*", 219 "com/sun/javafx/text/**/*"] 220 LINUX.font.compiler = compiler 221 LINUX.font.nativeSource = [file("modules/graphics/src/main/native-font")] 222 LINUX.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten() 223 LINUX.font.linker = linker 224 LINUX.font.linkFlags = [linkFlags].flatten() 225 LINUX.font.lib = "javafx_font" 226 227 LINUX.fontT2K = [:] 228 LINUX.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"] 229 LINUX.fontT2K.nativeSource = [ 230 file("$closedDir/javafx-font-t2k-native/src"), 231 file("$closedDir/javafx-font-t2k-native/src/layout")] 232 LINUX.fontT2K.compiler = compiler 233 LINUX.fontT2K.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags].flatten() 234 LINUX.fontT2K.linker = linker 235 LINUX.fontT2K.linkFlags = [linkFlags].flatten() 236 LINUX.fontT2K.lib = "javafx_font_t2k" 237 238 LINUX.fontFreetype = [:] 239 LINUX.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class"] 240 LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"] 241 LINUX.fontFreetype.compiler = compiler 242 LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, freetypeCCFlags].flatten() 243 LINUX.fontFreetype.linker = linker 244 LINUX.fontFreetype.linkFlags = [linkFlags, freetypeLinkFlags].flatten() 245 LINUX.fontFreetype.lib = "javafx_font_freetype" 246 247 LINUX.fontPango = [:] 248 LINUX.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"] 249 LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"] 250 LINUX.fontPango.compiler = compiler 251 LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten() 252 LINUX.fontPango.linker = linker 253 LINUX.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten() 254 LINUX.fontPango.lib = "javafx_font_pango" 255 256 LINUX.media = [:] 257 LINUX.media.compiler = compiler 258 LINUX.media.linker = linker 259 LINUX.media.lib = "ar"