# first extract the source as ~/gwc and run configure in that directory
make DESTDIR=~/gwc/osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources install
mv osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/bin/gtk-wave-cleaner osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/MacOS/gtk-wave-cleaner-bin
rmdir osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/bin
mkdir osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/lib/libgtkmacintegration-gtk2.2.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/gtk+/lib/libgtk-quartz-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/gtk+/lib/libgdk-quartz-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/pango/lib/libpangocairo-1.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/pango/lib/libpango-1.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/atk/lib/libatk-1.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/cairo/lib/libcairo.2.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/gdk-pixbuf/lib/libgdk_pixbuf-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/glib/lib/libgio-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/glib/lib/libgobject-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/glib/lib/libglib-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/gettext/lib/libintl.8.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libsndfile/lib/libsndfile.1.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/fftw/lib/libfftw3.3.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libffi/3.2.1/lib/libffi.6.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/fontconfig/2.12.1_2/lib/libfontconfig.1.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/freetype/2.7.1/lib/libfreetype.6.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/glib/2.52.0/lib/libgmodule-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/pixman/0.34.0/lib/libpixman-1.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libpng/1.6.29/lib/libpng16.16.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/flac/lib/libFLAC.8.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/glib/lib/libgthread-2.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/harfbuzz/lib/libharfbuzz.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libogg/lib/libogg.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libpango/lib/libpangoft2-1.0.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/pcre/lib/libpcre.1.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libvorbis/lib/libvorbis.0.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
cp /usr/local/opt/libvorbis/lib/libvorbisenc.2.dylib osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/
mkdir osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/gdk-pixbuf-2.0/loaders
cp /usr/local/opt/gdk-pixbuf/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-xpm.so osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/gdk-pixbuf-2.0/loaders

strip osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/MacOS/gtk-wave-cleaner-bin
for i in osx_packaging/Gtk\ Wave\ Cleaner.app/Contents/Resources/lib/*; do strip -x "$i"; done
hdiutil create -fs "Case-sensitive HFS+" -volname "Gtk Wave Cleaner" -srcfolder osx_packaging/Gtk\ Wave\ Cleaner.app GWC-stripped.dmg
