--- /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.hp;\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 aCCLinker extends AbstractLdLinker {\r
+ private static final String[] discardFiles = new String[0];\r
+ private static final String[] objFiles = new String[]{".o", ".a", ".lib",\r
+ ".dll", ".so", ".sl"};\r
+ private static final aCCLinker arLinker = new aCCLinker("aCC", objFiles,\r
+ discardFiles, "", ".a");\r
+ private static final aCCLinker dllLinker = new aCCLinker("aCC", objFiles,\r
+ discardFiles, "lib", ".sl");\r
+ private static final aCCLinker instance = new aCCLinker("aCC", objFiles,\r
+ discardFiles, "", "");\r
+ public static aCCLinker getInstance() {\r
+ return instance;\r
+ }\r
+ private File[] libDirs;\r
+ private aCCLinker(String command, String[] extensions,\r
+ String[] ignoredExtensions, String outputPrefix, String outputSuffix) {\r
+ super(command, "-help", 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
+ /*\r
+ * if(linkType.isStaticRuntime()) { args.addElement("-static"); }\r
+ */\r
+ if (linkType.isSharedLibrary()) {\r
+ args.addElement("-b");\r
+ }\r
+ /*\r
+ * if (linkType.isStaticLibrary()) { args.addElement("-Wl,-noshared"); }\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("aCC");\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