1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package com.github.maven_nar.cpptasks.sun;
24
25 import java.io.File;
26 import java.util.Vector;
27
28 import com.github.maven_nar.cpptasks.CUtil;
29 import com.github.maven_nar.cpptasks.OptimizationEnum;
30 import com.github.maven_nar.cpptasks.compiler.LinkType;
31 import com.github.maven_nar.cpptasks.compiler.Linker;
32 import com.github.maven_nar.cpptasks.gcc.GccCompatibleCCompiler;
33
34
35
36
37
38
39 public final class ForteF77Compiler extends GccCompatibleCCompiler {
40 private static final ForteF77Compiler instance = new ForteF77Compiler("f77");
41
42
43
44
45 public static ForteF77Compiler getInstance() {
46 return instance;
47 }
48
49 private String identifier;
50 private File[] includePath;
51
52
53
54
55
56 private ForteF77Compiler(final String command) {
57 super(command, "-V", false, null, false, null);
58 }
59
60 @Override
61 public void addImpliedArgs(final Vector<String> args, final boolean debug, final boolean multithreaded,
62 final boolean exceptions, final LinkType linkType, final Boolean rtti, final OptimizationEnum optimization) {
63 args.addElement("-c");
64 if (debug) {
65 args.addElement("-g");
66 }
67 if (optimization != null) {
68 if (optimization.isSpeed()) {
69 args.addElement("-xO2");
70 }
71 }
72 if (multithreaded) {
73 args.addElement("-mt");
74 }
75 if (linkType.isSharedLibrary()) {
76 args.addElement("-KPIC");
77 }
78
79 }
80
81 @Override
82 public void addWarningSwitch(final Vector<String> args, final int level) {
83 switch (level) {
84 case 0:
85 args.addElement("-w");
86 break;
87 case 1:
88 case 2:
89 args.addElement("+w");
90 break;
91 case 3:
92 case 4:
93 case 5:
94 args.addElement("+w2");
95 break;
96 }
97 }
98
99 @Override
100 public File[] getEnvironmentIncludePath() {
101 if (this.includePath == null) {
102 final File f77Loc = CUtil.getExecutableLocation("f77");
103 if (f77Loc != null) {
104 final File compilerIncludeDir = new File(new File(f77Loc, "../include").getAbsolutePath());
105 if (compilerIncludeDir.exists()) {
106 this.includePath = new File[2];
107 this.includePath[0] = compilerIncludeDir;
108 }
109 }
110 if (this.includePath == null) {
111 this.includePath = new File[1];
112 }
113 this.includePath[this.includePath.length - 1] = new File("/usr/include");
114 }
115 return this.includePath;
116 }
117
118 @Override
119 public Linker getLinker(final LinkType linkType) {
120 return ForteCCLinker.getInstance().getLinker(linkType);
121 }
122
123 @Override
124 public int getMaximumCommandLength() {
125 return Integer.MAX_VALUE;
126 }
127 }