1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/tools/MakeDeps/Platform.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,185 @@ 1.4 +/* 1.5 + * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +/** Defines what must be specified for each platform. This class must 1.29 + have a no-arg constructor. */ 1.30 + 1.31 +import java.io.*; 1.32 + 1.33 +public abstract class Platform { 1.34 + /** file name templates capture naming conventions */ 1.35 + protected FileName dummyFileTemplate = 1.36 + new FileName(this, "", "", "", "", "", ""); 1.37 + 1.38 + // The next three must be instantiated in subclasses' constructors 1.39 + 1.40 + /** An incl file is produced per .c file and contains all the 1.41 + includes it needs */ 1.42 + protected FileName inclFileTemplate; 1.43 + 1.44 + /** A GI (grand-include) file has any file used more than N times 1.45 + for precompiled headers */ 1.46 + protected FileName giFileTemplate; 1.47 + 1.48 + /** A GD (grand-dependencies) file that tells Unix make all the 1.49 + .o's needed for linking and the include dependencies */ 1.50 + protected FileName gdFileTemplate; 1.51 + 1.52 + // Accessors 1.53 + public FileName getInclFileTemplate() { 1.54 + return inclFileTemplate; 1.55 + } 1.56 + 1.57 + public FileName getGIFileTemplate() { 1.58 + return giFileTemplate; 1.59 + } 1.60 + 1.61 + public FileName getGDFileTemplate() { 1.62 + return gdFileTemplate; 1.63 + } 1.64 + 1.65 + // an incl file is the file included by each.c file that includes 1.66 + // all needed header files 1.67 + 1.68 + public abstract void setupFileTemplates(); 1.69 + public abstract String[] outerSuffixes(); 1.70 + 1.71 + /** empty file name -> no grand include file */ 1.72 + public boolean haveGrandInclude() { 1.73 + return (giFileTemplate.nameOfList().length() > 0); 1.74 + } 1.75 + 1.76 + public boolean writeDeps() { 1.77 + return (gdFileTemplate.nameOfList().length() > 0); 1.78 + } 1.79 + 1.80 + /** <p> A gi file is the grand-include file. It includes in one 1.81 + file any file that is included more than a certain number of 1.82 + times. </p> 1.83 + 1.84 + <p> It is used for precompiled header files. </p> 1.85 + 1.86 + <p> It has a source name, that is the file that this program 1.87 + generates, and a compiled name; that is the file that is 1.88 + included by other files. </p> 1.89 + 1.90 + <p> Some platforms have this program actually explictly 1.91 + include the preprocessed gi file-- see includeGIInEachIncl(). 1.92 + </p> 1.93 + 1.94 + <p> Also, some platforms need a pragma in the GI file. </p> */ 1.95 + public boolean includeGIInEachIncl() { 1.96 + return false; 1.97 + } 1.98 + 1.99 + /** For some platforms, e.g. Solaris, include the grand-include 1.100 + dependencies in the makefile. For others, e.g. Windows, do 1.101 + not. */ 1.102 + public boolean includeGIDependencies() { 1.103 + return false; 1.104 + } 1.105 + 1.106 + /** Should C/C++ source file be dependent on a file included 1.107 + into the grand-include file. */ 1.108 + public boolean writeDependenciesOnHFilesFromGI() { 1.109 + return false; 1.110 + } 1.111 + 1.112 + /** Default implementation does nothing */ 1.113 + public void writeGIPragma(PrintWriter out) { 1.114 + } 1.115 + 1.116 + /** A line with a filename and the noGrandInclude string means 1.117 + that this file cannot use the precompiled header. */ 1.118 + public String noGrandInclude() { 1.119 + return "no_precompiled_headers"; 1.120 + } 1.121 + 1.122 + /** A line with a filename and the 1.123 + generatePlatformDependentInclude means that an include file 1.124 + for the header file must be generated. This file generated include 1.125 + file is directly included by the non-platform dependent include file 1.126 + (e.g os.hpp includes _os_pd.hpp.incl. So while we notice files that 1.127 + are directly dependent on non-platform dependent files from the database 1.128 + we must infer the dependence on platform specific files to generate correct 1.129 + dependences on the platform specific files. */ 1.130 + public String generatePlatformDependentInclude() { 1.131 + return "generate_platform_dependent_include"; 1.132 + } 1.133 + 1.134 + /** Prefix and suffix strings for emitting Makefile rules */ 1.135 + public abstract String objFileSuffix(); 1.136 + public abstract String asmFileSuffix(); 1.137 + public abstract String dependentPrefix(); 1.138 + 1.139 + // Exit routines: 1.140 + 1.141 + /** Abort means an internal error */ 1.142 + public void abort() { 1.143 + throw new RuntimeException("Internal error"); 1.144 + } 1.145 + 1.146 + /** fatalError is used by clients to stop the system */ 1.147 + public void fatalError(String msg) { 1.148 + System.err.println(msg); 1.149 + System.exit(1); 1.150 + } 1.151 + 1.152 + /** Default implementation performs case-sensitive comparison */ 1.153 + public boolean fileNameStringEquality(String s1, String s2) { 1.154 + return s1.equals(s2); 1.155 + } 1.156 + 1.157 + public void fileNamePortabilityCheck(String name) { 1.158 + if (Character.isUpperCase(name.charAt(0))) { 1.159 + fatalError("Error: for the sake of portability we have chosen\n" + 1.160 + "to avoid files starting with an uppercase letter.\n" + 1.161 + "Please rename " + name + "."); 1.162 + } 1.163 + } 1.164 + 1.165 + public void fileNamePortabilityCheck(String name, String matchingName) { 1.166 + if (!name.equals(matchingName)) { 1.167 + fatalError("Error: file " + name + " also appears as " + 1.168 + matchingName + ". Case must be consistent for " + 1.169 + "portability."); 1.170 + } 1.171 + } 1.172 + 1.173 + /** max is 31 on mac, so warn */ 1.174 + public int fileNameLengthLimit() { 1.175 + return 45; 1.176 + } 1.177 + 1.178 + public int defaultGrandIncludeThreshold() { 1.179 + return 30; 1.180 + } 1.181 + 1.182 + /** Not very general, but this is a way to get platform-specific 1.183 + files to be written. Default implementation does nothing. */ 1.184 + public void writePlatformSpecificFiles(Database previousDB, 1.185 + Database currentDB, String[] args) 1.186 + throws IllegalArgumentException, IOException { 1.187 + } 1.188 +}