[119187] trunk/dports/graphics/freeimage/Portfile

mcalhoun at macports.org mcalhoun at macports.org
Sat Apr 19 06:57:03 PDT 2014


Revision: 119187
          https://trac.macports.org/changeset/119187
Author:   mcalhoun at macports.org
Date:     2014-04-19 06:57:03 -0700 (Sat, 19 Apr 2014)
Log Message:
-----------
*) FreeImage uses two different Makefiles
Use portbuild::build_main and portdestroot::destroot_main for both of them.
This allows the use of environmental variables like MACOSX_DEPLOYMENT_TARGET.
*) Implement options from configure in the build phase.

Modified Paths:
--------------
    trunk/dports/graphics/freeimage/Portfile

Modified: trunk/dports/graphics/freeimage/Portfile
===================================================================
--- trunk/dports/graphics/freeimage/Portfile	2014-04-19 11:52:52 UTC (rev 119186)
+++ trunk/dports/graphics/freeimage/Portfile	2014-04-19 13:57:03 UTC (rev 119187)
@@ -5,7 +5,7 @@
 
 name                freeimage
 version             3.16.0
-revision            0
+revision            1
 set major           [lindex [split ${version} .] 0]
 categories          graphics
 platforms           macosx
@@ -30,9 +30,6 @@
 checksums           rmd160  f0dcfb1514a288bbb2bc182130469b91d575e6cd \
                     sha256  03af32dd60140d07515ddfe7b4f467baa3b888a72ea78828811aded7adb42f60
 
-set libfreeimage libfreeimage.${major}.dylib
-set libfreeimageplus libfreeimageplus.${major}.dylib
-
 patchfiles          patch-Makefile.fip.diff
 
 post-patch {
@@ -63,41 +60,75 @@
 
 use_configure       no
 
+# In the future, implement in the build phase?
+#configure.pipe      no
+#configure.ccache    no
+#configure.distcc    no
+
+# FreeImage uses -O3
+configure.cflags-delete   -Os
+configure.cxxflags-delete -Os
+
 variant universal {}
 
-build.args          -f Makefile.gnu \
-                    PREFIX=${prefix} \
-                    VERLIBNAME=${libfreeimage} \
-                    CC="${configure.cc} ${configure.cflags} [get_canonical_archflags cc]" \
-                    CXX="${configure.cxx} ${configure.cxxflags} [get_canonical_archflags cxx]" \
-                    LDFLAGS="${configure.ldflags}"
+# Reimplement parts of portconfigure.tcl
+if {[info exists configure.cxx_stdlib] &&
+    ${configure.cxx_stdlib} ne {} &&
+    [string match *clang* ${configure.cxx}]
+} then {
+    configure.cxxflags-append -stdlib=${configure.cxx_stdlib}
+    configure.ldflags-append  -stdlib=${configure.cxx_stdlib}
+}
 
-post-build {
-    # build FreeImagePlus
-    system -W ${worksrcpath} "${build.cmd} -f Makefile.fip \
-        PREFIX=${prefix} \
-        VERLIBNAME=${libfreeimageplus} \
-        CC='${configure.cc} ${configure.cflags} [get_canonical_archflags cc]' \
-        CXX='${configure.cxx} ${configure.cxxflags} [get_canonical_archflags cxx]' \
-        LDFLAGS='${configure.ldflags}'"
+if {${configure.sdkroot} ne ""} {
+    configure.ldflags-append "-Wl,-syslibroot,${configure.sdkroot}"
 }
 
-destroot.args       -f Makefile.gnu \
-                    INCDIR=${destroot}${prefix}/include \
-                    INSTALLDIR=${destroot}${prefix}/lib \
-                    PREFIX=${prefix} \
-                    VERLIBNAME=${libfreeimage}
+foreach flags {cflags cxxflags} compiler {cc cxx} {
+    eval configure.${flags}-append [get_canonical_archflags ${compiler}]
+    
+    if {${configure.sdkroot} ne ""} {
+        configure.${flags}-append -isysroot${configure.sdkroot}
+    }
+    
+    if {${configure.march} ne "" } {
+        configure.${flags}-append "-march=${configure.march}"
+    }
+    
+    if {${configure.mtune} ne "" } {
+        configure.${flags}-append "-mtune=${configure.mtune}"
+    }
+}
 
+# running build_main and destroot_main makes use of environmental variables like MACOSX_DEPLOYMENT_TARGET
+
+build {
+    foreach makefile {Makefile.gnu Makefile.fip} libname {libfreeimage libfreeimageplus} {
+        # Makefile overrides CFLAGS and CXXFLAGS, so append options to CC and CXX
+        build.args -f ${makefile} \
+            PREFIX=${prefix} \
+            VERLIBNAME=${libname}.${major}.dylib \
+            CC="${configure.cc} ${configure.cflags}" \
+            CXX="${configure.cxx} ${configure.cxxflags}" \
+            LDFLAGS="${configure.ldflags}"
+        
+        portbuild::build_main
+    }
+}
+
+destroot {
+    foreach makefile {Makefile.gnu Makefile.fip} libname {libfreeimage libfreeimageplus} {
+        destroot.args -f ${makefile} \
+            PREFIX="${prefix}" \
+            VERLIBNAME=${libname}.${major}.dylib \
+            INCDIR="${destroot}${prefix}/include" \
+            INSTALLDIR="${destroot}${prefix}/lib"
+        
+        portdestroot::destroot_main
+    }
+}
+
 post-destroot {
-    # install FreeImagePlus
-    system -W ${worksrcpath} "${destroot.cmd} -f Makefile.fip install \
-        VERLIBNAME=${libfreeimageplus} \
-        CC='${configure.cc} ${configure.cflags} [get_canonical_archflags cc]' \
-        CXX='${configure.cxx} ${configure.cxxflags} [get_canonical_archflags cxx]' \
-        LDFLAGS='${configure.ldflags}' \
-        INCDIR='${destroot}${prefix}/include' \
-        INSTALLDIR='${destroot}${prefix}/lib'"
-
     set docdir ${prefix}/share/doc/${name}
     xinstall -d ${destroot}${docdir}
     xinstall -m 644 -W ${worksrcpath} Whatsnew.txt license-fi.txt \
@@ -106,16 +137,13 @@
 }
 
 test.run            yes
-test.cmd            ./testAPI
+test.cmd            "${build.cmd} && ./testAPI"
 test.dir            ${worksrcpath}/TestAPI
 test.target
 
-pre-test {
+post-patch {
     # Use correct compiler and flags when compiling test
-    reinplace "s:g++:${configure.cxx} ${configure.cxxflags} [get_canonical_archflags cxx]:" ${test.dir}/Makefile
-
-    # Build the test
-    system "make -C ${test.dir}"
+    reinplace "s:g++:${configure.cxx} ${configure.cxxflags}:" ${test.dir}/Makefile
 }
 
 livecheck.type      regex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140419/e83662d8/attachment-0001.html>


More information about the macports-changes mailing list