Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

149 lines (126 sloc) 5.61 KB
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
PortSystem 1.0
PortGroup github 1.0
github.setup mirror mingw-w64 6.0.0 v
set mingw_name w64-mingw32
platforms darwin
license ZPL-2.1
categories cross devel
maintainers {mojca @mojca} openmaintainer
description GCC cross-compiler for Windows 64 & 32 bits
long_description Mingw-w64 is an advancement of the original project, \
created to support the GCC compiler on Windows systems.
checksums rmd160 4e968d216f28b7ecc440ac543448aa5cb6da504a \
sha256 15ea31c5a7f3071517dd6f0075b113b45a2b30bc6083942d9a89ee4a46d8f7e6 \
size 12464594
# needs an out-of-source build
configure.dir ${workpath}/build
build.dir ${configure.dir}
post-extract { file mkdir "${build.dir}" }
# create six subports:
# - i686-w64-mingw32-headers
# - i686-w64-mingw32-crt
# - i686-w64-mingw32-winpthreads
# - x86_64-w64-mingw32-headers
# - x86_64-w64-mingw32-crt
# - x86_64-w64-mingw32-winpthreads
foreach arch {i686 x86_64} {
foreach component {crt headers winpthreads} {
subport ${arch}-${mingw_name}-${component} {
set mingw_arch ${arch}
set mingw_comp ${component}
if {${component} eq "winpthreads"} {
set mingw_dir mingw-w64-libraries/${component}
} else {
set mingw_dir mingw-w64-${component}
if {${subport} ne ${name}} {
set mingw_target ${mingw_arch}-${mingw_name}
configure.cmd ${worksrcpath}/${mingw_dir}/configure
configure.pre_args-replace --prefix=${prefix} --prefix=${prefix}/${mingw_target}
configure.args-append --host=${mingw_target}
# *-headers subports
if {${mingw_comp} eq "headers"} {
supported_archs noarch
configure.args-append --enable-secure-api
# winpthreads install three files which conflict with placeholders provided by "headers"
# a relatively ugly workaround is to copy those three files from "winpthreads" to "headers"
# and then delete them from "winpthreads" again
post-extract {
foreach f {signal time unistd} {
set f_src ${worksrcpath}/mingw-w64-libraries/winpthreads/include/pthread_${f}.h
set f_dest ${worksrcpath}/${mingw_dir}/crt
copy -force ${f_src} ${f_dest}
# *-crt and *-winpthreads subports
} else {
# We only need a dependency on either of the two GCC compilers:
# - ${mingw_target}-gcc-bootstrap
# - ${mingw_target}-gcc
# to build. The rest of dependencies (*-headers, *-binutils)
# are pulled in by one of those two ports.
# Runtime dependency on GCC is not added to avoid dependency cycles,
# but in fact it's GCC that needs CRT at runtime, not the other way around.
if {${mingw_comp} eq "crt"} {
depends_build-append bin:${mingw_target}-gcc:${mingw_target}-gcc-bootstrap
# *-winpthreads
} else {
# winpthreads needs at least stage 2 compiler (or the final one)
# as well as the latest version of crt
depends_build-append path:${mingw_target}/lib/libgcc_s.a:${mingw_target}-gcc-nothreads \
depends_lib-append port:${arch}-${mingw_name}-crt
# see above
post-destroot {
foreach f {signal time unistd} {
delete ${destroot}${prefix}/${mingw_target}/include/pthread_${f}.h
#depends_run-append bin:${mingw_target}-gcc:${mingw_target}-gcc-bootstrap
#depends_lib-append port:${mingw_target}-binutils
#depends_lib-append port:${mingw_target}-headers
configure.cppflags "-I${prefix}/${mingw_target}/include"
# prevent MacPorts from adding -syslibroot to linker flags
# ----- copied from crossgcc (not sure if needed) ----
# the generated compiler doesn't accept -arch
# the bootstrap compiler doesn't accept -stdlib
# We don't need system includes(this prevents xgcc to include system-wide
# unwind.h if it is present)!
# -----
# is there a more elegant way? ${prefix}/bin/${mingw_target}-gcc
configure.cxx ${prefix}/bin/${mingw_target}-g++
configure.cpp ${prefix}/bin/${mingw_target}-cpp
# configure.env-append PATH=...
# TODO: Is this also noarch? It uses object files, but probably only for windows.
destroot.violate_mtree yes
livecheck.type none
} else {
description "GCC cross-compiler for Windows 64 & 32 bits (meta port)"
depends_run port:i686-${mingw_name}-gcc \
use_configure no
build {}
destroot {
xinstall -d -m 755 "${destroot}${prefix}/share/doc/${name}"
system "echo $name is a stub port > ${destroot}${prefix}/share/doc/${name}/README"
supported_archs noarch
You can’t perform that action at this time.