--- /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-27 18:03:51.000000000 +0200
@@ -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,62 +20,106 @@
                     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
 license_noconflict  openssl
 maintainers         gmail.com:rjvbertin openmaintainer
 universal_variant   no
-use_parallel_build  no
+use_parallel_build  yes
 
 homepage            http://www.audacityteam.org/
 
+compiler.blacklist  {*gcc-[234].[0-8]}
+
 wxWidgets.use       wxWidgets-3.0
+depends_build-append \
+                    port:${wxWidgets.port}
 
 depends_build-append \
                     port:cmake \
                     port:pkgconfig \
                     port:python27
-depends_lib-append  port:expat \
-                    path:lib/libavcodec.dylib:ffmpeg \
-                    port:flac \
+depends_build-append \
                     port:freetype \
                     port:harfbuzz \
                     port:lame \
                     port:libid3tag \
                     port:libmad \
+                    port:soundtouch \
+                    port:soxr \
+                    port:twolame
+depends_lib-append  port:expat \
+                    path:lib/libavcodec.dylib:ffmpeg \
+                    port:flac \
                     port:libogg \
                     port:libsndfile \
                     port:libvorbis \
-                    port:portaudio \
-                    port:soundtouch \
-                    port:soxr \
-                    port:twolame \
-                    port:${wxWidgets.port}
+                    port:portaudio
 # audacity could use port:lv2 and port:lilv but would also require a port:suil for that to be possible.
 
 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
+platform darwin {
+    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
+} else {
+    patchfiles-append \
+                    devel/patch-fix-audiounits.diff \
+                    devel/patch-temp-fixes.h
+}
 
 post-patch {
     set python_bin ${prefix}/bin/python2.7
@@ -109,26 +138,31 @@
     reinplace -W ${worksrcpath} "s| -Werror||g" \
                                 lib-src/portaudio-v19/configure.in \
                                 lib-src/portaudio-v19/configure
-    # audacity 2.1.2 contains C++ files that include system SDK headers and ObjC code on OS X;
-    # they must thus be built as ObjC++
-    set make_objcpp { \
-        {CommandManager src/commands    {src/Makefile.in src/Makefile.am}} \
-        {Effect         src/effects     {src/Makefile.in src/Makefile.am}} \
-        {LV2Effect      src/effects/lv2 {src/Makefile.in src/Makefile.am}} \
-    }
-    foreach mm ${make_objcpp} {
-        set f  [lindex ${mm} 0]
-        set d  [lindex ${mm} 1]
-        set mk [lindex ${mm} 2]
-        foreach m ${mk} {
-            reinplace -W ${worksrcpath} "s|/${f}.cpp|/${f}.mm|g" ${m}
-        }
-        # it's easiest to symlink f.mm to f.cpp; clang++ will do the rest.
-        if {![file exists ${worksrcpath}/${d}/${f}.mm]} {
-            ln -s ${f}.cpp ${worksrcpath}/${d}/${f}.mm
+    platform darwin {
+        # audacity 2.1.2 contains C++ files that include system SDK headers and ObjC code on OS X;
+        # they must thus be built as ObjC++
+        set make_objcpp { \
+            {CommandManager src/commands    {src/Makefile.in src/Makefile.am}} \
+            {Effect         src/effects     {src/Makefile.in src/Makefile.am}} \
+            {LV2Effect      src/effects/lv2 {src/Makefile.in src/Makefile.am}} \
+        }
+        foreach mm ${make_objcpp} {
+            set f  [lindex ${mm} 0]
+            set d  [lindex ${mm} 1]
+            set mk [lindex ${mm} 2]
+            foreach m ${mk} {
+                reinplace -W ${worksrcpath} "s|/${f}.cpp|/${f}.mm|g" ${m}
+            }
+            # it's easiest to symlink f.mm to f.cpp; clang++ will do the rest.
+            if {![file exists ${worksrcpath}/${d}/${f}.mm]} {
+                ln -s ${f}.cpp ${worksrcpath}/${d}/${f}.mm
+            }
         }
         reinplace -W ${worksrcpath} "s|/VSTControlGTK.cpp|/VSTControlOSX.mm|g" \
-            src/Makefile.in src/Makefile.am
+                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
+        }
     }
 }
 
@@ -141,7 +175,7 @@
                     --enable-shared \
                     --enable-sse \
                     --with-ffmpeg \
-                    --with-lam \
+                    --with-lame \
                     --with-libflac \
                     --with-libmad \
                     --with-libsoxr \
@@ -156,42 +190,46 @@
                     CPPFLAGS=-I${prefix}/include \
                     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 {
-    # create the app bundle infrastructure
-    xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/MacOS
-    xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/Resources
-    # the BundleExec:
-    file rename ${destroot}${prefix}/bin/audacity ${destroot}${aud_app_path}/Contents/MacOS/Audacity
-    # install the Info.plist provided by Audacity
-    xinstall -m 644 ${worksrcpath}/mac/Info.plist ${destroot}${aud_app_path}/Contents/
-    # adapt the provided Info.plist
-    reinplace "s|AUDACITY_EXECUTABLE|Audacity|g" ${destroot}${aud_app_path}/Contents/Info.plist
-    reinplace "s|AUDACITY_INFO_VERSION|${version} (MacPorts)|g" ${destroot}${aud_app_path}/Contents/Info.plist
-    # install the provided icons into the Resources directory
-    foreach r [glob -nocomplain ${worksrcpath}/mac/Resources/*.icns] {
-        xinstall -m 644 ${r} ${destroot}${aud_app_path}/Contents/Resources/
-    }
-    # allow the application to find certain things where it expects them on OS X (= inside the app bundle)
-    foreach r [glob -nocomplain ${destroot}${prefix}/share/audacity/*] {
-        ln -s ${prefix}/share/audacity/[file tail ${r}] ${destroot}${aud_app_path}/Contents/Resources
-    }
-    # install translation resources
-    foreach l [glob -nocomplain ${destroot}${prefix}/share/locale/*] {
-        set lang [file tail ${l}]
-        xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj
-        ln -s ${prefix}/share/locale/${lang}/LC_MESSAGES/audacity.mo ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj/
-    }
-    foreach l [glob -nocomplain ${wxWidgets.prefix}/share/locale/*] {
-        set lang [file tail ${l}]
-        xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj
-        ln -s ${l}/LC_MESSAGES/wxstd.mo ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj/
+build.args-append   V=1 VERBOSE=1
+
+platform darwin {
+    set aud_app_path    ${applications_dir}/Audacity.app
+    destroot.keepdirs   ${destroot}${aud_app_path}/Contents/Resources/en.lproj
+
+    post-destroot {
+        # create the app bundle infrastructure
+        xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/MacOS
+        xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/Resources
+        # the BundleExec:
+        file rename ${destroot}${prefix}/bin/audacity ${destroot}${aud_app_path}/Contents/MacOS/Audacity
+        # install the Info.plist provided by Audacity
+        xinstall -m 644 ${worksrcpath}/mac/Info.plist ${destroot}${aud_app_path}/Contents/
+        # adapt the provided Info.plist
+        reinplace "s|AUDACITY_EXECUTABLE|Audacity|g" ${destroot}${aud_app_path}/Contents/Info.plist
+        reinplace "s|AUDACITY_INFO_VERSION|${version} (MacPorts)|g" ${destroot}${aud_app_path}/Contents/Info.plist
+        # install the provided icons into the Resources directory
+        foreach r [glob -nocomplain ${worksrcpath}/mac/Resources/*.icns] {
+            xinstall -m 644 ${r} ${destroot}${aud_app_path}/Contents/Resources/
+        }
+        # allow the application to find certain things where it expects them on OS X (= inside the app bundle)
+        foreach r [glob -nocomplain ${destroot}${prefix}/share/audacity/*] {
+            ln -s ${prefix}/share/audacity/[file tail ${r}] ${destroot}${aud_app_path}/Contents/Resources
+        }
+        # install translation resources
+        foreach l [glob -nocomplain ${destroot}${prefix}/share/locale/*] {
+            set lang [file tail ${l}]
+            xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj
+            ln -s ${prefix}/share/locale/${lang}/LC_MESSAGES/audacity.mo ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj/
+        }
+        foreach l [glob -nocomplain ${wxWidgets.prefix}/share/locale/*] {
+            set lang [file tail ${l}]
+            xinstall -m 755 -d ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj
+            ln -s ${l}/LC_MESSAGES/wxstd.mo ${destroot}${aud_app_path}/Contents/Resources/${lang}.lproj/
+        }
+        # install a wrapper script in ${prefix}/bin
+        system "echo \"#!/bin/sh\nexec \\\"${aud_app_path}/Contents/MacOS/Audacity\\\" \\\"\\\$\@\\\"\" > ${destroot}${prefix}/bin/audacity"
+        system "chmod 755 ${destroot}${prefix}/bin/audacity"
     }
-    # install a wrapper script in ${prefix}/bin
-    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;
