--- /opt/local/var/macports/sources/git.macports.org/dports/audio/audacity/Portfile	2016-12-21 23:31:02.000000000 +0100
+++ audio/audacity/Portfile	2017-03-24 22:13:30.000000000 +0100
@@ -1,28 +1,13 @@
 # -*- coding: utf-8; mode: tcl; tab-width: 4; truncate-lines: t; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
-# kate: backspace-indents true; indent-pasted-text true; indent-width 4; keep-extra-spaces true; remove-trailing-spaces modified; replace-tabs true; replace-tabs-save true; syntax Tcl/Tk; tab-indents true; tab-width 4;
 
 PortSystem          1.0
 PortGroup           wxWidgets 1.0
+PortGroup           compiler_blacklist_versions 1.0
 
-# use the release tarball from github because it contains all required external libs
-# incl. those not in MacPorts.
-PortGroup           github 1.0
-github.setup        audacity audacity 2.1.2 Audacity-
-github.tarball_from releases
-revision            2
-master_sites        https://github.com/audacity/audacity/archive/
-distname            Audacity-${version}
-checksums           rmd160  4e0c508b8edd24935a235c0b1a636c4ef1ae59a9 \
-                    sha256  90007b50cdc3885607b1afef2f158777a61c1658e869a88ec4d98c59c133f9bd
-
-post-extract {
-    file rename ${workpath}/audacity-Audacity-${version} ${workpath}/${distname}
-}
-
-categories          audio
-
-description         A Free, Cross-Platform Digital Audio Editor
+name                audacity
+conflicts           audacity-gtk
 
+description         A Free, Cross-Platform Digital Audio Editor.
 long_description    Audacity is a free, easy-to-use, multi-track audio editor and recorder \
                     for Windows, Mac OS X, GNU/Linux and other operating systems. The interface is translated \
                     into many languages. You can use Audacity to: \n\
@@ -35,6 +20,36 @@
                     Numerous effects including change the speed or pitch of a recording. \n\
                     And more!
 
+subport             audacity-devel {
+    long_description A port of the Audacity audio editor aimed at development purposes.
+}
+
+
+# use the release tarball from github because it contains all required external libs
+# incl. those not in MacPorts.
+PortGroup           github 1.0
+
+if {${subport} eq "${name}"} {
+    version         2.1.3
+    github.setup    audacity audacity ${version} Audacity-
+    distname        Audacity-${version}
+    checksums       rmd160  d3f9252f55a13ee1a9f4fcf1f5ffdd72eafdde6d \
+                    sha256  24469a0b8c822f4f93ce23add61cd6ffd1919fc8c1384015a05566764c870ef1
+} else {
+#     # git describe --tags : Audacity-2.1.2-1652-g0cb89a8
+#     github.setup        audacity audacity 0cb89a895a25e4f1e7ca4045d0b95e786bce7ed2
+    # git describe --tags : Audacity-2.1.3-190-g78149bc
+    github.setup    audacity audacity 78149bc3da4a7d18c0487baf7002b23759a814c3
+    version         2.1.3.190
+    # this port is intended to facilitate development efforts shared with "upstreams"
+    # so using git instead of a tarball fetch type is more appropriate.
+    fetch.type      git
+    distname        audacity-git
+}
+
+categories          audio
+
+
 platforms           darwin
 license             GPL-2+
 # openssl is a dependency of curl in cmake
@@ -47,6 +62,8 @@
 
 wxWidgets.use       wxWidgets-3.0
 
+compiler.blacklist  {*gcc-[234].[0-8]}
+
 depends_build-append \
                     port:cmake \
                     port:pkgconfig \
@@ -71,27 +88,37 @@
 
 patch.pre_args      -Np1
 
-patchfiles-append   debian/patches/fix-minsrc-autoreconf.patch              \
-                    add_missing_newline.diff                                \
+# address issues in the build system:
+# - build and link VSTControlOSX.mm instead of the GTk interface
+# - address a visibility issue with the slider_array variable in libnyquist
+# - make the AudioUnits plugin support build; on 64bit and also include AUControl.mm
+patchfiles-append \
+                    fix-minsrc-autoreconf.patch                             \
                     libvamp-Makefile-for-osx.diff                           \
                     src-Makefile-for-osx.diff                               \
-                    FFmpeg_build_against_ffmpeg.diff                       \
                     portaudio-no-universal-build.diff                       \
                     buildinfo-clarify-no-gstreamer.diff                     \
                     add_enGB_translation.diff                               \
                     patch-avoid-clang-choke-on-confbase.diff                \
-                    patch-no-rtld_deepbind.diff                             \
                     patch-more-decent-font-sizes.diff                       \
-                    patch-python.diff
-
-# address issues in the build system:
-# - build and link VSTControlOSX.mm instead of the GTk interface
-# - address a visibility issue with the slider_array variable in libnyquist
-# - make the AudioUnits plugin support build; on 64bit and also include AUControl.mm
-patchfiles-append   patch-vstcontrolosx.diff \
+                    patch-python.diff                                       \
+                    patch-vstcontrolosx.diff \
                     patch-libnyquist-symbol-visibility.diff \
+                    patch-fix-casts.diff \
+                    patch-add-MenusMac.diff \
+                    patch-skip-gcc-version-test.diff
+
+if {${subport} eq "${name}"} {
+    patchfiles-append \
                     patch-fix-audiounits.diff
 
+    patchfiles-append \
+} else {
+    patchfiles-append \
+                    devel/patch-fix-audiounits.diff \
+                    devel/patch-temp-fixes.h
+}
+
 post-patch {
     set python_bin ${prefix}/bin/python2.7
     reinplace -W ${worksrcpath} "s|@@PYTHON@@|${python_bin}|g" \
@@ -127,8 +154,11 @@
         if {![file exists ${worksrcpath}/${d}/${f}.mm]} {
             ln -s ${f}.cpp ${worksrcpath}/${d}/${f}.mm
         }
-        reinplace -W ${worksrcpath} "s|/VSTControlGTK.cpp|/VSTControlOSX.mm|g" \
+    }
+    reinplace -W ${worksrcpath} "s|/VSTControlGTK.cpp|/VSTControlOSX.mm|g" \
             src/Makefile.in src/Makefile.am
+    if {[file exists ${worksrcpath}/src/MenusMac.cpp] && ![file exists ${worksrcpath}/src/MenusMac.mm]} {
+        ln -s MenusMac.cpp ${worksrcpath}/src/MenusMac.mm
     }
 }
 
@@ -157,8 +187,6 @@
                     WX_CONFIG=${wxWidgets.wxconfig}
 
 set aud_app_path    ${applications_dir}/Audacity.app
-# the following causes an empty directory to be created and preserved at installation
-# to allow the default en language localization to function properly (#50724)
 destroot.keepdirs   ${destroot}${aud_app_path}/Contents/Resources/en.lproj
 
 post-destroot {
@@ -195,3 +223,5 @@
     system "echo \"#!/bin/sh\nexec \\\"${aud_app_path}/Contents/MacOS/Audacity\\\" \\\"\\\$\@\\\"\" > ${destroot}${prefix}/bin/audacity"
     system "chmod 755 ${destroot}${prefix}/bin/audacity"
 }
+
+# kate: backspace-indents true; indent-pasted-text true; indent-width 4; keep-extra-spaces true; remove-trailing-spaces modified; replace-tabs true; replace-tabs-save true; syntax Tcl/Tk; tab-indents true; tab-width 4;
