diff options
Diffstat (limited to 'src/main/java/net')
3 files changed, 33 insertions, 2 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java index fec91af..2e2065f 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/CCTask.java @@ -1389,6 +1389,9 @@ public class CCTask extends Task { linkType.setLinkFortran(linkFortran); } + public void setLinkFortranMain(boolean linkFortranMain) { + linkType.setLinkFortranMain(linkFortranMain); + } // ENDFREEHEP /** diff --git a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java index 67d7e6b..aae520d 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/compiler/LinkType.java @@ -31,6 +31,7 @@ public class LinkType { // BEGINFREEHEP private boolean linkCPP = true; private boolean linkFortran = false; + private boolean linkFortranMain = false; // ENDFREEHEP /** @@ -176,6 +177,14 @@ public class LinkType { public boolean linkFortran() { return linkFortran; } -// ENDFREEHEP + + public void setLinkFortranMain(boolean linkFortranMain) { + this.linkFortranMain = linkFortranMain; + } + + public boolean linkFortranMain() { + return linkFortranMain; + } + // ENDFREEHEP } diff --git a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java index 043720d..ce9f2fb 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/gcc/GppLinker.java @@ -63,7 +63,7 @@ public class GppLinker extends AbstractLdLinker { private File[] libDirs; private String runtimeLibrary; // FREEEHEP - private String gccLibrary, gfortranLibrary; + private String gccLibrary, gfortranLibrary, gfortranMainLibrary; protected GppLinker(String command, String[] extensions, String[] ignoredExtensions, String outputPrefix, @@ -97,6 +97,22 @@ public class GppLinker extends AbstractLdLinker { gfortranLibrary = "-lgfortran"; } } + + gfortranMainLibrary = null; + if (linkType.linkFortran()) { + if (linkType.isExecutable() && linkType.linkFortranMain() && !isDarwin()) { + if (linkType.isStaticRuntime()) { + String[] cmdin = new String[] { "gfortran", + "-print-file-name=libgfortranbegin.a" }; + String[] cmdout = CaptureStreamHandler.run(cmdin); + if ((cmdout.length > 0) && (cmdout[0].indexOf('/') >= 0)) { + gfortranMainLibrary = cmdout[0]; + } + } else { + gfortranMainLibrary = "-lgfortranbegin"; + } + } + } runtimeLibrary = null; if (linkType.linkCPP()) { @@ -137,6 +153,9 @@ public class GppLinker extends AbstractLdLinker { if (gfortranLibrary != null) { endargs.addElement(gfortranLibrary); } + if (gfortranMainLibrary != null) { + endargs.addElement(gfortranMainLibrary); + } if (gccLibrary != null) { endargs.addElement(gccLibrary); } |