Changes between Version 68 and Version 69 of PortfileRecipes


Ignore:
Timestamp:
Aug 25, 2013, 5:06:39 PM (11 years ago)
Author:
jeremyhu (Jeremy Huddleston Sequoia)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PortfileRecipes

    v68 v69  
    401401== Providing compiler variants == #gcc
    402402
     403'''This recipe is not recommended.  Please do not use it in new ports'''
     404
     405Use of the C++ and ObjC compilers provided by macports-gcc-X.Y compiler options (and by extension, dragonegg compiler options) is strongly discouraged because it will lead to different C++ and ObjC runtimes being used by different ports (which can make such ports incompatible with each other)'''.  The general rule of thumb is that if the C++ or ObjC usage is wholly contained within the port, it is safe to use the gcc compilers.  If the port uses C++ or ObjC APIs provided by the host or other ports, then you must use an Apple provided compiler or one of the macports-clang compilers.  Similarly, if the port is providing ObjC or C++ APIs to other ports, then it must use an Apple provided compiler or one of the macports-clang ports.  See the next section below for instructions on how to choose just the fortran compiler based on gcc variants.
     406
    403407By default, a port will compile using Apple's Clang or GCC compiler. For
    404408most ports this is fine, but some require a recent version of GCC, or
     
    469473}}}
    470474
     475== Selecting a Fortran Compiler == #fortran
     476
     477The 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{{{
     480set gcc_versions {4.3 4.4 4.5 4.6 4.7 4.8 4.9}
     481set default_fortran_variant +gcc48
     482
     483foreach 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
     507variant g95 description {build with g95} {}
     508
     509if {[variant_isset g95]} {
     510    if {${default_fortran_variant} != "+g95"} {
     511        set default_fortran_variant ""
     512    }
     513}
     514
     515if {${default_fortran_variant} != ""} {
     516    default_variants "${default_fortran_variant}"
     517}
     518
     519foreach 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
     532if {[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}}}
    471541
    472542== Replacing and renaming ports == #replaced-by