View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar.cpptasks.ibm;
21  
22  import java.util.Vector;
23  
24  import com.github.maven_nar.cpptasks.CCTask;
25  import com.github.maven_nar.cpptasks.compiler.LinkType;
26  import com.github.maven_nar.cpptasks.compiler.Linker;
27  import com.github.maven_nar.cpptasks.gcc.AbstractLdLinker;
28  import com.github.maven_nar.cpptasks.gcc.GccLibrarian;
29  
30  /**
31   * Adapter for IBM(r) Visual Age(tm) Linker for AIX(tm)
32   *
33   * @author Curt Arnold
34   */
35  public final class VisualAgeLinker extends AbstractLdLinker {
36    private static final String[] discardFiles = new String[] {};
37    private static final String[] objFiles = new String[] {
38        ".o", ".a", ".lib", ".dll", ".so", ".sl"
39    };
40    private static final VisualAgeLinker dllLinker = new VisualAgeLinker("xlC", objFiles, discardFiles, "lib", ".a");
41    private static final VisualAgeLinker instance = new VisualAgeLinker("xlC", objFiles, discardFiles, "", "");
42  
43    public static VisualAgeLinker getInstance() {
44      return instance;
45    }
46  
47    private VisualAgeLinker(final String command, final String[] extensions, final String[] ignoredExtensions,
48        final String outputPrefix, final String outputSuffix) {
49      //
50      // just guessing that -? might display something useful
51      //
52      super(command, "-?", extensions, ignoredExtensions, outputPrefix, outputSuffix, false, null);
53    }
54  
55    @Override
56    public void
57        addImpliedArgs(final CCTask task, final boolean debug, final LinkType linkType, final Vector<String> args) {
58      if (debug) {
59        // args.addElement("-g");
60      }
61      if (linkType.isSharedLibrary()) {
62        args.addElement("-qmkshrobj");
63      }
64    }
65  
66    @Override
67    protected String getDynamicLibFlag() {
68      return "-bdynamic";
69    }
70  
71    /**
72     * Gets identifier for the compiler.
73     * 
74     * Initial attempt at extracting version information
75     * would lock up. Using a stock response.
76     */
77    @Override
78    public String getIdentifier() {
79      return "VisualAge linker - unidentified version";
80    }
81  
82    @Override
83    public Linker getLinker(final LinkType type) {
84      if (type.isStaticLibrary()) {
85        return GccLibrarian.getInstance();
86      }
87      if (type.isSharedLibrary()) {
88        return dllLinker;
89      }
90      return instance;
91    }
92  
93    @Override
94    protected String getStaticLibFlag() {
95      return "-bstatic";
96    }
97  
98  }