]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCLinker.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / sun / ForteCCLinker.java
1 /*
2 *
3 * Copyright 2001-2004 The Ant-Contrib project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package net.sf.antcontrib.cpptasks.sun;
18 import java.io.File;
19 import java.util.Vector;
20
21 import net.sf.antcontrib.cpptasks.CUtil;
22 import net.sf.antcontrib.cpptasks.compiler.LinkType;
23 import net.sf.antcontrib.cpptasks.compiler.Linker;
24 import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
25 /**
26 * Adapter for Sun (r) Forte(tm) C++ Linker
27 *
28 * @author Curt Arnold
29 */
30 public final class ForteCCLinker extends AbstractLdLinker {
31 private static final String[] discardFiles = new String[]{".dll", ".so",
32 ".sl"};
33 private static final String[] objFiles = new String[]{".o", ".a", ".lib"};
34 private static final ForteCCLinker arLinker = new ForteCCLinker("CC",
35 objFiles, discardFiles, "lib", ".a");
36 private static final ForteCCLinker dllLinker = new ForteCCLinker("CC",
37 objFiles, discardFiles, "lib", ".so");
38 private static final ForteCCLinker instance = new ForteCCLinker("CC",
39 objFiles, discardFiles, "", "");
40 public static ForteCCLinker getInstance() {
41 return instance;
42 }
43 private File[] libDirs;
44 private ForteCCLinker(String command, String[] extensions,
45 String[] ignoredExtensions, String outputPrefix, String outputSuffix) {
46 super(command, "-V", extensions, ignoredExtensions, outputPrefix,
47 outputSuffix, false, null);
48 }
49 public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
50 if (debug) {
51 args.addElement("-g");
52 }
53 if (linkType.isStaticRuntime()) {
54 args.addElement("-static");
55 }
56 if (linkType.isSharedLibrary()) {
57 args.addElement("-G");
58 }
59 if (linkType.isStaticLibrary()) {
60 args.addElement("-xar");
61 }
62 }
63 public void addIncremental(boolean incremental, Vector args) {
64 /*
65 * if (incremental) { args.addElement("-xidlon"); } else {
66 * args.addElement("-xidloff"); }
67 */
68 }
69 /**
70 * Returns library path.
71 *
72 */
73 public File[] getLibraryPath() {
74 if (libDirs == null) {
75 File CCloc = CUtil.getExecutableLocation("CC");
76 if (CCloc != null) {
77 File compilerLib = new File(new File(CCloc, "../lib")
78 .getAbsolutePath());
79 if (compilerLib.exists()) {
80 libDirs = new File[2];
81 libDirs[0] = compilerLib;
82 }
83 }
84 if (libDirs == null) {
85 libDirs = new File[1];
86 }
87 }
88 libDirs[libDirs.length - 1] = new File("/usr/lib");
89 return libDirs;
90 }
91 public Linker getLinker(LinkType type) {
92 if (type.isStaticLibrary()) {
93 return arLinker;
94 }
95 if (type.isSharedLibrary()) {
96 return dllLinker;
97 }
98 return instance;
99 }
100 }