--- /opt/local/var/macports/sources/git.macports.org/dports/audio/audacity/Portfile	2016-12-21 23:31:02.000000000 +0100
+++ audio/audacity/Portfile	2017-02-02 14:19:32.000000000 +0100
@@ -1,28 +1,12 @@
 # -*- 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
 
-# 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 +19,41 @@
                     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.2
+    github.setup        audacity audacity ${version} Audacity-
+    github.tarball_from releases
+    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}
+    }
+} else {
+    # git describe --tags : Audacity-2.1.2-1543-g25b7a00
+    # github.setup        audacity audacity 25b7a0040f34e416ab43df2054ccc7bf43b34495
+    # git describe --tags : Audacity-2.1.2-1652-g0cb89a8
+    github.setup        audacity audacity 0cb89a895a25e4f1e7ca4045d0b95e786bce7ed2
+    version             2.1.2.1652
+    # 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
@@ -71,11 +90,13 @@
 
 patch.pre_args      -Np1
 
-patchfiles-append   debian/patches/fix-minsrc-autoreconf.patch              \
+if {${subport} eq "${name}"} {
+    patchfiles-append \
+                    fix-minsrc-autoreconf.patch                             \
                     add_missing_newline.diff                                \
                     libvamp-Makefile-for-osx.diff                           \
                     src-Makefile-for-osx.diff                               \
-                    FFmpeg_build_against_ffmpeg.diff                       \
+                    FFmpeg_build_against_ffmpeg.diff                        \
                     portaudio-no-universal-build.diff                       \
                     buildinfo-clarify-no-gstreamer.diff                     \
                     add_enGB_translation.diff                               \
@@ -84,13 +105,34 @@
                     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 \
+    # 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-libnyquist-symbol-visibility.diff \
                     patch-fix-audiounits.diff
+} else {
+    patchfiles-append \
+                    devel/fix-minsrc-autoreconf.patch                        \
+                    devel/libvamp-Makefile-for-osx.diff                      \
+                    devel/src-Makefile-for-osx.diff                          \
+                    devel/portaudio-no-universal-build.diff                  \
+                    devel/buildinfo-clarify-no-gstreamer.diff                \
+                    devel/add_enGB_translation.diff                          \
+                    devel/patch-avoid-clang-choke-on-confbase.diff           \
+                    devel/patch-more-decent-font-sizes.diff                  \
+                    devel/patch-python.diff
+
+    patchfiles-append \
+                    devel/patch-vstcontrolosx.diff \
+                    devel/patch-libnyquist-symbol-visibility.diff \
+                    devel/patch-fix-audiounits.diff
+    patchfiles-append \
+                    devel/patch-fix-casts.diff \
+                    devel/patch-add-MenusMac.diff
+}
 
 post-patch {
     set python_bin ${prefix}/bin/python2.7
@@ -127,8 +169,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 {${subport} eq "${name}-devel"} {
+        ln -s MenusMac.cpp ${worksrcpath}/src/MenusMac.mm
     }
 }
 
@@ -157,8 +202,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 +238,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;
