| 475 | == Selecting a Fortran Compiler == #fortran |
| 476 | |
| 477 | The default Apple-provided compilers (and the clang compilers from MacPorts) do not support as many languages as the gcc ports. The Portfile recipe below will allow you to compile fortran code while still using the default compiler for C, ObjC, C++, and ObjC++ code. If your port uses gcj, the same process can be used to select a gcj compiler. |
| 478 | |
| 479 | {{{ |
| 480 | set gcc_versions {4.3 4.4 4.5 4.6 4.7 4.8 4.9} |
| 481 | set default_fortran_variant +gcc48 |
| 482 | |
| 483 | foreach ver ${gcc_versions} { |
| 484 | set ver_no_dot [join [split ${ver} "."] ""] |
| 485 | |
| 486 | variant gcc${ver_no_dot} description {build with gfortran from gcc${ver_no_dot}} {} |
| 487 | |
| 488 | variant gcc${ver_no_dot} conflicts g95 {} |
| 489 | variant g95 conflicts gcc${ver_no_dot} {} |
| 490 | |
| 491 | foreach over ${gcc_versions} { |
| 492 | if {${ver} == ${over}} { |
| 493 | continue |
| 494 | } |
| 495 | |
| 496 | set over_no_dot [join [split ${over} "."] ""] |
| 497 | variant gcc${ver_no_dot} conflicts gcc${over_no_dot} {} |
| 498 | } |
| 499 | |
| 500 | if {[variant_isset gcc${ver_no_dot}]} { |
| 501 | if {${default_fortran_variant} != "+gcc${ver_no_dot}"} { |
| 502 | set default_fortran_variant "" |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | variant g95 description {build with g95} {} |
| 508 | |
| 509 | if {[variant_isset g95]} { |
| 510 | if {${default_fortran_variant} != "+g95"} { |
| 511 | set default_fortran_variant "" |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | if {${default_fortran_variant} != ""} { |
| 516 | default_variants "${default_fortran_variant}" |
| 517 | } |
| 518 | |
| 519 | foreach ver ${gcc_versions} { |
| 520 | set ver_no_dot [join [split ${ver} "."] ""] |
| 521 | |
| 522 | if {[variant_isset gcc${ver_no_dot}]} { |
| 523 | depends_lib-append port:libgcc |
| 524 | depends_build-append port:gcc${ver_no_dot} |
| 525 | |
| 526 | configure.fc ${prefix}/bin/gfortran-mp-${ver} |
| 527 | configure.f77 ${prefix}/bin/gfortran-mp-${ver} |
| 528 | configure.f90 ${prefix}/bin/gfortran-mp-${ver} |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | if {[variant_isset g95]} { |
| 533 | depends_lib-append port:libgcc |
| 534 | depends_build-append port:g95 |
| 535 | |
| 536 | configure.fc ${prefix}/bin/g95 |
| 537 | configure.f77 ${prefix}/bin/g95 |
| 538 | configure.f90 ${prefix}/bin/g95 |
| 539 | } |
| 540 | }}} |