+++ /dev/null
-/*\r
- * \r
- * Copyright 2002-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.CCTask;\r
-import net.sf.antcontrib.cpptasks.CUtil;\r
-import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;\r
-import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
-import net.sf.antcontrib.cpptasks.compiler.Linker;\r
-import net.sf.antcontrib.cpptasks.types.LibrarySet;\r
-import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;\r
-\r
-/**\r
- * Adapter for the Sun C89 Linker\r
- * \r
- * @author Hiram Chirino (cojonudo14@hotmail.com)\r
- */\r
-public final class C89Linker extends CommandLineLinker {\r
- private static final C89Linker dllLinker = new C89Linker("lib", ".so");\r
- private static final C89Linker instance = new C89Linker("", "");\r
- public static C89Linker getInstance() {\r
- return instance;\r
- }\r
- private String outputPrefix;\r
- private C89Linker(String outputPrefix, String outputSuffix) {\r
- super("ld", "/bogus", new String[]{".o", ".a", ".lib", ".x"},\r
- new String[]{}, outputSuffix, false, null);\r
- this.outputPrefix = outputPrefix;\r
- }\r
- protected void addBase(long base, Vector args) {\r
- }\r
- protected void addFixed(Boolean fixed, Vector args) {\r
- }\r
- protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {\r
- if (linkType.isSharedLibrary()) {\r
- args.addElement("-G");\r
- }\r
- }\r
- protected void addIncremental(boolean incremental, Vector args) {\r
- }\r
- public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,\r
- Vector preargs, Vector midargs, Vector endargs) {\r
- super.addLibrarySets(task, libsets, preargs, midargs, endargs);\r
- StringBuffer buf = new StringBuffer("-l");\r
- for (int i = 0; i < libsets.length; i++) {\r
- LibrarySet set = libsets[i];\r
- File libdir = set.getDir(null);\r
- String[] libs = set.getLibs();\r
- if (libdir != null) {\r
- endargs.addElement("-L");\r
- endargs.addElement(libdir.getAbsolutePath());\r
- }\r
- for (int j = 0; j < libs.length; j++) {\r
- //\r
- // reset the buffer to just "-l"\r
- //\r
- buf.setLength(2);\r
- //\r
- // add the library name\r
- buf.append(libs[j]);\r
- //\r
- // add the argument to the list\r
- endargs.addElement(buf.toString());\r
- }\r
- }\r
- return null;\r
- }\r
- protected void addMap(boolean map, Vector args) {\r
- }\r
- protected void addStack(int stack, Vector args) {\r
- }\r
- /* (non-Javadoc)\r
- * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)\r
- */\r
- protected void addEntry(String entry, Vector args) {\r
- }\r
- \r
- public String getCommandFileSwitch(String commandFile) {\r
- return "@" + commandFile;\r
- }\r
- public File[] getLibraryPath() {\r
- return CUtil.getPathFromEnvironment("LIB", ";");\r
- }\r
- public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {\r
- return C89Processor.getLibraryPatterns(libnames, libType);\r
- }\r
- public Linker getLinker(LinkType linkType) {\r
- if (linkType.isSharedLibrary()) {\r
- return dllLinker;\r
- }\r
- /*\r
- * if(linkType.isStaticLibrary()) { return\r
- * OS390Librarian.getInstance(); }\r
- */\r
- return instance;\r
- }\r
- public int getMaximumCommandLength() {\r
- return Integer.MAX_VALUE;\r
- }\r
- public String getOutputFileName(String baseName) {\r
- return outputPrefix + super.getOutputFileName(baseName);\r
- }\r
- public String[] getOutputFileSwitch(String outputFile) {\r
- return new String[]{"-o", outputFile};\r
- }\r
- public boolean isCaseSensitive() {\r
- return C89Processor.isCaseSensitive();\r
- }\r
-}\r