Ticket #18154: openssl-Portfile.diff

File openssl-Portfile.diff, 5.7 KB (added by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), 15 years ago)
  • Portfile

    old new  
    11# $Id: Portfile 45258 2009-01-12 09:13:25Z blb@macports.org $
    22
    33PortSystem 1.0
     4PortGroup  merge_universal 1.0
    45
    56name                    openssl
    67version                 0.9.8j
     
    4647
    4748test.run                yes
    4849
    49 livecheck.check regex
    50 livecheck.url   ${master_sites}
    51 livecheck.regex ${name}-(0.9.8\[a-z\])
    52 
    53 if { ![info exists universal_archs] } {
    54         set universal_archs {i386 ppc}
    55         #set universal_archs {i386 x86_64 ppc ppc64}
     50post-patch {
     51        # Ensure that the correct compiler is used
     52        reinplace "s|cc:|${configure.cc}:|" ${worksrcpath}/Configure
     53
     54        # For universal builds, add "-isysroot ${universal_sysroot}" to compiler options
     55        if { [variant_isset universal] } {
     56                reinplace "s|\\(-arch \[_a-zA-Z0-9\]*\\)|\\1 -isysroot ${universal_sysroot}|" ${worksrcpath}/Configure
     57        }
    5658}
    57 set first_arch [lindex ${universal_archs} 0]
    5859
    59 variant universal {
    60     patchfiles-append patch-Configure-sysroot.diff
    61         post-patch {
    62             reinplace "s|__UNIVERSAL_SYSROOT__|${universal_sysroot}|" ${worksrcpath}/Configure
    63                 foreach arch ${universal_archs} {
    64                         if {[string equal ${arch} ${first_arch}]} {
    65                                 move ${worksrcpath} ${workpath}/${first_arch}
    66                         } else {
    67                                 copy ${workpath}/${first_arch} ${workpath}/${arch}
    68                         }
    69                 }
    70         }
     60if { [variant_isset universal] } {
     61        configure.cmd   ./Configure
    7162
    72         configure {
    73                 foreach arch ${universal_archs} {
    74                         if { [string first 64 $arch] == -1 } {
    75                                 set my_cc "darwin-${arch}-cc"
    76                         } else {
    77                                 if {[string first ppc $arch] != -1} {
    78                                         set my_cc "darwin64-ppc-cc"
    79                                 } else {
    80                                         set my_cc "darwin64-${arch}-cc"
    81                                 }
    82                         }
    83                         system "cd ${workpath}/${arch} && ./Configure ${my_cc} ${configure.pre_args} ${configure.args}"
    84                 }
     63        if { ${os.arch}=="i386" } {
     64                set universal_archs_supported  "i386 x86_64"
     65        } else {
     66                set universal_archs_supported  "ppc ppc64"
    8567        }
    8668
    87         build {
    88                 foreach arch ${universal_archs} {
    89                         system "cd ${workpath}/${arch} && make all"
    90                 }
     69        pre-configure {
     70                configure.args-delete  --disable-dependency-tracking
    9171        }
    92 
    93         destroot {
    94 # in port 1.7, just call:
    95 #               merge "${workpath}/pre-dest"
    96 # till then, do this:
    97                 foreach arch ${universal_archs} {
    98                         xinstall -d ${workpath}/pre-dest/${arch}
    99                         system "cd ${workpath}/${arch} && make install INSTALL_PREFIX=${workpath}/pre-dest/${arch} MANDIR=${prefix}/share/man"
    100                        
    101                         # opensslconf.h will differ between 32- and 64-bit, so patch it so it doesn't
    102                         if { [string first 64 $arch] != -1 } {
    103                                 if { [string first ppc $arch] != -1 } {
    104                                         set configpatch ${filespath}/patch-opensslconf.h-ppc64.diff
    105                                 } else {
    106                                         set configpatch ${filespath}/patch-opensslconf.h-x86_64.diff
    107                                 }
    108                         } else {
    109                                 set configpatch ${filespath}/patch-opensslconf.h-32.diff
    110                         }
    111                         system "cd ${workpath}/pre-dest/${arch}${prefix} && patch --no-backup-if-mismatch -p0 < ${configpatch}"
    112                 }
    113 
    114                 set basepath "${workpath}/pre-dest/i386"
    115                 fs-traverse file "${basepath}" {
    116                         set fpath [string range "${file}" [string length "${basepath}"] [string length "${file}"]]
    117                         if {${fpath} != ""} {
    118                                 ui_debug ":: ${fpath}"
    119 
    120                                 switch -exact [file type "${basepath}${fpath}"] {
    121                                         directory {
    122                                                 # just create directories
    123                                                 ui_debug "-- dir:: ${fpath}"
    124                                                 file mkdir "${destroot}${fpath}"
    125                                         }
    126                                         link {
    127                                                 # copy symlinks (TODO: check if target matches)
    128                                                 ui_debug "-- lnk:: ${fpath}"
    129                                                 file copy "${basepath}${fpath}" "${destroot}${fpath}"
    130                                         }
    131                                         file {
    132                                                 # treat files depending on their filetype
    133                                                 ui_debug "-- file:: ${fpath}"
    134                                                 set filetype [exec "/usr/bin/file" "-b" "${basepath}${fpath}"]
    135                                                 switch -regexp ${filetype} {
    136                                                         Mach-O.* {
    137                                                                 # Mach-O binaries get lipo-ed
    138                                                                 ui_debug "Mach-O file -- lipo-ing"
    139                                                                 set machocmd "lipo"
    140                                                                 foreach arch ${universal_archs} {
    141                                                                         set machocmd "${machocmd} -arch $arch ${workpath}/pre-dest/${arch}/${fpath}"
    142                                                                 }
    143                                                                 set machocmd "${machocmd} -create -output ${destroot}${fpath}"
    144                                                                 system ${machocmd}
    145                                                         }
    146                                                         current\ ar\ archive {
    147                                                                 # ar archives get lipo-ed
    148                                                                 ui_debug "ar archive -- lipo-ing"
    149                                                                 set arcmd "lipo"
    150                                                                 foreach arch ${universal_archs} {
    151                                                                         set arcmd "${arcmd} -arch $arch ${workpath}/pre-dest/${arch}/${fpath}"
    152                                                                 }
    153                                                                 set arcmd "${arcmd} -create -output ${destroot}${fpath}"
    154                                                                 system ${arcmd}
    155                                                         }
    156                                                         default {
    157                                                                 # unknown file types are copied IF they do not differ across ALL architectures -- if they do: This is an error!
    158                                                                 ui_debug "unknown filetype: ${filetype}"
    159                                                                
    160                                                                 set any_difference no
    161                                                                 foreach arch ${universal_archs} {
    162                                                                         if {![string equal ${arch} ${first_arch}]} {
    163                                                                                 set differ1 [exec "/usr/bin/diff" "-q" "${workpath}/pre-dest/${first_arch}/${fpath}" "${workpath}/pre-dest/${arch}/${fpath}"]
    164                                                                                 if {![string equal ${differ1} ""]} {
    165                                                                                         set any_difference yes
    166                                                                                 }
    167                                                                         }
    168                                                                 }
    169                                                                 if {${any_difference}} {
    170                                                                         ui_debug "ERROR: files differ"
    171                                                                 } else {
    172                                                                         ui_debug "files match, just copying"
    173                                                                         file copy "${basepath}${fpath}" "${destroot}${fpath}"
    174                                                                 }
    175                                                         }
    176                                                 }
    177                                         }
    178                                         default { ui_debug "serious error" }
    179                                 }
    180                         }
    181                 }
     72        array set merger_configure_args {
     73                ppc     darwin-ppc-cc
     74                i386    darwin-i386-cc
     75                ppc64   darwin64-ppc-cc
     76                x86_64  darwin64-x86_64-cc
     77        }
     78        array set merger_host {
     79                ppc     ""
     80                i386    ""
     81                ppc64   ""
     82                x86_64  ""
    18283        }
    18384}
    18485
     86livecheck.check regex
     87livecheck.url   ${master_sites}
     88livecheck.regex ${name}-(0.9.8\[a-z\])
     89
    18590# the test suite can only be run *after* destrooting
    18691#    test.run            yes
    18792#    test.dir            ${worksrcpath}/test