+++ /dev/null
-/*\r
- * \r
- * Copyright 2001-2004 The Ant-Contrib project\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package net.sf.antcontrib.cpptasks.sun;\r
-import java.io.File;\r
-import java.util.Vector;\r
-\r
-import net.sf.antcontrib.cpptasks.CUtil;\r
-import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
-import net.sf.antcontrib.cpptasks.compiler.Linker;\r
-import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;\r
-/**\r
- * Adapter for Sun (r) Forte(tm) C++ Linker\r
- * \r
- * @author Curt Arnold\r
- */\r
-public final class ForteCCLinker extends AbstractLdLinker {\r
- private static final String[] discardFiles = new String[]{".dll", ".so",\r
- ".sl"};\r
- private static final String[] objFiles = new String[]{".o", ".a", ".lib"};\r
- private static final ForteCCLinker arLinker = new ForteCCLinker("CC",\r
- objFiles, discardFiles, "lib", ".a");\r
- private static final ForteCCLinker dllLinker = new ForteCCLinker("CC",\r
- objFiles, discardFiles, "lib", ".so");\r
- private static final ForteCCLinker instance = new ForteCCLinker("CC",\r
- objFiles, discardFiles, "", "");\r
- public static ForteCCLinker getInstance() {\r
- return instance;\r
- }\r
- private File[] libDirs;\r
- private ForteCCLinker(String command, String[] extensions,\r
- String[] ignoredExtensions, String outputPrefix, String outputSuffix) {\r
- super(command, "-V", extensions, ignoredExtensions, outputPrefix,\r
- outputSuffix, false, null);\r
- }\r
- public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {\r
- if (debug) {\r
- args.addElement("-g");\r
- }\r
- if (linkType.isStaticRuntime()) {\r
- args.addElement("-static");\r
- }\r
- if (linkType.isSharedLibrary()) {\r
- args.addElement("-G");\r
- }\r
- if (linkType.isStaticLibrary()) {\r
- args.addElement("-xar");\r
- }\r
- }\r
- public void addIncremental(boolean incremental, Vector args) {\r
- /*\r
- * if (incremental) { args.addElement("-xidlon"); } else {\r
- * args.addElement("-xidloff"); }\r
- */\r
- }\r
- /**\r
- * Returns library path.\r
- * \r
- */\r
- public File[] getLibraryPath() {\r
- if (libDirs == null) {\r
- File CCloc = CUtil.getExecutableLocation("CC");\r
- if (CCloc != null) {\r
- File compilerLib = new File(new File(CCloc, "../lib")\r
- .getAbsolutePath());\r
- if (compilerLib.exists()) {\r
- libDirs = new File[2];\r
- libDirs[0] = compilerLib;\r
- }\r
- }\r
- if (libDirs == null) {\r
- libDirs = new File[1];\r
- }\r
- }\r
- libDirs[libDirs.length - 1] = new File("/usr/lib");\r
- return libDirs;\r
- }\r
- public Linker getLinker(LinkType type) {\r
- if (type.isStaticLibrary()) {\r
- return arLinker;\r
- }\r
- if (type.isSharedLibrary()) {\r
- return dllLinker;\r
- }\r
- return instance;\r
- }\r
-}\r