[MacPorts] PortfileRecipes modified

MacPorts noreply at macports.org
Sat Oct 24 01:02:07 PDT 2009


Changed page "PortfileRecipes" by ryandesign at macports.org from 70.253.95.39*
Page URL: <http://trac.macports.org/wiki/PortfileRecipes>
Diff URL: <http://trac.macports.org/wiki/PortfileRecipes?action=diff&version=13>
Revision 13
Comment: Add "Providing compiler variants" section

-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: PortfileRecipes
=========================================================================
--- PortfileRecipes (version: 12)
+++ PortfileRecipes (version: 13)
@@ -159,3 +159,52 @@
 This example is taken from [browser:trunk/dports/www/spawn-fcgi/Portfile spawn-fcgi].
 
 Note: Ensure you use the correct capitalization for each filename. For example, many projects typically use all-caps for most of the documentation files, except for ChangeLog, which is often written in camel-case. If you fail to use the correct capitalization, the port may still install on your system, but will fail for users with case-sensitive filesystems.
+
+== Providing compiler variants == #gcc
+
+By default, a port will compile using Apple's gcc compiler.
+For most ports this is fine, but some require a newer version of gcc, or are for some reason incompatible with Apple's version.
+In these cases you can use `configure.compiler` to specify an alternate compiler, for example one provided by a MacPorts gcc port.
+More commonly, a port specifies such a compiler because it needs gcj or gfortran, which Apple does not provide any version of at all.
+
+On the one hand, such ports should prefer to use the newest suitable stable version of gcc they can.
+On the other hand, a user may already have an older gcc port installed and may not want to spend the time to compile a newer one right now, or may have other reasons for preferring a particular version of gcc.
+Therefore, ports that need to use a gcc port, but aren't picky about exactly which one, are encouraged to offer variants:
+
+{{{
+variant gcc42 conflicts gcc43 gcc44 description {Compile with gcc42} {
+    configure.compiler macports-gcc-4.2
+    depends_lib-append port:gcc42
+}
+
+variant gcc43 conflicts gcc42 gcc44 description {Compile with gcc43} {
+    configure.compiler macports-gcc-4.3
+    depends_lib-append port:gcc43
+}
+
+variant gcc44 conflicts gcc42 gcc43 description {Compile with gcc44} {
+    configure.compiler macports-gcc-4.4
+    depends_lib-append port:gcc44
+}
+
+if {![variant_isset gcc42] && ![variant_isset gcc43] && ![variant_isset gcc44]} {
+    default_variants +gcc44
+}
+}}}
+
+Note that the variants are all marked as conflicting with one another, and that the newest one is chosen by default if the user has not picked one.
+Note also that the compiler dependencies are library dependencies because programs compiled using these compilers will generally end up linked to at least one of the compiler's libraries (i.e. libgcc_s.dylib, libgfortran.dylib, etc.).
+
+Setting `configure.compiler` changes the values MacPorts puts in variables like ${configure.cc}, ${configure.cxx}, ${configure.f77}, etc., which MacPorts automatically sets as environment variables during the configure phase.
+If the software in question doesn't use the configure phase, and you therefore need to pass these variables to the build phase, you must do so in a pre-build block;
+if you try to do so directly in the portfile body, you'll pick up the original values, before the variant changed them.
+
+{{{
+pre-build {
+    build.args      CC=${configure.cc} \
+                    CXX=${configure.cxx}
+}
+}}}
+
+Another reason to want compiler variants is if the software installs a library, or uses a library built with a different gcc.
+Subtle and difficult-to-find errors can occur if a library and the program using it are not both compiled with the same compiler.

-------8<------8<------8<------8<------8<------8<------8<------8<--------

* The IP shown here might not mean anything if the user or the server is
behind a proxy.

--
MacPorts <http://www.macports.org/>
Ports system for Mac OS

This is an automated message. Someone at http://www.macports.org/ added your email
address to be notified of changes on PortfileRecipes. If it was not you, please
report to .


More information about the macports-changes mailing list