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.compaq;
21  
22  import java.util.Vector;
23  
24  import com.github.maven_nar.cpptasks.compiler.LinkType;
25  import com.github.maven_nar.cpptasks.compiler.Linker;
26  import com.github.maven_nar.cpptasks.msvc.MsvcCompatibleLinker;
27  
28  /**
29   * Adapter for the Compaq(r) Visual Fortran linker.
30   *
31   * @author Curt Arnold
32   */
33  public final class CompaqVisualFortranLinker extends MsvcCompatibleLinker {
34    private static final CompaqVisualFortranLinker dllLinker = new CompaqVisualFortranLinker(".dll");
35    private static final CompaqVisualFortranLinker instance = new CompaqVisualFortranLinker(".exe");
36  
37    public static CompaqVisualFortranLinker getInstance() {
38      return instance;
39    }
40  
41    private CompaqVisualFortranLinker(final String outputSuffix) {
42      super("DF", "__bogus__.xxx", outputSuffix);
43    }
44  
45    protected void addImpliedArgs(final boolean debug, final LinkType linkType, final Vector<String> args) {
46      args.addElement("/NOLOGO");
47      final boolean staticRuntime = linkType.isStaticRuntime();
48      if (staticRuntime) {
49        args.addElement("/libs:static");
50      } else {
51        args.addElement("/libs:dll");
52      }
53      if (debug) {
54        args.addElement("/debug");
55      } else {
56      }
57      if (linkType.isSharedLibrary()) {
58        args.addElement("/dll");
59      } else {
60        args.addElement("/exe");
61      }
62    }
63  
64    @Override
65    public Linker getLinker(final LinkType type) {
66      if (type.isStaticLibrary()) {
67        return CompaqVisualFortranLibrarian.getInstance();
68      }
69      if (type.isSharedLibrary()) {
70        return dllLinker;
71      }
72      return instance;
73    }
74  
75    @Override
76    public String[] getOutputFileSwitch(final String outputFile) {
77      final StringBuffer buf = new StringBuffer("/OUT:");
78      if (outputFile.indexOf(' ') >= 0) {
79        buf.append('"');
80        buf.append(outputFile);
81        buf.append('"');
82      } else {
83        buf.append(outputFile);
84      }
85      return new String[] {
86        buf.toString()
87      };
88    }
89  }