diff --git a/README.md b/README.md
index 1b612a843c449b013e1ef98dbc5b795e74378870..0b236feb6b73015ba0d643d7c44cf97180345b8a 100644
--- a/README.md
+++ b/README.md
@@ -201,16 +201,28 @@ Hard drive space required: *roughly 2 GB*
         brew install libtool
         brew install fftw
         brew install python
-        brew install python-markdown
         brew install lua
         brew install fluidsynth
+        brew install faac
+        brew install jpeg
         brew install lame
         brew install libvorbis
         brew install speex
         brew install gsl
         brew install libquicktime
+        brew install sdl2
         brew install pkg-config
 
+   You'll also need to install the python markdown module to generate the
+   platform-specific release notes (ReadMe.html, Welcome.html):
+
+        pip3 install markdown
+
+   **Note:** Depending on your macOS and Xcode version, the 10 minutes
+   estimate for this step may be a overly optimistic. Some build dependencies
+   may require recompilation which can take a long time (up to several hours,
+   if it includes a complete build of, e.g., gcc and cmake).
+
 3. Clone the Purr-Data repository *(10 minutes)*
 
         git clone https://git.purrdata.net/jwilkes/purr-data.git
diff --git a/abstractions/footils/list-abs/Makefile b/abstractions/footils/list-abs/Makefile
index 39020dd7bd9fe3f0acd1d351046cceb9683682ea..f84f77bbbe779fdb323afb67bf5d50a650447dad 100644
--- a/abstractions/footils/list-abs/Makefile
+++ b/abstractions/footils/list-abs/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/abstractions/purepd/Makefile b/abstractions/purepd/Makefile
index 19c30b1dc4a763e2656493d352a7547514d268a0..08ca20d5ed421d2c2a668dbfe95062d9cd893e77 100644
--- a/abstractions/purepd/Makefile
+++ b/abstractions/purepd/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/Makefile b/externals/Makefile
index c1659e503bbbf85f2e184d2f2524499148c70610..f781fe1a2471ae60991aaa34449d3046fb74c9fd 100644
--- a/externals/Makefile
+++ b/externals/Makefile
@@ -54,14 +54,23 @@ LIBS = -lm
 
 ifeq ($(OS_NAME),darwin)
 # 10.4 Tiger
-  FAT_FLAGS = -arch ppc -arch ppc64 -arch i386
+#  FAT_FLAGS = -arch ppc -arch ppc64 -arch i386
 # 10.5 Leopard
 #  FAT_FLAGS = -arch ppc -arch ppc7400 -arch ppc64 -arch i386 -arch x86_64
-  CFLAGS += -I/sw/include -I$(externals_src)/pdp/include -DMACOSX -DUNIX -Dunix -DDL_OPEN
-  LDFLAGS += -bundle -bundle_loader $(pd_src)/bin/pd-l2ork -undefined dynamic_lookup \
-		-L/sw/lib -weak_framework Carbon
+# Check whether we have Homebrew or MacPorts, prefer the former.
+optlocal := $(shell (test -d /usr/local/opt && echo /usr/local/opt) || (test -d /opt/local && echo /opt/local) || echo /usr/local)
+ifeq ($(optlocal),/opt/local)
+# MacPorts installs directly into $(optlocal)
+usrlocal = $(optlocal)
+else
+# Homebrew links software into /usr/local, which also works for locally
+# installed software if neither MP nor Homebrew is detected.
+usrlocal = /usr/local
+endif
+  CFLAGS += -I$(usrlocal)/include -I$(externals_src)/pdp/include -DMACOSX -DUNIX -Dunix -DDL_OPEN
+  LDFLAGS += -bundle -bundle_loader $(pd_src)/bin/pd-l2ork -undefined dynamic_lookup -L$(usrlocal)/lib
   LIBS += -lc 
-  DYLIB_LDFLAGS = -dynamiclib -undefined dynamic_lookup -read_only_relocs warning -L/sw/lib
+  DYLIB_LDFLAGS = -dynamiclib -undefined dynamic_lookup -read_only_relocs warning -L$(usrlocal)/lib
   STRIP = strip -x
 endif
 ifeq ($(OS_NAME),linux)
@@ -153,9 +162,10 @@ ifeq ($(OS_NAME),windows)
 else
   ifeq ($(OS_NAME),darwin)
 # on Mac OS X 10.6/Snow Leopard don't build hid since it needs Carbon
-    lib_targets += pdp iem16 apple
-    ifneq ($(shell uname -r | sed 's|10\.[0-9][0-9]*\.[0-9][0-9]*|10|'),10)
-      lib_targets +=
+    ifeq ($(INCREMENTAL),yes)
+	lib_targets += pdp iem16 apple
+    else
+	lib_targets += gem pdp iem16 apple
     endif
   else ifneq ($(LIGHT),yes)
     # GNU/Linux, BSD, IRIX, etc. (we use exported variable INCREMENTAL to
@@ -706,22 +716,50 @@ $(gem_src)/Gem.pd_linux: $(gem_src)/configure
 		cd $(gem_src) && ./configure \
 			CXXFLAGS="-DHAVE_S_STUFF_H $(CFLAGS_ADD)" \
 			--prefix=$(prefix) \
-			--with-video=plugins \
-			--with-film=plugins \
 			--with-pd=$(pd_src)
 	$(MAKE) $(GEM_MAKEFLAGS) -C $(gem_src)
 
+# Mac: This is still a bit experimental. At present, many of the window
+# backends seem to be at least half-broken on recent macOS versions, including
+# the native gemmacoswindow, which the wiki recommends. For me, the SDL2
+# backend works best, on Mojave at least, so that's what we include as the
+# default here. NOTES: In MacPorts, libquicktime is unmaintained and doesn't
+# build, so it is currently excluded from the MacPorts build. AVF, which is
+# supposed to replace libquicktime, is enabled by default on the Mac, but
+# right now it only seems to work for video capture, not loading or recording.
+# We also exclude ImageMagick, which is needed for improved image support,
+# because it currently isn't in our OSX build requirements. But if you have it
+# (it's available in both Homebrew and MacPorts), you can enable it below.
+
+ifeq ($(optlocal),/opt/local)
+# MacPorts
+gem_quicktime = --without-libquicktime
+else
+# Homebrew
+gem_quicktime = --with-libquicktime --with-libquicktime-LIBS="-L$(usrlocal)/lib -lquicktime"
+endif
+
+# Uncomment to enable ImageMagick support. This needs imagemagick from Hombrew
+# or ImageMagick from MacPorts.
+#gem_magick = --with-MagickCore --with-MagickCore-CFLAGS="$(shell pkg-config --cflags MagickCore)" --with-MagickCore-LIBS="$(shell pkg-config --libs MagickCore)"
+
+# Adjust this as needed/wanted. If you comment this out, you'll get the
+# default gemmacoswindow which doesn't work for me, YMMV.
+gem_window = --with-sdl2 --with-sdl2-LIBS="-L$(usrlocal)/lib -lSDL2" --with-defaultwindow=gemsdl2window
+
 $(gem_src)/Gem.pd_darwin: $(gem_src)/configure
 	cd $(gem_src) && ./configure \
 		CXXFLAGS="-DHAVE_S_STUFF_H $(CFLAGS_ADD)" \
-		PKG_FTGL_CFLAGS="-I/sw/include -I/sw/include/freetype2 -I/sw/include/FTGL" \
 		--prefix=$(prefix) \
 		--libdir=$(objectsdir) \
 		--without-ALL \
-		--with-ftgl --with-ftgl-libs=/sw/lib \
-		--with-artoolkit-includes=/sw/include --with-artoolkit-libs=/sw/lib \
-		--with-video=plugins \
-		--with-film=plugins \
+		--without-QuickTime-framework --without-Carbon-framework \
+		--with-ftgl --with-ftgl-LIBS="-L$(usrlocal)/lib -lftgl" \
+		--with-tiff --with-tiff-LIBS="-L$(usrlocal)/lib -ltiff" \
+		--with-jpeg --with-jpeg-LIBS="-L$(usrlocal)/lib -ljpeg" \
+		$(gem_quicktime) $(gem_magick) \
+		$(gem_window) \
+		--without-ndi --without-DeckLink \
 		--with-pd=$(pd_src)
 	$(MAKE) $(GEM_MAKEFLAGS) -C $(gem_src)
 
@@ -2334,7 +2372,7 @@ etags_Darwin:
 	etags -a $(externals_src)/hcs/hid/HID\ Utilities\ Source/*.[ch]
 	find /System/Library/Frameworks  -type f -name \*.h -exec etags -a '{}' \;
 	find /Library/Frameworks  -type f -name \*.h -exec etags -a '{}' \;
-	find /sw/include -type f -name \*.h -exec etags -a '{}' \;
+	find /usr/local/include/ -type f -name \*.h -exec etags -a '{}' \;
 
 etags_Linux:
 
diff --git a/externals/apple/Makefile b/externals/apple/Makefile
index a7eac85106e7fab7cecbb3e12bbcb65a97d4bedf..b8e367473debe042bf9c51ddb021f3b921ae9aca 100644
--- a/externals/apple/Makefile
+++ b/externals/apple/Makefile
@@ -121,10 +121,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/arraysize/Makefile b/externals/arraysize/Makefile
index b2c93f3602e95b8e985d2d3b4ecb8dbdc54c0fe0..3805e841448bb2005610e1a1427471faa1c090ce 100644
--- a/externals/arraysize/Makefile
+++ b/externals/arraysize/Makefile
@@ -101,9 +101,9 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/autotune/Makefile b/externals/autotune/Makefile
index 20737751cd05e49a0b22ca280d7a026a17cef040..ed41cb625a2a24f123768bd803a3c4e11352edb1 100644
--- a/externals/autotune/Makefile
+++ b/externals/autotune/Makefile
@@ -100,9 +100,9 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/opt/local/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/bassemu~/Makefile b/externals/bassemu~/Makefile
index 0dee92919f88e5fb24e2a27189b1390be4b9ef94..00d2eb4207e7ccccfbbe9f95985a879005bfb0a1 100644
--- a/externals/bassemu~/Makefile
+++ b/externals/bassemu~/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/beatpipe/Makefile b/externals/beatpipe/Makefile
index 1b97abfda26f01af5071380efc58d294f857e7ed..cd2c30c08804fee9f3544e3262416453074664bb 100644
--- a/externals/beatpipe/Makefile
+++ b/externals/beatpipe/Makefile
@@ -97,9 +97,9 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/bendinfix/Makefile.pdlibbuilder.revised b/externals/bendinfix/Makefile.pdlibbuilder.revised
index c2da4e48d8390f5eb0324f874d76e95f33d4949a..177bd7d85e33cab6ebac89ad032fe69c9edcdcbb 100644
--- a/externals/bendinfix/Makefile.pdlibbuilder.revised
+++ b/externals/bendinfix/Makefile.pdlibbuilder.revised
@@ -523,7 +523,7 @@ ifeq ($(system), Darwin)
     /Applications/Pd-extended*.app/Contents/Resources/include/pdextended \
     /Applications/Pd*.app/Contents/Resources/src))
   extension = pd_darwin
-  cpp.flags := -DUNIX -DMACOSX -I /sw/include
+  cpp.flags := -DUNIX -DMACOSX
   c.flags := 
   c.ldflags := -undefined suppress -flat_namespace -bundle
   c.ldlibs := -lc
diff --git a/externals/boids/Makefile b/externals/boids/Makefile
index e5d16bc77ba599a6de8473e0f32bd427ecf264f6..ad0e4d1e0f46531bcd5f316ea240b8061dce0fe6 100644
--- a/externals/boids/Makefile
+++ b/externals/boids/Makefile
@@ -102,8 +102,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/bsaylor/Makefile b/externals/bsaylor/Makefile
index bc2d032dc3bbdb4e8c0c4f1f51310376f62233b0..e60e961d34989bdbf78c7e9adb83e935097238d7 100644
--- a/externals/bsaylor/Makefile
+++ b/externals/bsaylor/Makefile
@@ -103,8 +103,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/build/darwin/makefile b/externals/build/darwin/makefile
index fd7254f4a4a43c0259d91703fd5afdbefcde607f..3244822c5b417fd507ebf87243bb979c2ea3a65e 100644
--- a/externals/build/darwin/makefile
+++ b/externals/build/darwin/makefile
@@ -33,8 +33,8 @@ OPTIM_FLAGS = -mpowerpc-gpopt -mcpu=750
 
 CFLAGS = -DPD -DUNIX -DMACOSX -Dunix $(OPTIM_FLAGS) \
     -Wall -W -Wno-unused -Wno-parentheses -Wno-switch -Wno-shadow 
-INCLUDES = -I$(pd_src)/src -I/sw/include
-LDFLAGS = -bundle  -bundle_loader $(PDEXECUTABLE) -L/sw/lib
+INCLUDES = -I$(pd_src)/src
+LDFLAGS = -bundle  -bundle_loader $(PDEXECUTABLE)
 
 externals: $(EXTERNALS:.c=.pd_darwin)
 
diff --git a/externals/cxc/Makefile b/externals/cxc/Makefile
index de83b3cbad541077d9e10cb1c7e8043c7ac14ea9..61fbc3c9b19260bb7d1f9c504872fdb45c3a8d8e 100644
--- a/externals/cxc/Makefile
+++ b/externals/cxc/Makefile
@@ -105,8 +105,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/deprecated/Makefile b/externals/deprecated/Makefile
index 5d351d5c5f20f1a2d6e308efeb1ccbd94d69fcf0..ba76cc59cb71b3cc39d43ff802cf76c6db6e060f 100644
--- a/externals/deprecated/Makefile
+++ b/externals/deprecated/Makefile
@@ -80,9 +80,9 @@ ifeq ($(UNAME),Darwin)
     OS = macosx
     OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
     FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=10.4
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/disis/Makefile.pdlibbuilder.revised b/externals/disis/Makefile.pdlibbuilder.revised
index 07fa86d97dcbb4b6ca07df2025289c870eb03c57..7ad6afcc5c7535b3b170d2f81c30666571df336d 100644
--- a/externals/disis/Makefile.pdlibbuilder.revised
+++ b/externals/disis/Makefile.pdlibbuilder.revised
@@ -417,7 +417,7 @@ ifeq ($(system), Darwin)
     /Applications/Pd-extended*.app/Contents/Resources/include/pdextended \
     /Applications/Pd*.app/Contents/Resources/src))
   extension = pd_darwin
-  cpp.flags := -DUNIX -DMACOSX -I /sw/include
+  cpp.flags := -DUNIX -DMACOSX
   c.flags := 
   c.ldflags := -undefined suppress -flat_namespace -bundle
   c.ldlibs := -lc
diff --git a/externals/earplug~/Makefile b/externals/earplug~/Makefile
index b2a0d389b7a07207f9b5b9f675a4d79ccfd3a506..63b0683960a9370c187b5cf0409c32e283935ab4 100644
--- a/externals/earplug~/Makefile
+++ b/externals/earplug~/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/ekext/Makefile b/externals/ekext/Makefile
index d5c6685c9a7571b993732c0e791b111e97e82952..322c5162251c5b2f35dc43366335639c90bde54a 100644
--- a/externals/ekext/Makefile
+++ b/externals/ekext/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/ext13/Makefile b/externals/ext13/Makefile
index 2f5f389835bb76d9080bdeef8970782236bce7b4..3ca4e4f7eb804f81acb4d08e9df9cc18fea74257 100644
--- a/externals/ext13/Makefile
+++ b/externals/ext13/Makefile
@@ -107,8 +107,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/ezfile/Makefile b/externals/ezfile/Makefile
index 189c6057d4b28446cd343023930b10cb1a926284..858cef59198cbd97c6e7365abc181353a7ea8775 100644
--- a/externals/ezfile/Makefile
+++ b/externals/ezfile/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/fftease/Makefile b/externals/fftease/Makefile
index 25a8b8b4394bacc54d238b51780f14180f794de4..d58a63a6ac6d5a225932a3e54d066816f8aa4e14 100644
--- a/externals/fftease/Makefile
+++ b/externals/fftease/Makefile
@@ -130,7 +130,7 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
diff --git a/externals/fluid~/Makefile.pdlibbuilder.revised b/externals/fluid~/Makefile.pdlibbuilder.revised
index c2da4e48d8390f5eb0324f874d76e95f33d4949a..177bd7d85e33cab6ebac89ad032fe69c9edcdcbb 100644
--- a/externals/fluid~/Makefile.pdlibbuilder.revised
+++ b/externals/fluid~/Makefile.pdlibbuilder.revised
@@ -523,7 +523,7 @@ ifeq ($(system), Darwin)
     /Applications/Pd-extended*.app/Contents/Resources/include/pdextended \
     /Applications/Pd*.app/Contents/Resources/src))
   extension = pd_darwin
-  cpp.flags := -DUNIX -DMACOSX -I /sw/include
+  cpp.flags := -DUNIX -DMACOSX
   c.flags := 
   c.ldflags := -undefined suppress -flat_namespace -bundle
   c.ldlibs := -lc
diff --git a/externals/footils/knob/Makefile.pdlibbuilder.revised b/externals/footils/knob/Makefile.pdlibbuilder.revised
index c2da4e48d8390f5eb0324f874d76e95f33d4949a..177bd7d85e33cab6ebac89ad032fe69c9edcdcbb 100644
--- a/externals/footils/knob/Makefile.pdlibbuilder.revised
+++ b/externals/footils/knob/Makefile.pdlibbuilder.revised
@@ -523,7 +523,7 @@ ifeq ($(system), Darwin)
     /Applications/Pd-extended*.app/Contents/Resources/include/pdextended \
     /Applications/Pd*.app/Contents/Resources/src))
   extension = pd_darwin
-  cpp.flags := -DUNIX -DMACOSX -I /sw/include
+  cpp.flags := -DUNIX -DMACOSX
   c.flags := 
   c.ldflags := -undefined suppress -flat_namespace -bundle
   c.ldlibs := -lc
diff --git a/externals/freeverb~/Makefile b/externals/freeverb~/Makefile
index e67ba10a04fccb53c710929d8d9f60f2839a25db..c5bc5dd49267dc35de2da6e9d6b18ac3cad5feef 100644
--- a/externals/freeverb~/Makefile
+++ b/externals/freeverb~/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/gem2pdp/configure.ac b/externals/gem2pdp/configure.ac
index be8bf645bb973f7fb0591fc5b13ada94901a8ee7..da6f80bbb56e52a6394085144890320ca401ec10 100644
--- a/externals/gem2pdp/configure.ac
+++ b/externals/gem2pdp/configure.ac
@@ -104,14 +104,9 @@ case "$host" in
    *-darwin* | *-macos10*)
 	  EXTENSION=pd_darwin
 	  LDFLAGS="$LDFLAGS -bundle -undefined dynamic_lookup"
-  	  # Check for DarwinPorts and/or Fink on Mac OS X/Darwin
-     if test -d /sw ; then
-       # Fink
-       PATH="/sw/bin:/sw/sbin:$PATH"
-       INCLUDES="$INCLUDES -I/sw/include"
-       LIBS="$LIBS -L/sw/lib"
-     elif test -d /opt/local ; then
-       # DarwinPorts
+	  # Check for MacPorts on Mac OS X/Darwin
+     if test -d /opt/local ; then
+       # MacPorts
        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
        INCLUDES="$INCLUDES -I/opt/local/include"
        LIBS="$LIBS -L/opt/local/lib"
diff --git a/externals/ggee/Makefile b/externals/ggee/Makefile
index 1057b612f6d51709a0323c04a1834865dfed036b..1dea6b62c71d648420e0852804b8cd7638a0ad50 100644
--- a/externals/ggee/Makefile
+++ b/externals/ggee/Makefile
@@ -104,8 +104,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/hardware/multio/Makefile b/externals/hardware/multio/Makefile
index ede6349ebc5a4b023ca05cf4e3ffa684e297abb2..999fb85057546a50761ad839f98469a2eb509948 100755
--- a/externals/hardware/multio/Makefile
+++ b/externals/hardware/multio/Makefile
@@ -57,8 +57,8 @@ pd_darwin: $(NAME).pd_darwin
 
 DARWINCFLAGS = -DPD -O2 -Wall -W
 
-DARWININCLUDE =  -I../../src -I$(pd_src)/src -I/sw/include
-DARWINLIBS = -L/sw/lib -lusb
+DARWININCLUDE =  -I../../src -I$(pd_src)/src
+DARWINLIBS = -lusb
 
 .c.pd_darwin:
 	$(CC) $(DARWINCFLAGS) $(DARWININCLUDE) -o $*.o -c $*.c
diff --git a/externals/hardware/wiimote/autogen.sh b/externals/hardware/wiimote/autogen.sh
index 27b75c66aecd9fab2a8c778506727270190f2dbe..f261730b13fd7aa7388ff502654f7ff03bf22c0b 100755
--- a/externals/hardware/wiimote/autogen.sh
+++ b/externals/hardware/wiimote/autogen.sh
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-PATH=/sw/bin:$PATH
-
 PWD=${0%/*}
 
 
diff --git a/externals/hcs/Makefile b/externals/hcs/Makefile
index 06928b2d23d99874a26c144f3ed7fe31c59aafe4..cf2ec2dc80e4feb9946f716cb20225e13e03293e 100644
--- a/externals/hcs/Makefile
+++ b/externals/hcs/Makefile
@@ -116,10 +116,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/hcs/usbhid/Makefile b/externals/hcs/usbhid/Makefile
index 6aadb6de0c2f398ae96864298ac99b9eae4a80c0..62830c9f92ab46e9bf4d1dd925c0db5b5ce32a2b 100644
--- a/externals/hcs/usbhid/Makefile
+++ b/externals/hcs/usbhid/Makefile
@@ -83,9 +83,9 @@ ifeq ($(UNAME),Darwin)
     OS = macosx
     OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
     FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=$(macos_target)
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/iem/comport/comport/Makefile b/externals/iem/comport/comport/Makefile
index e2bf0bb7cd8554c97e63cd76f90a648cf7beef3f..b4640e07078a46f23194f977badfb1a54157c5e0 100644
--- a/externals/iem/comport/comport/Makefile
+++ b/externals/iem/comport/comport/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/iem/iemguts/Makefile b/externals/iem/iemguts/Makefile
index 72bc4d56c2c3dc71f5f00ce345e957064ca34f1d..d0112bc68bdbcceb410cb130bbad49fe5e09e857 100644
--- a/externals/iem/iemguts/Makefile
+++ b/externals/iem/iemguts/Makefile
@@ -150,9 +150,9 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/iem/iemnet/Makefile b/externals/iem/iemnet/Makefile
index 4d0714d91b8eb7880204bb231e71b4e1c9a247c7..8e396c1c2b18d26019ce6e0d096c4d9119972eee 100644
--- a/externals/iem/iemnet/Makefile
+++ b/externals/iem/iemnet/Makefile
@@ -93,9 +93,9 @@ ifeq ($(UNAME),Darwin)
     OS = macosx
     OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=0 -fast
     FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=$(macos_target)
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     LIBS += -lc 
     STRIP = strip -x
     DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
diff --git a/externals/iem/syslog/Makefile b/externals/iem/syslog/Makefile
index 405f1c14b013d641523a172924b48d34c404f2eb..aea5c7f661249d36b0d499ae7993649b42496cab 100644
--- a/externals/iem/syslog/Makefile
+++ b/externals/iem/syslog/Makefile
@@ -112,8 +112,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     ALL_LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LIBS += -lc 
diff --git a/externals/import/Makefile b/externals/import/Makefile
index 7b59b925e6b20174075c6add65ee446ba6ffd1d2..42985284bc0aae77aedce38b6c8a62077fd92aee 100644
--- a/externals/import/Makefile
+++ b/externals/import/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/io/hidio/autogen.sh b/externals/io/hidio/autogen.sh
index 582ecb1c84d5185f737b6bc53575d04ae869a1a7..690f2c9ef7a60f003fae9a38777e69df2315e730 100755
--- a/externals/io/hidio/autogen.sh
+++ b/externals/io/hidio/autogen.sh
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-PATH=/sw/bin:$PATH
-
 case `uname -s` in
     MINGW*)
 # autoreconf doesn't always work on MinGW
diff --git a/externals/io/sixaxis/Makefile b/externals/io/sixaxis/Makefile
index 51c9331a47c98d06fded424096ddb4640cf4d34c..0252b65cc4dcf04afab8884a924db20d8d2c9a24 100644
--- a/externals/io/sixaxis/Makefile
+++ b/externals/io/sixaxis/Makefile
@@ -79,9 +79,9 @@ ifeq ($(UNAME),Darwin)
     OS = macosx
     OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
     FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=10.4
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/io/xbee/Makefile b/externals/io/xbee/Makefile
index b7e3c40232f964f193d4fb8997faca35de17fd1f..61d037446455a50ee658aa9c325e1edfd81575d7 100644
--- a/externals/io/xbee/Makefile
+++ b/externals/io/xbee/Makefile
@@ -79,9 +79,9 @@ ifeq ($(UNAME),Darwin)
     OS = macosx
     OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
     FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=10.4
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/loaders/libdir/Makefile b/externals/loaders/libdir/Makefile
index 8088e85e81b5caa17bd9615f12f0c08dd34f2632..2ccebd7737cbce5958797ff2ec684c83bcf8f661 100644
--- a/externals/loaders/libdir/Makefile
+++ b/externals/loaders/libdir/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/lyonpotpourri/Makefile b/externals/lyonpotpourri/Makefile
index b2d80b58748b958d93eca1ea825f5c103964f2b9..85a240b8b1b3dfa279182c8bbf8ff4c0dc5e8fc7 100755
--- a/externals/lyonpotpourri/Makefile
+++ b/externals/lyonpotpourri/Makefile
@@ -124,7 +124,7 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
diff --git a/externals/mapping/Makefile b/externals/mapping/Makefile
index ad7b9bcf7790e01eb35936bb86d315e5811116b1..81f2a72f262ebb9a9d37422ff8561dd19cdc97a0 100644
--- a/externals/mapping/Makefile
+++ b/externals/mapping/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/markex/Makefile b/externals/markex/Makefile
index 22082204e56617ed24dcbb21f33d3f73e9efbbd0..1d1031d0fd1f7ba7457fcdeb288c4ad8e95580b3 100644
--- a/externals/markex/Makefile
+++ b/externals/markex/Makefile
@@ -111,10 +111,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/maxlib/Makefile b/externals/maxlib/Makefile
index cfc7a81edb3e03ff6008ff328246ea2bb65c3baa..437f27c5d5be36170ed1c3be33da3e9748fb51d8 100644
--- a/externals/maxlib/Makefile
+++ b/externals/maxlib/Makefile
@@ -120,11 +120,11 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/miXed/cyclone/Makefile.libdir b/externals/miXed/cyclone/Makefile.libdir
index dc1f925a25c689e948df9b1423185952e95babd7..08b15a49bf84452cb55b2ee6d9ccd0bc0b88c7af 100644
--- a/externals/miXed/cyclone/Makefile.libdir
+++ b/externals/miXed/cyclone/Makefile.libdir
@@ -46,8 +46,8 @@ ifeq ($(UNAME),Darwin)
     else
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd-l2ork && echo -bundle_loader $(PD_PATH)/bin/pd-l2ork)
     LIBS += -lc 
diff --git a/externals/mjlib/Makefile b/externals/mjlib/Makefile
index 0b99f4ffab670132bcc67449f318910bf92ff0f2..85e2d8d2c20205ffee671f3e783a25d25ee940d5 100644
--- a/externals/mjlib/Makefile
+++ b/externals/mjlib/Makefile
@@ -102,8 +102,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/moocow/extended/Makefile b/externals/moocow/extended/Makefile
index c5c7878c3427c28ef18fb6ce3140aef7a6d4f99d..148016c1981fbe20ccbdfe73c011b88665f313fa 100644
--- a/externals/moocow/extended/Makefile
+++ b/externals/moocow/extended/Makefile
@@ -34,8 +34,8 @@ MOOCOW_BUILD_VERSION ?=2009-04-27.002
 #	CFLAGS="$(subst ',,$(CFLAGS))" ##-- works
 #	CFLAGS="$(shell echo $(CFLAGS))" ##-- works
 CONFIGURE_ARGS=\
-	CFLAGS="$(CFLAGS) -I/sw/include" \
-	LDFLAGS="$(LDFLAGS) -L$(pd_src)/src -L$(pd_src)/bin -L$(pd_src)/obj -L/sw/lib" \
+	CFLAGS="$(CFLAGS)" \
+	LDFLAGS="$(LDFLAGS) -L$(pd_src)/src -L$(pd_src)/bin -L$(pd_src)/obj" \
 	--with-pd-include="$(pd_src)/src" \
 	--with-pd-dir="$(MOOCOW_BUILD)" \
 	--disable-dependency-tracking
diff --git a/externals/moocow/flite/configure b/externals/moocow/flite/configure
index b9f8437782f8cdfc956df9ddb24ee0772d664ce2..a0624528ded479c6d3246cd861fb745a7fe6dd48 100755
--- a/externals/moocow/flite/configure
+++ b/externals/moocow/flite/configure
@@ -4509,10 +4509,10 @@ fi
 
 if test "$pdflite_have_lib" != "yes"; then
   for d in \
-    /usr/lib /usr/local/lib /sw/lib \
-    /usr/lib/flite /usr/local/lib/flite /sw/lib/flite \
-    /usr/flite/lib /usr/local/flite/lib /sw/flite/lib \
-    /usr/lib/flite/lib /usr/local/lib/flite/lib /sw/lib/flite/lib
+    /usr/lib /usr/local/lib \
+    /usr/lib/flite /usr/local/lib/flite \
+    /usr/flite/lib /usr/local/flite/lib \
+    /usr/lib/flite/lib /usr/local/lib/flite/lib
   do
     LDFLAGS="$LDFLAGS_SAVE -L$d"
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flite_init in -lflite" >&5
diff --git a/externals/moocow/flite/configure.ac b/externals/moocow/flite/configure.ac
index 97fd4a835b615b9e26161f0f27b6a0270cc3876c..98f8de1c893b2e12193cc5c5033fbed4d5381530 100644
--- a/externals/moocow/flite/configure.ac
+++ b/externals/moocow/flite/configure.ac
@@ -68,10 +68,10 @@ LDFLAGS_SAVE="$LDFLAGS"
 AC_CHECK_LIB(flite,[flite_init],[pdflite_have_lib=yes],[pdflite_have_lib=no],[-lm])
 if test "$pdflite_have_lib" != "yes"; then
   for d in \
-    /usr/lib /usr/local/lib /sw/lib \
-    /usr/lib/flite /usr/local/lib/flite /sw/lib/flite \
-    /usr/flite/lib /usr/local/flite/lib /sw/flite/lib \
-    /usr/lib/flite/lib /usr/local/lib/flite/lib /sw/lib/flite/lib
+    /usr/lib /usr/local/lib \
+    /usr/lib/flite /usr/local/lib/flite \
+    /usr/flite/lib /usr/local/flite/lib \
+    /usr/lib/flite/lib /usr/local/lib/flite/lib
   do
     LDFLAGS="$LDFLAGS_SAVE -L$d"
     AC_CHECK_LIB(flite,[flite_init],[pdflite_have_lib=yes],[pdflite_have_lib=no],[-lm])
diff --git a/externals/moonlib/Makefile b/externals/moonlib/Makefile
index b5ee48d9fc9af54db72d46c256357dc20214623c..79c9c70e1003bda37213710b11de97aa99b82270 100644
--- a/externals/moonlib/Makefile
+++ b/externals/moonlib/Makefile
@@ -115,10 +115,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/motex/Makefile b/externals/motex/Makefile
index c696e8e7fa3890ee1d2093aab44912fbc4473e35..711e7e64ff69a24127caf432d2109143a91606bc 100644
--- a/externals/motex/Makefile
+++ b/externals/motex/Makefile
@@ -101,9 +101,9 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/mrpeach/Makefile b/externals/mrpeach/Makefile
index 6633d08b3159f084a5621ae1143d1cc685205a36..027550c585c33921cd75669047ca3d184aa6b96d 100644
--- a/externals/mrpeach/Makefile
+++ b/externals/mrpeach/Makefile
@@ -139,11 +139,11 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/mrpeach/cmos/Makefile b/externals/mrpeach/cmos/Makefile
index 6a23280a4e64a4bf0bb052b55c2ddc9dd1ce8731..10b93de7ecef8ca9f1067540921687d195d84526 100644
--- a/externals/mrpeach/cmos/Makefile
+++ b/externals/mrpeach/cmos/Makefile
@@ -124,11 +124,11 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/mrpeach/net/Makefile b/externals/mrpeach/net/Makefile
index 2d13b7dec154807a4dc174d76f7f180c232af4c6..fafcbf8f5d615d59301e5d8bfe50428ddcd8ae9d 100644
--- a/externals/mrpeach/net/Makefile
+++ b/externals/mrpeach/net/Makefile
@@ -112,10 +112,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/mrpeach/osc/Makefile b/externals/mrpeach/osc/Makefile
index 36bdd9ede9dd2cea0b44b85871269fd60c6b5dc2..cf096240258490cb6d97ea3f8fa40c393f1a6d9c 100644
--- a/externals/mrpeach/osc/Makefile
+++ b/externals/mrpeach/osc/Makefile
@@ -118,8 +118,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     ALL_LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LIBS += -lc 
diff --git a/externals/nusmuk/lightboard/Makefile b/externals/nusmuk/lightboard/Makefile
index 3a747f4fd6c9cd76861b51d37222b4b0e76c8d7b..9869e2a0d2945c856cdac81bd1ab6d27a25c6ee7 100644
--- a/externals/nusmuk/lightboard/Makefile
+++ b/externals/nusmuk/lightboard/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/nusmuk/linear-cue-system/Makefile b/externals/nusmuk/linear-cue-system/Makefile
index e8a6bbd447589c47f9d7d169018aebc005c02ba2..548c6baed1618b38efa37dae580c8989b2873365 100644
--- a/externals/nusmuk/linear-cue-system/Makefile
+++ b/externals/nusmuk/linear-cue-system/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/nusmuk/nusmuk-audio/Makefile b/externals/nusmuk/nusmuk-audio/Makefile
index 884aa60c2fc270fad25d5db694fff898787e9c95..f00519a4289d6708f4c03ba89b15bb24376f4c79 100644
--- a/externals/nusmuk/nusmuk-audio/Makefile
+++ b/externals/nusmuk/nusmuk-audio/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/nusmuk/nusmuk-utils/Makefile b/externals/nusmuk/nusmuk-utils/Makefile
index aa5f728c70754373d648c5c1399e93c94ce316b9..4f8c6ca2badea2d6bc3907cba50a719991bd64c1 100644
--- a/externals/nusmuk/nusmuk-utils/Makefile
+++ b/externals/nusmuk/nusmuk-utils/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/nusmuk/puremapping/Makefile b/externals/nusmuk/puremapping/Makefile
index 7a5a33767ecb346fd65e13984e47bfe6126de78e..66023afeeda7f546b2610c505f2c156f23c2fd56 100644
--- a/externals/nusmuk/puremapping/Makefile
+++ b/externals/nusmuk/puremapping/Makefile
@@ -97,8 +97,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/pan/Makefile b/externals/pan/Makefile
index 76a995f5ca2baa1dd01ae0d1a5d8bd672444f7d2..60f52792f8ac3e738229ed80d0d0e819bf824495 100644
--- a/externals/pan/Makefile
+++ b/externals/pan/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/pddp/Makefile b/externals/pddp/Makefile
index 9f44e9f7851cb49a6bd3910e8e13fd47fe0314ba..5709fbaed740872d30d20d89437635dba33ce7a4 100644
--- a/externals/pddp/Makefile
+++ b/externals/pddp/Makefile
@@ -111,10 +111,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/pdogg/Makefile b/externals/pdogg/Makefile
index a9eb1f45a87099dccbc8e8e324cc08857e13dc4e..1be2ac87e3bbf5086e115a7e459c4bdd7eda6b66 100644
--- a/externals/pdogg/Makefile
+++ b/externals/pdogg/Makefile
@@ -118,11 +118,11 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/pdp/configure.ac b/externals/pdp/configure.ac
index 35bd1e9eb9152da4c171ce944301df7f1d649770..bb3825dcd460f5b3678bf9753a9b699bbf2e919e 100644
--- a/externals/pdp/configure.ac
+++ b/externals/pdp/configure.ac
@@ -139,9 +139,6 @@ dnl How to test if frameworks are present ????
 if test $ARCH == Darwin
 then
 	PD_EXECUTABLE=$prefix/bin/pd-l2ork
-	LIBS="$LIBS -L/sw/lib"
-	CPPFLAGS="$CPPFLAGS -I/sw/include"
-	PDP_EXTRA_CPPFLAGS="-I/sw/include"
 
 dnl if not darwin, assume target is linux
 else
diff --git a/externals/pdp/opengl/Makefile.config b/externals/pdp/opengl/Makefile.config
index 8968b3e39e346b9f8ca0288a29a2042e5a887cb9..e864cf49bf913ce00fc16fc4f3a7f3f975d3732a 100644
--- a/externals/pdp/opengl/Makefile.config
+++ b/externals/pdp/opengl/Makefile.config
@@ -22,9 +22,9 @@ ifeq ($(UNAME),Linux)
 endif
 ifeq ($(UNAME),Darwin)
   TARGET = darwin
-  CPPFLAGS += -I/sw/include
+  CPPFLAGS +=
   PD_EXECUTABLE=../../../pd/bin/pd-l2ork
-  LDFLAGS = -lgsl -lGL -lGLU -lglut -lX11 -L/sw/lib -L/usr/X11R6/lib
+  LDFLAGS = -lgsl -lGL -lGLU -lglut -lX11 -L/usr/X11R6/lib
 endif
 
 
diff --git a/externals/pdp_opencv/configure b/externals/pdp_opencv/configure
index f7eb8a6d221c282856620802a348d8ebf87d2448..80a92127d3bf23191b3ab2f508755cf0b620146d 100755
--- a/externals/pdp_opencv/configure
+++ b/externals/pdp_opencv/configure
@@ -2510,17 +2510,11 @@ PDP_DIR=/usr/local/pd/pdp
 SOURCES_OPT=
 
 echo $host
-# Check for DarwinPorts and/or Fink on Mac OS X/Darwin
+# Check for MacPorts on Mac OS X/Darwin
 case "$host" in
   *-darwin* | *-macos10*)
-     if test -d /sw ; then
-       # Fink
-       PATH="/sw/bin:/sw/sbin:$PATH"
-       CFLAGS="$CFLAGS -I/sw/include"
-       CPPFLAGS="$CPPFLAGS -I/sw/include"
-       LDFLAGS="$LDFLAGS -L/sw/lib"
-     elif test -d /opt/local ; then
-       # DarwinPorts
+     if test -d /opt/local ; then
+       # MacPorts
        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
        CFLAGS="$CFLAGS -I/opt/local/include"
        CPPFLAGS="$CPPFLAGS -I/opt/local/include"
diff --git a/externals/pdp_opencv/configure.ac b/externals/pdp_opencv/configure.ac
index 14da37691f2eb4cf6a700e8bbd3c6f3b2aa11b26..d3f3a1af017bbefd12dbe2529fad4cf7eb31c6ad 100755
--- a/externals/pdp_opencv/configure.ac
+++ b/externals/pdp_opencv/configure.ac
@@ -14,17 +14,11 @@ PDP_DIR=/usr/local/pd/pdp
 SOURCES_OPT=
 
 echo $host
-# Check for DarwinPorts and/or Fink on Mac OS X/Darwin
+# Check for MacPorts on Mac OS X/Darwin
 case "$host" in
   *-darwin* | *-macos10*)
-     if test -d /sw ; then
-       # Fink
-       PATH="/sw/bin:/sw/sbin:$PATH"
-       CFLAGS="$CFLAGS -I/sw/include"
-       CPPFLAGS="$CPPFLAGS -I/sw/include"
-       LDFLAGS="$LDFLAGS -L/sw/lib"
-     elif test -d /opt/local ; then
-       # DarwinPorts
+     if test -d /opt/local ; then
+       # MacPorts
        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
        CFLAGS="$CFLAGS -I/opt/local/include"
        CPPFLAGS="$CPPFLAGS -I/opt/local/include"
diff --git a/externals/pidip/Makefile.in b/externals/pidip/Makefile.in
index 157e11217cf5c17579baa6f50c2e9482664d931d..bd387395967a446efca642b62aac929ba4d2054e 100755
--- a/externals/pidip/Makefile.in
+++ b/externals/pidip/Makefile.in
@@ -44,7 +44,7 @@ pdp_pidip_all:
 
 pidip.pd_darwin: pdp_pidip_all
 	rm -f pidip.pd_darwin
-	g++ -bundle -undefined dynamic_lookup -headerpad_max_install_names -o pidip.pd_darwin modules/*.o system/*.o -L/sw/lib $(THEORA_LIBS) $(DC1394_LIBS) $(FREENECT_LIBS) $(OPENCV_LIBS) $(PDP_PIDIP_LIBS) $(IMLIB_LIBS) $(ARTKP_LIBS)
+	g++ -bundle -undefined dynamic_lookup -headerpad_max_install_names -o pidip.pd_darwin modules/*.o system/*.o $(THEORA_LIBS) $(DC1394_LIBS) $(FREENECT_LIBS) $(OPENCV_LIBS) $(PDP_PIDIP_LIBS) $(IMLIB_LIBS) $(ARTKP_LIBS)
 	strip -x pidip.pd_darwin
 
 pidip.pd_linux: pdp_pidip_all
diff --git a/externals/pidip/configure.ac b/externals/pidip/configure.ac
index 7f4d105c2d169c4936b3670a61d71cd55f2249a4..09f749860d19400c9297dad5597239f742c7d333 100755
--- a/externals/pidip/configure.ac
+++ b/externals/pidip/configure.ac
@@ -26,18 +26,12 @@ ARTKP_CPPFLAGS=
 ARTKP_LIBS=
 
 echo $host
-# Check for DarwinPorts and/or Fink on Mac OS X/Darwin
+# Check for MacPorts on Mac OS X/Darwin
 case "$host" in
   *-darwin* | *-macos10*)
      PDP_CAPTURE_OBJECT="pdp_ieee1394.o"
-     if test -d /sw ; then
-       # Fink
-       PATH="/sw/bin:/sw/sbin:$PATH"
-       CFLAGS="$CFLAGS -I/sw/include"
-       CPPFLAGS="$CPPFLAGS -I/sw/include"
-       LDFLAGS="$LDFLAGS -L/sw/lib"
-     elif test -d /opt/local ; then
-       # DarwinPorts
+     if test -d /opt/local ; then
+       # MacPorts
        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
        CFLAGS="$CFLAGS -I/opt/local/include"
        CPPFLAGS="$CPPFLAGS -I/opt/local/include"
diff --git a/externals/pidip/modules/pdp_qtext.c b/externals/pidip/modules/pdp_qtext.c
index da08ba70e8ee5efc2c042b7d274d14554aaa2a61..cc200c0fbdd414fd672b6a5273e1c8ed9505d94f 100755
--- a/externals/pidip/modules/pdp_qtext.c
+++ b/externals/pidip/modules/pdp_qtext.c
@@ -1118,8 +1118,6 @@ void pdp_qtext_setup(void)
 #ifdef __APPLE__
     imlib_add_path_to_font_path("/System/Library/Fonts");
     imlib_add_path_to_font_path("/Library/Fonts");
-    imlib_add_path_to_font_path("/sw/share/imlib2/data/fonts");
-    imlib_add_path_to_font_path("/sw/lib/X11/fonts/msttf");
 #else
     imlib_add_path_to_font_path("/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType");
 #endif
diff --git a/externals/pidip/modules/pdp_text.c b/externals/pidip/modules/pdp_text.c
index d96d9b41b712a18fac82d2ee5ca4e16044f03f05..74cb0d6a5eb355980626c37387c061c5d1d1fd52 100755
--- a/externals/pidip/modules/pdp_text.c
+++ b/externals/pidip/modules/pdp_text.c
@@ -682,8 +682,6 @@ void pdp_text_setup(void)
 #ifdef __APPLE__
     imlib_add_path_to_font_path("/System/Library/Fonts");
     imlib_add_path_to_font_path("/Library/Fonts");
-    imlib_add_path_to_font_path("/sw/share/imlib2/data/fonts");
-    imlib_add_path_to_font_path("/sw/lib/X11/fonts/msttf");
 #else
     imlib_add_path_to_font_path("/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType");
 #endif
diff --git a/externals/pix_opencv/configure b/externals/pix_opencv/configure
index e2f94ac0fa75ef23bc3d75d6ef3b10fff84e0c47..4b4eaba0e38051627e2c140d447fddb430ded342 100755
--- a/externals/pix_opencv/configure
+++ b/externals/pix_opencv/configure
@@ -2262,17 +2262,11 @@ GEM_DIR=/usr/local/pd/gem
 SOURCES_OPT=
 
 echo $host
-# Check for DarwinPorts and/or Fink on Mac OS X/Darwin
+# Check for MacPorts on Mac OS X/Darwin
 case "$host" in
   *-darwin* | *-macos10*)
-     if test -d /sw ; then
-       # Fink
-       PATH="/sw/bin:/sw/sbin:$PATH"
-       CFLAGS="$CFLAGS -I/sw/include"
-       CPPFLAGS="$CPPFLAGS -I/sw/include"
-       LDFLAGS="$LDFLAGS -L/sw/lib"
-     elif test -d /opt/local ; then
-       # DarwinPorts
+     if test -d /opt/local ; then
+       # MacPorts
        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
        CFLAGS="$CFLAGS -I/opt/local/include"
        CPPFLAGS="$CPPFLAGS -I/opt/local/include"
diff --git a/externals/pix_opencv/configure.ac b/externals/pix_opencv/configure.ac
index 1ab17e4c1f5dcaed484e5d4538ece92890f74855..f3da50b2d5b2b7df1b88c548b5a4fd21e468bd65 100755
--- a/externals/pix_opencv/configure.ac
+++ b/externals/pix_opencv/configure.ac
@@ -13,17 +13,11 @@ GEM_DIR=/usr/local/pd/gem
 SOURCES_OPT=
 
 echo $host
-# Check for DarwinPorts and/or Fink on Mac OS X/Darwin
+# Check for MacPorts on Mac OS X/Darwin
 case "$host" in
   *-darwin* | *-macos10*)
-     if test -d /sw ; then
-       # Fink
-       PATH="/sw/bin:/sw/sbin:$PATH"
-       CFLAGS="$CFLAGS -I/sw/include"
-       CPPFLAGS="$CPPFLAGS -I/sw/include"
-       LDFLAGS="$LDFLAGS -L/sw/lib"
-     elif test -d /opt/local ; then
-       # DarwinPorts
+     if test -d /opt/local ; then
+       # MacPorts
        PATH="/opt/local/bin:/opt/local/sbin:$PATH"
        CFLAGS="$CFLAGS -I/opt/local/include"
        CPPFLAGS="$CPPFLAGS -I/opt/local/include"
diff --git a/externals/plugin~/Makefile b/externals/plugin~/Makefile
index b27605c4b904a0dd8d3a58970017515faf265dcf..b8c5bd9e4d31d9bf1c02d38f828c859c50f65716 100644
--- a/externals/plugin~/Makefile
+++ b/externals/plugin~/Makefile
@@ -103,8 +103,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/plugin~/jsearch.c b/externals/plugin~/jsearch.c
index cc46c8bb5e4ca105ead881c132070deab9acb134..82a840c66db46ba5fbbfa08a877deecdfce8cf17 100644
--- a/externals/plugin~/jsearch.c
+++ b/externals/plugin~/jsearch.c
@@ -104,11 +104,7 @@ LADSPAPluginSearch(LADSPAPluginSearchCallbackFunction fCallbackFunction,
   pcLADSPAPath = getenv("LADSPA_PATH");
   if (!pcLADSPAPath) {
     //fprintf(stderr, "Warning: no LADSPA_PATH, assuming /usr/lib/ladspa:/usr/local/lib/ladspa\n");
-#ifdef __APPLE__
-    pcLADSPAPath = "/sw/lib/ladspa:/usr/local/lib/ladspa";
-#else
     pcLADSPAPath = "/usr/lib/ladspa:/usr/local/lib/ladspa";
-#endif
   }
   
   pcStart = pcLADSPAPath;
diff --git a/externals/pmpd/Makefile b/externals/pmpd/Makefile
index a2eefeb957613c2e6edacdf3310b6271a2897f85..c27189ee0771be22327e4741c0690dd30f3e7645 100644
--- a/externals/pmpd/Makefile
+++ b/externals/pmpd/Makefile
@@ -120,11 +120,11 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/postlude/pluginhost~/Makefile b/externals/postlude/pluginhost~/Makefile
index 0d9bcfecdef210b677969ee9bfbfcbe99c22963b..e8a482ea05eb601f1007a7001c6dc2935dc842d5 100644
--- a/externals/postlude/pluginhost~/Makefile
+++ b/externals/postlude/pluginhost~/Makefile
@@ -125,11 +125,11 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/postlude/pluginhost~/Makefile~ b/externals/postlude/pluginhost~/Makefile~
deleted file mode 100644
index dc61d3c1316fad465040e4eee6af88c71688e976..0000000000000000000000000000000000000000
--- a/externals/postlude/pluginhost~/Makefile~
+++ /dev/null
@@ -1,458 +0,0 @@
-## Pd library template version 1.0.14
-# For instructions on how to use this template, see:
-#  http://puredata.info/docs/developer/MakefileTemplate
-#
-
-# the name of this library
-# must not contain any spaces or weird characters (as it's used for
-# filenames,...)
-LIBRARY_NAME = pluginhost~
-
-# add your .c source files, one object per file, to the SOURCES
-# variable, help files will be included automatically, and for GUI
-# objects, the matching .tcl file too
-SOURCES = pluginhost~.c
-
-# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
-# be included automatically
-PDOBJECTS = 
-
-# example patches and related files, in the 'examples' subfolder
-EXAMPLES = 
-
-# manuals and related files, in the 'manual' subfolder
-MANUAL = 
-
-# if you want to include any other files in the source and binary tarballs,
-# list them here.  This can be anything from header files, test patches,
-# documentation, etc.  README.txt and LICENSE.txt are required and therefore
-# automatically included
-EXTRA_DIST = handlers_osc.h handlers_pd.h jutils.h ph_common.h
-
-# unit tests and related files here, in the 'unittests' subfolder
-UNITTESTS = 
-
-
-# Additional source files
-SHARED_SOURCE = handlers_osc.c jload.c ph_common.c handlers_pd.c jsearch.c
-SHARED_LIB = lib$(LIBRARY_NAME).$(SHARED_EXTENSION)
-
-#------------------------------------------------------------------------------#
-#
-# things you might need to edit if you are using other C libraries
-#
-#------------------------------------------------------------------------------#
-
-ALL_CFLAGS = -I"$(PD_INCLUDE)" -DHAVE_SYS_CLOSE_AUDIO -DHAVE_SYS_CLOSE_MIDI -g -O0
-ALL_LDFLAGS =  
-SHARED_LDFLAGS =
-ALL_LIBS = 
-
-
-#------------------------------------------------------------------------------#
-#
-# you shouldn't need to edit anything below here, if we did it right :)
-#
-#------------------------------------------------------------------------------#
-
-# these can be set from outside without (usually) breaking the build
-CFLAGS = -Wall -W -g
-LDFLAGS =
-LIBS =
-
-# get library version from meta file
-LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd)
-
-ALL_CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"'
-
-PD_INCLUDE = $(PD_PATH)/include/pdl2ork
-# where to install the library, overridden below depending on platform
-prefix = /usr/local
-libdir = $(prefix)/lib
-pkglibdir = $(libdir)/pd-externals
-objectsdir = $(pkglibdir)
-
-INSTALL = install
-INSTALL_PROGRAM = $(INSTALL) -p -m 644
-INSTALL_DATA = $(INSTALL) -p -m 644
-INSTALL_DIR     = $(INSTALL) -p -m 755 -d
-
-ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \
-	         $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows)
-
-DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
-ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
-
-UNAME := $(shell uname -s)
-ifeq ($(UNAME),Darwin)
-  CPU := $(shell uname -p)
-  ifeq ($(CPU),arm) # iPhone/iPod Touch
-    SOURCES += $(SOURCES_iphoneos)
-    EXTENSION = pd_darwin
-    SHARED_EXTENSION = dylib
-    OS = iphoneos
-    PD_PATH = /Applications/Pd-extended.app/Contents/Resources
-    IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
-    CC=$(IPHONE_BASE)/gcc
-    CPP=$(IPHONE_BASE)/cpp
-    CXX=$(IPHONE_BASE)/g++
-    ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk
-    IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6
-    OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer
-    ALL_CFLAGS := $(IPHONE_CFLAGS) $(ALL_CFLAGS)
-    ALL_LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT)
-    SHARED_LDFLAGS += -arch armv6 -dynamiclib -undefined dynamic_lookup $(ISYSROOT)
-    ALL_LIBS += -lc $(LIBS_iphoneos)
-    STRIP = strip -x
-    DISTBINDIR=$(DISTDIR)-$(OS)
-  else # Mac OS X
-    SOURCES += $(SOURCES_macosx)
-    EXTENSION = pd_darwin
-    SHARED_EXTENSION = dylib
-    OS = macosx
-    PD_PATH = /Applications/Pd-extended.app/Contents/Resources
-    OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
-# build universal 32-bit on 10.4 and 32/64 on newer
-    ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8)
-      FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4
-    else
-      SOURCES += $(SOURCES_iphoneos)
-# Starting with Xcode 4.0, the PowerPC compiler is not installed by default
-      ifeq ($(wildcard /usr/llvm-gcc-4.2/libexec/gcc/powerpc*), )
-        FAT_FLAGS = -arch i386 -arch x86_64 -mmacosx-version-min=10.5
-      else
-        FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
-      endif
-    endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    # if the 'pd' binary exists, check the linking against it to aid with stripping
-    BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
-    SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
-	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
-    ALL_LIBS += -lc $(LIBS_macosx)
-    STRIP = strip -x
-    DISTBINDIR=$(DISTDIR)-$(OS)
-# install into ~/Library/Pd on Mac OS X since /usr/local isn't used much
-    pkglibdir=$(HOME)/Library/Pd
-  endif
-endif
-# Tho Android uses Linux, we use this fake uname to provide an easy way to
-# setup all this things needed to cross-compile for Android using the NDK
-ifeq ($(UNAME),ANDROID)
-  CPU := arm
-  SOURCES += $(SOURCES_android)
-  EXTENSION = so
-  SHARED_EXTENSION = so
-  OS = android
-  PD_PATH = /usr
-  NDK_BASE := /usr/local/android-ndk
-  NDK_PLATFORM_LEVEL ?= 5
-  NDK_ABI=arm
-  NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_LEVEL)/arch-$(NDK_ABI)
-  NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
-  NDK_COMPILER_VERSION=4.6
-  NDK_TOOLCHAIN=$(wildcard \
-	$(NDK_BASE)/toolchains/$(NDK_ABI)*-$(NDK_COMPILER_VERSION)/prebuilt/$(NDK_UNAME)-x86)
-  CC := $(wildcard $(NDK_TOOLCHAIN)/bin/*-linux-android*-gcc) --sysroot=$(NDK_SYSROOT)
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  CFLAGS += 
-  LDFLAGS += -rdynamic -shared
-  SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
-  LIBS += -lc $(LIBS_android)
-  STRIP := $(wildcard $(NDK_TOOLCHAIN)/bin/$(NDK_ABI)-linux-android*-strip) \
-	--strip-unneeded -R .note -R .comment
-  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
-endif
-ifeq ($(UNAME),Linux)
-  CPU := $(shell uname -m)
-  SOURCES += $(SOURCES_linux)
-  EXTENSION = pd_linux
-  SHARED_EXTENSION = so
-  OS = linux
-  PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  ALL_CFLAGS += -fPIC
-  ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
-  SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
-  ALL_LIBS += -lc $(LIBS_linux)
-  STRIP = strip --strip-unneeded -R .note -R .comment
-  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
-endif
-ifeq ($(UNAME),GNU)
-  # GNU/Hurd, should work like GNU/Linux for basically all externals
-  CPU := $(shell uname -m)
-  SOURCES += $(SOURCES_linux)
-  EXTENSION = pd_linux
-  SHARED_EXTENSION = so
-  OS = linux
-  PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  ALL_CFLAGS += -fPIC
-  ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
-  SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
-  ALL_LIBS += -lc $(LIBS_linux)
-  STRIP = strip --strip-unneeded -R .note -R .comment
-  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
-endif
-ifeq ($(UNAME),GNU/kFreeBSD)
-  # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals
-  CPU := $(shell uname -m)
-  SOURCES += $(SOURCES_linux)
-  EXTENSION = pd_linux
-  SHARED_EXTENSION = so
-  OS = linux
-  PD_PATH = /usr
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  ALL_CFLAGS += -fPIC
-  ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
-  SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
-  ALL_LIBS += -lc $(LIBS_linux)
-  STRIP = strip --strip-unneeded -R .note -R .comment
-  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
-endif
-ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
-  CPU := $(shell uname -m)
-  SOURCES += $(SOURCES_cygwin)
-  EXTENSION = dll
-  SHARED_EXTENSION = dll
-  OS = cygwin
-  PD_PATH = $(shell cygpath $$PROGRAMFILES)/pd
-  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  ALL_CFLAGS += 
-  ALL_LDFLAGS += -rdynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
-  SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
-  ALL_LIBS += -lc -lpd $(LIBS_cygwin)
-  STRIP = strip --strip-unneeded -R .note -R .comment
-  DISTBINDIR=$(DISTDIR)-$(OS)
-endif
-ifeq (MINGW,$(findstring MINGW,$(UNAME)))
-  CPU := $(shell uname -m)
-  SOURCES += $(SOURCES_windows)
-  EXTENSION = dll
-  SHARED_EXTENSION = dll
-  OS = windows
-  PD_PATH = $(shell cd "$$PROGRAMFILES/pd" && pwd)
-  # MinGW doesn't seem to include cc so force gcc
-  CC=gcc
-  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer
-  ALL_CFLAGS += -mms-bitfields
-  ALL_LDFLAGS += -s -shared -Wl,--enable-auto-import
-  SHARED_LDFLAGS += -shared
-  ALL_LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" \
-	-lpd -lwsock32 -lkernel32 -luser32 -lgdi32 -liberty $(LIBS_windows)
-  STRIP = strip --strip-unneeded -R .note -R .comment
-  DISTBINDIR=$(DISTDIR)-$(OS)
-endif
-
-# in case somebody manually set the HELPPATCHES above
-HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd)
-
-ALL_CFLAGS := $(ALL_CFLAGS) $(CFLAGS) $(OPT_CFLAGS)
-ALL_LDFLAGS := $(LDFLAGS) $(ALL_LDFLAGS)
-ALL_LIBS := $(LIBS) $(ALL_LIBS)
-
-SHARED_SOURCE ?= $(wildcard lib$(LIBRARY_NAME).c)
-SHARED_HEADER ?= $(shell test ! -e $(LIBRARY_NAME).h || echo $(LIBRARY_NAME).h)
-SHARED_LIB ?= $(SHARED_SOURCE:.c=.$(SHARED_EXTENSION))
-SHARED_TCL_LIB = $(wildcard lib$(LIBRARY_NAME).tcl)
-
-.PHONY = install libdir_install single_install install-doc install-examples install-manual install-unittests clean distclean dist etags $(LIBRARY_NAME)
-
-all: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB)
-
-%.o: %.c
-	$(CC) $(ALL_CFLAGS) -o "$*.o" -c "$*.c"
-
-%.$(EXTENSION): %.o $(SHARED_LIB)
-	$(CC) $(ALL_LDFLAGS) -o "$*.$(EXTENSION)" "$*.o"  $(ALL_LIBS) $(SHARED_LIB)
-	chmod a-x "$*.$(EXTENSION)"
-
-# this links everything into a single binary file
-$(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o lib$(LIBRARY_NAME).o
-	$(CC) $(ALL_LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) \
-		$(LIBRARY_NAME).o lib$(LIBRARY_NAME).o $(ALL_LIBS)
-	chmod a-x $(LIBRARY_NAME).$(EXTENSION)
-
-$(SHARED_LIB): $(SHARED_SOURCE:.c=.o)
-	$(CC) $(SHARED_LDFLAGS) -o $(SHARED_LIB) $(SHARED_SOURCE:.c=.o) $(ALL_LIBS)
-
-install: libdir_install
-
-# The meta and help files are explicitly installed to make sure they are
-# actually there.  Those files are not optional, then need to be there.
-libdir_install: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB) install-doc install-examples install-manual install-unittests
-	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	$(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \
-		$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	test -z "$(strip $(SOURCES))" || (\
-		$(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \
-		$(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION))))
-	test -z "$(strip $(SHARED_LIB))" || \
-		$(INSTALL_DATA) $(SHARED_LIB) \
-			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	test -z "$(strip $(wildcard $(SOURCES:.c=.tcl)))" || \
-		$(INSTALL_DATA) $(wildcard $(SOURCES:.c=.tcl)) \
-			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	test -z "$(strip $(PDOBJECTS))" || \
-		$(INSTALL_DATA) $(PDOBJECTS) \
-			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	test -z "$(strip $(SHARED_TCL_LIB))" || \
-		$(INSTALL_DATA) $(SHARED_TCL_LIB) \
-			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-
-# install library linked as single binary
-single_install: $(LIBRARY_NAME) install-doc install-examples install-manual install-unittests
-	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	$(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	$(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION)
-
-install-doc:
-	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \
-		$(INSTALL_DATA) $(HELPPATCHES) \
-			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
-	$(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt
-	$(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt
-
-install-examples:
-	test -z "$(strip $(EXAMPLES))" || \
-		$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \
-		for file in $(EXAMPLES); do \
-			$(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \
-		done
-
-install-manual:
-	test -z "$(strip $(MANUAL))" || \
-		$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \
-		for file in $(MANUAL); do \
-			$(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \
-		done
-
-install-unittests:
-	test -z "$(strip $(UNITTESTS))" || \
-		$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/unittests && \
-		for file in $(UNITTESTS); do \
-			$(INSTALL_DATA) unittests/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/unittests; \
-		done
-
-clean:
-	-rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) $(SHARED_SOURCE:.c=.o)
-	-rm -f -- $(SOURCES:.c=.$(EXTENSION))
-	-rm -f -- $(LIBRARY_NAME).o
-	-rm -f -- $(LIBRARY_NAME).$(EXTENSION)
-	-rm -f -- $(SHARED_LIB)
-
-distclean: clean
-	-rm -f -- $(DISTBINDIR).tar.gz
-	-rm -rf -- $(DISTBINDIR)
-	-rm -f -- $(DISTDIR).tar.gz
-	-rm -rf -- $(DISTDIR)
-	-rm -f -- $(ORIGDIR).tar.gz
-	-rm -rf -- $(ORIGDIR)
-
-
-$(DISTBINDIR):
-	$(INSTALL_DIR) $(DISTBINDIR)
-
-libdir: all $(DISTBINDIR)
-	$(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd  $(DISTBINDIR)
-	$(INSTALL_DATA) $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER) $(DISTBINDIR)
-	$(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR)
-	test -z "$(strip $(EXTRA_DIST))" || \
-		$(INSTALL_DATA) $(EXTRA_DIST)    $(DISTBINDIR)
-#	tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR)
-
-$(DISTDIR):
-	$(INSTALL_DIR) $(DISTDIR)
-
-$(ORIGDIR):
-	$(INSTALL_DIR) $(ORIGDIR)
-
-dist: $(DISTDIR)
-	$(INSTALL_DATA) Makefile  $(DISTDIR)
-	$(INSTALL_DATA) README.txt $(DISTDIR)
-	$(INSTALL_DATA) LICENSE.txt $(DISTDIR)
-	$(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd  $(DISTDIR)
-	test -z "$(strip $(ALLSOURCES))" || \
-		$(INSTALL_DATA) $(ALLSOURCES)  $(DISTDIR)
-	test -z "$(strip $(wildcard $(ALLSOURCES:.c=.tcl)))" || \
-		$(INSTALL_DATA) $(wildcard $(ALLSOURCES:.c=.tcl))  $(DISTDIR)
-	test -z "$(strip $(wildcard $(LIBRARY_NAME).c))" || \
-		$(INSTALL_DATA) $(LIBRARY_NAME).c  $(DISTDIR)
-	test -z "$(strip $(SHARED_HEADER))" || \
-		$(INSTALL_DATA) $(SHARED_HEADER)  $(DISTDIR)
-	test -z "$(strip $(SHARED_SOURCE))" || \
-		$(INSTALL_DATA) $(SHARED_SOURCE)  $(DISTDIR)
-	test -z "$(strip $(SHARED_TCL_LIB))" || \
-		$(INSTALL_DATA) $(SHARED_TCL_LIB)  $(DISTDIR)
-	test -z "$(strip $(PDOBJECTS))" || \
-		$(INSTALL_DATA) $(PDOBJECTS)  $(DISTDIR)
-	test -z "$(strip $(HELPPATCHES))" || \
-		$(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR)
-	test -z "$(strip $(EXTRA_DIST))" || \
-		$(INSTALL_DATA) $(EXTRA_DIST)    $(DISTDIR)
-	test -z "$(strip $(EXAMPLES))" || \
-		$(INSTALL_DIR) $(DISTDIR)/examples && \
-		for file in $(EXAMPLES); do \
-			$(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \
-		done
-	test -z "$(strip $(MANUAL))" || \
-		$(INSTALL_DIR) $(DISTDIR)/manual && \
-		for file in $(MANUAL); do \
-			$(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \
-		done
-	test -z "$(strip $(UNITTESTS))" || \
-		$(INSTALL_DIR) $(DISTDIR)/unittests && \
-		for file in $(UNITTESTS); do \
-			$(INSTALL_DATA) unittests/$$file $(DISTDIR)/unittests; \
-		done
-	tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR)
-
-# make a Debian source package
-dpkg-source:
-	debclean
-	make distclean dist
-	mv $(DISTDIR) $(ORIGDIR)
-	tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR)
-	rm -f -- $(DISTDIR).tar.gz
-	rm -rf -- $(DISTDIR) $(ORIGDIR)
-	cd .. && dpkg-source -b $(LIBRARY_NAME)
-
-etags: TAGS
-
-TAGS: $(wildcard $(PD_INCLUDE)/*.h) $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER)
-	etags $(wildcard $(PD_INCLUDE)/*.h)
-	etags -a *.h $(SOURCES) $(SHARED_SOURCE) $(SHARED_HEADER)
-	etags -a --language=none --regex="/proc[ \t]+\([^ \t]+\)/\1/" *.tcl
-
-showsetup:
-	@echo "CC: $(CC)"
-	@echo "CFLAGS: $(CFLAGS)"
-	@echo "LDFLAGS: $(LDFLAGS)"
-	@echo "LIBS: $(LIBS)"
-	@echo "ALL_CFLAGS: $(ALL_CFLAGS)"
-	@echo "ALL_LDFLAGS: $(ALL_LDFLAGS)"
-	@echo "ALL_LIBS: $(ALL_LIBS)"
-	@echo "PD_INCLUDE: $(PD_INCLUDE)"
-	@echo "PD_PATH: $(PD_PATH)"
-	@echo "objectsdir: $(objectsdir)"
-	@echo "LIBRARY_NAME: $(LIBRARY_NAME)"
-	@echo "LIBRARY_VERSION: $(LIBRARY_VERSION)"
-	@echo "SOURCES: $(SOURCES)"
-	@echo "SHARED_HEADER: $(SHARED_HEADER)"
-	@echo "SHARED_SOURCE: $(SHARED_SOURCE)"
-	@echo "SHARED_LIB: $(SHARED_LIB)"
-	@echo "SHARED_TCL_LIB: $(SHARED_TCL_LIB)"
-	@echo "PDOBJECTS: $(PDOBJECTS)"
-	@echo "ALLSOURCES: $(ALLSOURCES)"
-	@echo "ALLSOURCES TCL: $(wildcard $(ALLSOURCES:.c=.tcl))"
-	@echo "UNAME: $(UNAME)"
-	@echo "CPU: $(CPU)"
-	@echo "pkglibdir: $(pkglibdir)"
-	@echo "DISTDIR: $(DISTDIR)"
-	@echo "ORIGDIR: $(ORIGDIR)"
-	@echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)"
-	@echo "NDK_BASE: $(NDK_BASE)"
-	@echo "NDK_SYSROOT: $(NDK_SYSROOT)"
diff --git a/externals/postlude/psql/Makefile b/externals/postlude/psql/Makefile
index 76aff3795de2b82ac36186bc76a4146471fbedd8..9be867ae86d05ef0d1c0ae923dcdd1085ca4104f 100644
--- a/externals/postlude/psql/Makefile
+++ b/externals/postlude/psql/Makefile
@@ -35,7 +35,7 @@ UNITTESTS =
 #
 #------------------------------------------------------------------------------#
 
-ALL_CFLAGS = -I"$(PD_INCLUDE)" -I/usr/include/postgresql -I/sw/include/postgresql
+ALL_CFLAGS = -I"$(PD_INCLUDE)" -I/usr/include/postgresql
 ALL_LDFLAGS =  
 SHARED_LDFLAGS =
 ALL_LIBS = -lpq
@@ -113,11 +113,11 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/sigpack/Makefile b/externals/sigpack/Makefile
index 961bafe8b67a3a4e89d97bc65a01f8df81f8462a..820f5808e92c213e87775c5d89bb129b2625085e 100644
--- a/externals/sigpack/Makefile
+++ b/externals/sigpack/Makefile
@@ -111,10 +111,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/smlib/Makefile b/externals/smlib/Makefile
index a80ecdf8e7e8137e8457fafe8f5e05f05b01bfbe..0a144146047ac3aae68a315c72b613fd7884d827 100644
--- a/externals/smlib/Makefile
+++ b/externals/smlib/Makefile
@@ -101,8 +101,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/tb/sndfiler/src/Makefile.pd_main b/externals/tb/sndfiler/src/Makefile.pd_main
index 29bde8074157e5c394b50496b8eb79b1803357b3..e85e252a41f0765c5bace1eba1b3b0e2837d8aae 100755
--- a/externals/tb/sndfiler/src/Makefile.pd_main
+++ b/externals/tb/sndfiler/src/Makefile.pd_main
@@ -100,7 +100,7 @@ pd_darwin: $(NAME).pd_darwin
 CC_DARWIN = -pthread
 LD_DARWIN = -bundle -undefined suppress -flat_namespace \
             -bundle_loader $(PD_PATH)/bin/pd --export-dynamic \
-            -L/sw/lib -L/opt/local/lib -lsndfile -lvorbisfile \
+            -lsndfile -lvorbisfile \
             $(THREADLIB_PATH)/threadlib.pd_darwin
 
 .c.pd_darwin:
diff --git a/externals/template/Makefile b/externals/template/Makefile
index 85c6d2397f60c279647b89fca9fab097c78a6ecf..3d7330da74b28fe569bdaf56541ff542c7cbe5b2 100644
--- a/externals/template/Makefile
+++ b/externals/template/Makefile
@@ -98,8 +98,8 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    CFLAGS += $(FAT_FLAGS) -fPIC
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/tof/src/Makefile b/externals/tof/src/Makefile
index 7b329cc822e434eb89eeb7413622a956baad38a7..a47e177f40f9d03471e4ba91cca97ad953412e4b 100644
--- a/externals/tof/src/Makefile
+++ b/externals/tof/src/Makefile
@@ -90,11 +90,11 @@ ifeq ($(OS_NAME),darwin)
   FAT_FLAGS = -arch ppc -arch ppc64 -arch i386
 # 10.5 Leopard
 #  FAT_FLAGS = -arch ppc -arch ppc7400 -arch ppc64 -arch i386 -arch x86_64
-  CFLAGS += -I/sw/include -DMACOSX -DUNIX -Dunix -DDL_OPEN -arch $(ARCH)
+  CFLAGS += -DMACOSX -DUNIX -Dunix -DDL_OPEN -arch $(ARCH)
   LDFLAGS += -bundle -bundle_loader $(PD_BIN)/bin/pd -undefined dynamic_lookup \
 		-weak_framework Carbon -arch $(ARCH)
   LIBS += -lc 
-  DYLIB_LDFLAGS = -dynamiclib -undefined dynamic_lookup -read_only_relocs warning -L/sw/lib
+  DYLIB_LDFLAGS = -dynamiclib -undefined dynamic_lookup -read_only_relocs warning
   STRIP = strip -x
 endif
 ifeq ($(OS_NAME),linux)
diff --git a/externals/unauthorized/Makefile b/externals/unauthorized/Makefile
index 9b34891d1a9403d60dbf2b784895bdacf24f0fcc..6203ce2203b63e10e50f542ab725221931188596 100644
--- a/externals/unauthorized/Makefile
+++ b/externals/unauthorized/Makefile
@@ -118,10 +118,10 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
-    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup -L/sw/lib
+    ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/vbap/Makefile b/externals/vbap/Makefile
index 35975fb5b42e8ae0c88f0d396b2ea6efb40041f4..60d72110d1ab5ee148a5e009b2bc93cb65c3466d 100644
--- a/externals/vbap/Makefile
+++ b/externals/vbap/Makefile
@@ -120,11 +120,11 @@ ifeq ($(UNAME),Darwin)
         FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       endif
     endif
-    ALL_CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    ALL_CFLAGS += $(FAT_FLAGS) -fPIC
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
     ALL_LDFLAGS += $(FAT_FLAGS) -headerpad_max_install_names -bundle $(BUNDLE_LOADER) \
-	-undefined dynamic_lookup -L/sw/lib
+	-undefined dynamic_lookup
     SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
 	-install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
     ALL_LIBS += -lc $(LIBS_macosx)
diff --git a/externals/windowing/Makefile b/externals/windowing/Makefile
index 8d40cb46d1bcdd49d4abefa931ce2f4967721183..a5e56ba94a2468a7e4673044ecb67eec28fbed28 100644
--- a/externals/windowing/Makefile
+++ b/externals/windowing/Makefile
@@ -98,9 +98,9 @@ ifeq ($(UNAME),Darwin)
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=$(macos_target)
       SOURCES += $(SOURCES_iphoneos)
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \
+    CFLAGS += $(FAT_FLAGS) -fPIC \
       -I/Applications/Pd-extended.app/Contents/Resources/include
-    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
+    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
     LIBS += -lc 
diff --git a/externals/zexy/pd-lib-builder/Makefile.pdlibbuilder b/externals/zexy/pd-lib-builder/Makefile.pdlibbuilder
index 7d6c11cdb2703f76838f7e5fe96c92d8d07d3222..9ee96c09b3b35adec8dbe2ef55a483f51bd0918a 100644
--- a/externals/zexy/pd-lib-builder/Makefile.pdlibbuilder
+++ b/externals/zexy/pd-lib-builder/Makefile.pdlibbuilder
@@ -580,7 +580,7 @@ ifeq ($(system), Darwin)
   pdincludepath := $(firstword $(wildcard \
     /Applications/Pd*.app/Contents/Resources/src))
   extension = pd_darwin
-  cpp.flags := -DUNIX -DMACOSX -I /sw/include
+  cpp.flags := -DUNIX -DMACOSX
   c.flags :=
   c.ldflags := -undefined suppress -flat_namespace -bundle
   c.ldlibs := -lc
diff --git a/l2ork_addons/tar_em_up.sh b/l2ork_addons/tar_em_up.sh
index 2d7412e6867ffe32d3fecb3a61cd0acbe74a30ad..3f5a72871f33e047faf3dde3167cc2ed6d424a65 100755
--- a/l2ork_addons/tar_em_up.sh
+++ b/l2ork_addons/tar_em_up.sh
@@ -33,8 +33,7 @@ then
 	echo
 	echo "   The incremental options bypass Gem compilation. This saves"
 	echo "   (lots of) time, but the generated package will lack Gem"
-	echo "   unless it has already been built previously. NOTE: Building"
-	echo "   Gem is NOT supported on OSX right now."
+	echo "   unless it has already been built previously."
 	echo
 	echo "   The -k (keep) option doesn't clean before compilation,"
 	echo "   preserving the build products from a previous run. This"
@@ -132,7 +131,7 @@ fi
 # Auto-detect the platform and pick an appropriate build target.
 if [ $any -gt 0 ]; then
 	if [[ $os == "osx" ]]; then
-		dmg=1
+		dmg=$any
 	elif [[ $os == "win" || $os == "win64" ]]; then
 		inno=$any
 	else
@@ -146,7 +145,7 @@ fi
 # package for the platform instead.
 if [ $full -gt 0 ]; then
 	if [[ $os == "osx" ]]; then
-		dmg=1
+		dmg=$full
 		echo "Warning: tarball installer not supported on Mac, building a dmg installer instead."
 	elif [[ $os == "win" || $os == "win64" ]]; then
 		inno=$full
@@ -356,7 +355,7 @@ then
 	elif [[ $os == "osx" ]]; then
 		echo "Making OSX package (dmg)..."
 		echo `pwd`
-		make install && make package
+		make install INCREMENTAL=$INCREMENTAL LIGHT=$LIGHT && make package
 	else
 		# create images folder
 		mkdir -p ../../packages/linux_make/build$inst_dir/lib/pd-l2ork/extra/images
diff --git a/packages/darwin_app/Makefile b/packages/darwin_app/Makefile
index 2b04949fa3836ae1b8fe2f26b0be6bb8a8a9b094..b379c0d6f09af65f7d74a249d30d1873e7e806e1 100644
--- a/packages/darwin_app/Makefile
+++ b/packages/darwin_app/Makefile
@@ -68,17 +68,7 @@ darwin_app: darwin_app_core extended_install darwin_app_embed_libs
 NWFILES = $(foreach file,$(wildcard $(cvs_root_dir)/pd/nw/*),$(DESTDIR)/bin/$(notdir $(file)))
 
 extended_install:
-# on Mac OS X 10.6/Snow Leopard don't build Gem since it needs Carbon
-ifeq ($(shell uname -r | sed 's|10\.[0-9][0-9]*\.[0-9][0-9]*|10|'),10)
-	$(MAKE) -C $(packages_src) $(DEST_PATHS) abstractions_install
-	$(MAKE) -C $(packages_src) $(DEST_PATHS) externals_install
-	$(MAKE) -C $(packages_src) $(DEST_PATHS) readme_install
-	$(MAKE) -C $(packages_src) $(DEST_PATHS) welcome_install
-	$(MAKE) -C $(packages_src) $(DEST_PATHS) license_install
-	$(MAKE) -C $(packages_src) $(DEST_PATHS) noncvs_install
-else
 	$(MAKE) -C $(packages_src) $(DEST_PATHS) extended_install
-endif
 	# Huge kludge to move all the nw.js files in $DESTDIR/bin to
 	# $DESTDIR. We need to do this because the nw.js app expects
 	# package.json to be inside $DESTDIR. So all the rest of the
@@ -148,8 +138,6 @@ rez_install:
 
 darwin_app_embed_libs:
 # embed libquicktime plugins
-	#install -d $(PD_APP_CONTENTS)/lib/libquicktime1
-	#install -p /sw/lib/libquicktime1/*.so $(PD_APP_CONTENTS)/lib/libquicktime1
 	./embed-MacOSX-dependencies.sh $(PD_APP_CONTENTS)
 
 # shortcut to install the readme on non-Extended builds
@@ -306,8 +294,6 @@ test_locations:
 	@echo "MANUALSDIR  $(manualsdir)"
 	@echo "EXAMPLESDIR  $(examplesdir)"
 	@echo --------------------------------------------------
-	sw_vers
-	@echo --------------------------------------------------
 	autoconf --version
 	@echo --------------------------------------------------
 	make --version
diff --git a/packages/darwin_app/embed-MacOSX-dependencies.sh b/packages/darwin_app/embed-MacOSX-dependencies.sh
index 318ae79f9a292a2e12b3e8d22da69b5453b0b6e8..1d4e53e3be3b09ae451b20c036adfd6b7472e284 100755
--- a/packages/darwin_app/embed-MacOSX-dependencies.sh
+++ b/packages/darwin_app/embed-MacOSX-dependencies.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
-# This script finds all of the dependecies from Fink and included them into
-# the Pd.app.  <hans@at.or.at>
+# This script finds all of the dependecies from Homebrew or MacPorts and
+# includes them into the Pd.app.  <hans@at.or.at>
 #
 # run it in the root directory where the externals are stored, i.e. "extra"
 
@@ -12,9 +12,22 @@ if [ $# -ne 1 ]; then
 	exit
 fi
 
+# Check whether we have Homebrew or MacPorts, prefer the former.
+optlocal=$((test -d /usr/local/opt && echo /usr/local/opt) || (test -d /opt/local && echo /opt/local) || echo /usr/local)
+
+if [ "$optlocal" == "/opt/local" ]; then
+    # MacPorts installs software into /opt/local
+    usrlocal=$optlocal
+else
+    # Homebrew links software into /usr/local; if neither MP nor Homebrew is
+    # detected, fall back to plain old local software in /usr/local
+    usrlocal=/usr/local
+fi
+
 LIB_DIR=lib
 PD_APP_CONTENTS=$1
 PD_APP_LIB=$PD_APP_CONTENTS/$LIB_DIR
+PD_APP_PLUGINS=$PD_APP_CONTENTS/Plugins
 
 #echo "PD_APP_CONTENTS: $PD_APP_CONTENTS"
 #echo "PD_APP_LIB: $PD_APP_LIB"
@@ -22,25 +35,57 @@ PD_APP_LIB=$PD_APP_CONTENTS/$LIB_DIR
 echo " "
 
 for pd_darwin in `find $PD_APP_CONTENTS -name '*.pd_darwin'`; do
-	LIBS=`otool -L $pd_darwin | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
+	LIBS=`otool -L $pd_darwin | sed -n 's|.*'"${optlocal}"'/\(.*\.dylib\).*|\1|p'`
 	if [ "x$LIBS" != "x" ]; then
 		echo "`echo $pd_darwin | sed 's|.*/\(.*\.pd_darwin$\)|\1|'` is using:"
 		for lib in $LIBS; do
 			echo "    $lib"
 			install -d $PD_APP_LIB
-			install -p /usr/local/opt/$lib $PD_APP_LIB/$(basename $lib)
+			install -p ${optlocal}/$lib $PD_APP_LIB/$(basename $lib)
 			new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
-			# @executable_path starts from Contents/Resources/app.nw/bin/pd
+			# @executable_path starts from Contents/Resources/app.nw/bin
 			install_name_tool -id @executable_path/../../../$LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
-			install_name_tool -change /usr/local/opt/$lib @executable_path/../../../$LIB_DIR/$new_lib $pd_darwin
+			install_name_tool -change ${optlocal}/$lib @executable_path/../../../$LIB_DIR/$new_lib $pd_darwin
 		done
 		echo " "
 	fi
 done
 
+# check for libquicktime plugins, copy them over
+rm -rf $PD_APP_PLUGINS/libquicktime
+libqt_ffmpeg_plugins=${optlocal}/libquicktime-ffmpeg/lib/libquicktime
+libqt_plugins=${optlocal}/libquicktime/lib/libquicktime
+# prefer libquicktime-ffmpeg, in case we have both installed
+if test -d ${libqt_ffmpeg_plugins}; then
+    cp -r ${libqt_ffmpeg_plugins} $PD_APP_PLUGINS
+elif test -d ${libqt_plugins}; then
+    cp -r ${libqt_plugins} $PD_APP_PLUGINS
+elif [ "$optlocal" != "/opt/local" ]; then
+    echo "No libquicktime found, did you install it?" >&2
+fi
+# change permissions so that install_name can write to the plugin files
+chmod -fR u+xw $PD_APP_PLUGINS/libquicktime
+
 # check for .so plugins used by libquicktime and others
-for so in $PD_APP_LIB/*/*.so; do
-	LIBS=`otool -L $so | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
+for so in $PD_APP_PLUGINS/*/*.so; do
+	LIBS=`otool -L $so | sed -n 's|.*'"${optlocal}"'/\(.*\.dylib\).*|\1|p'`
+	if [ "x$LIBS" != "x" ]; then
+		echo "`echo $so | sed 's|.*/\(lib.*/.*\.so\)|\1|'` is using:"
+		for lib in $LIBS; do
+			echo "    $lib"
+			new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
+			if [ -e  $PD_APP_LIB/$new_lib ]; then
+				echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
+			else
+				install -vp ${optlocal}/$lib $PD_APP_LIB
+			fi
+			# @executable_path starts from Contents/Resources/app.nw/bin
+			install_name_tool -change ${optlocal}/$lib @executable_path/../../../$LIB_DIR/$new_lib $so
+		done
+		echo " "
+	fi
+	# Homebrew also has some libraries in its cellar (keg-only package?).
+	LIBS=`otool -L $so | sed -n 's|.*'"/usr/local/Cellar"'/\(.*\.dylib\).*|\1|p'`
 	if [ "x$LIBS" != "x" ]; then
 		echo "`echo $so | sed 's|.*/\(lib.*/.*\.so\)|\1|'` is using:"
 		for lib in $LIBS; do
@@ -49,17 +94,17 @@ for so in $PD_APP_LIB/*/*.so; do
 			if [ -e  $PD_APP_LIB/$new_lib ]; then
 				echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
 			else
-				install -vp /usr/local/opt/$lib $PD_APP_LIB
+				install -vp /usr/local/Cellar/$lib $PD_APP_LIB
 			fi
-			# @executable_path starts from Contents/Resources/bin/pd
-			install_name_tool -change /usr/local/opt/$lib @executable_path/../../../$LIB_DIR/$new_lib $so
+			# @executable_path starts from Contents/Resources/app.nw/bin
+			install_name_tool -change /usr/local/Cellar/$lib @executable_path/../../../$LIB_DIR/$new_lib $so
 		done
 		echo " "
 	fi
 done
 
 for dylib in $PD_APP_LIB/*.dylib; do
-	LIBS=`otool -L $dylib | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
+	LIBS=`otool -L $dylib | sed -n 's|.*'"${optlocal}"'/\(.*\.dylib\).*|\1|p'`
 	if [ "x$LIBS" != "x" ]; then
 		echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
 		for lib in $LIBS; do
@@ -68,19 +113,19 @@ for dylib in $PD_APP_LIB/*.dylib; do
 			if [ -e  $PD_APP_LIB/$new_lib ]; then
 				echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
 			else
-				install -vp /usr/local/opt/$lib $PD_APP_LIB
+				install -vp ${optlocal}/$lib $PD_APP_LIB
 			fi
-			# @executable_path starts from Contents/Resources/bin/pd
+			# @executable_path starts from Contents/Resources/app.nw/bin
 			install_name_tool -id @executable_path/../../../$LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
-			install_name_tool -change /usr/local/opt/$lib @executable_path/../../../$LIB_DIR/$new_lib $dylib
+			install_name_tool -change ${optlocal}/$lib @executable_path/../../../$LIB_DIR/$new_lib $dylib
 		done
 		echo " "
 	fi
 done
 
-# run it again to catch dylibs that depend on dylibs located in /usr/local/
+# run it again to catch dylibs that depend on dylibs located in ${usrlocal}/
 for dylib in $PD_APP_LIB/*.dylib; do
-	LIBS=`otool -L $dylib | sed -n 's|.*/usr/local/\(.*\.dylib\).*|\1|p'`
+	LIBS=`otool -L $dylib | sed -n 's|.*'"${usrlocal}"'/\(.*\.dylib\).*|\1|p'`
 	if [ "x$LIBS" != "x" ]; then
 		echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
 		for lib in $LIBS; do
@@ -89,20 +134,20 @@ for dylib in $PD_APP_LIB/*.dylib; do
 			if [ -e  $PD_APP_LIB/$new_lib ]; then
 				echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
 			else
-				install -vp /usr/local/$lib $PD_APP_LIB
+				install -vp ${usrlocal}/$lib $PD_APP_LIB
 			fi
-			# @executable_path starts from Contents/Resources/app.nw/bin/pd
+			# @executable_path starts from Contents/Resources/app.nw/bin
 			install_name_tool -id @executable_path/../../../$LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
-			install_name_tool -change /usr/local/$lib @executable_path/../../../$LIB_DIR/$new_lib $dylib
+			install_name_tool -change ${usrlocal}/$lib @executable_path/../../../$LIB_DIR/$new_lib $dylib
 		done
 		echo " "
 	fi
 done
 
 # finally, run it one more time to catch dylibs that depend on dylibs from
-# /usr/local/
+# ${usrlocal}/
 for dylib in $PD_APP_LIB/*.dylib; do
-        LIBS=`otool -L $dylib | sed -n 's|.*/usr/local/\(.*\.dylib\).*|\1|p'`
+        LIBS=`otool -L $dylib | sed -n 's|.*'"${usrlocal}"'/\(.*\.dylib\).*|\1|p'`
         if [ "x$LIBS" != "x" ]; then
                 echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
                 for lib in $LIBS; do
@@ -111,11 +156,11 @@ for dylib in $PD_APP_LIB/*.dylib; do
                         if [ -e  $PD_APP_LIB/$new_lib ]; then
                                 echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
                         else
-                                install -vp /usr/local/$lib $PD_APP_LIB
+                                install -vp ${usrlocal}/$lib $PD_APP_LIB
                         fi
-                        # @executable_path starts from Contents/Resources/app.nw/bin/pd
+                        # @executable_path starts from Contents/Resources/app.nw/bin
                         install_name_tool -id @executable_path/../../../$LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
-                        install_name_tool -change /usr/local/$lib @executable_path/../../../$LIB_DIR/$new_lib $dylib
+                        install_name_tool -change ${usrlocal}/$lib @executable_path/../../../$LIB_DIR/$new_lib $dylib
                 done
                 echo " "
         fi
diff --git a/packages/gendoc/Makefile b/packages/gendoc/Makefile
index 479b2e27d657aa2810d87e639f6b468bbed2eabd..9de0231665fd43582ff620fdcd01b9a849257f6e 100644
--- a/packages/gendoc/Makefile
+++ b/packages/gendoc/Makefile
@@ -8,6 +8,12 @@ $(addprefix Welcome-, Linux Darwin MINGW)
 markdown = $(addsuffix .md, $(targets))
 html = $(addsuffix .html, $(targets))
 
+# python -m markdown setup. We may need to invoke python as python3 on systems
+# which still have python2 as the default. You can also set this manually by
+# passing python-markdown=python-markdown-command to make if python-markdown
+# gets invoked in an unusual way.
+python-markdown = $(shell python3 -m markdown 2>/dev/null < /dev/null && echo python3 -m markdown || echo python -m markdown)
+
 # Note: This requires special tools (python-markdown, awk).
 all: html
 
@@ -20,7 +26,7 @@ ReadMe-%.md: ReadMe.md
 
 ReadMe-%.html: osname = $(patsubst ReadMe-%.html,%,$@)
 ReadMe-%.html: ReadMe-%.md pandoc-template.html
-	python -m markdown $< > ReadMe-body.html
+	$(python-markdown) $< > ReadMe-body.html
 	sed -e "s/@version@/$(version) ($(osname))/g" -e '/--stylesheet--/r gh-pandoc.css' -e '/--body--/r ReadMe-body.html' pandoc-template.html > $@
 	rm -f ReadMe-body.html
 
@@ -30,7 +36,7 @@ Welcome-%.md: Welcome.md
 
 Welcome-%.html: osname = $(patsubst Welcome-%.html,%,$@)
 Welcome-%.html: Welcome-%.md pandoc-template.html
-	python -m markdown $< > Welcome-body.html
+	$(python-markdown) $< > Welcome-body.html
 	sed -e "s/@version@/$(version) ($(osname))/g" -e '/--stylesheet--/r gh-pandoc.css' -e '/--body--/r Welcome-body.html' pandoc-template.html > $@
 	rm -f Welcome-body.html
 
diff --git a/pd/src/makefile.in b/pd/src/makefile.in
index 4f30df23848e853a7d826f49143c4a851d2d615e..439ab427b15eaae96889ea0381e94c206f13080f 100644
--- a/pd/src/makefile.in
+++ b/pd/src/makefile.in
@@ -271,7 +271,7 @@ etags:
 etags_Darwin:
 	find /System/Library/Frameworks  -type f -name \*.h -exec etags -a '{}' \;
 	find /Library/Frameworks  -type f -name \*.h -exec etags -a '{}' \;
-	find /sw/include -type f -name \*.h -exec etags -a '{}' \;
+	find /usr/local/include/ -type f -name \*.h -exec etags -a '{}' \;
 
 etags_Linux:
 
diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index 3ee486e46a33515554ae7f55c7cd508f130b2397..76f101a82a845a433b28a08796b90bd06bdea445 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -1396,7 +1396,6 @@ int sys_startgui(const char *guidir)
                 "/Applications/Wish.app/Contents/MacOS/Wish",
                 "/Applications/Wish Shell.app/Contents/MacOS/Wish Shell",
                 "/usr/local/bin/wish8.4",
-                "/sw/bin/wish8.4"
                 "/opt/bin/wish8.4"
                 "/usr/bin/wish8.4"
                 "/usr/local/bin/wish8.4",
diff --git a/pd/src/s_loader.c b/pd/src/s_loader.c
index 1dc0646a809a2d73255dda9a5d51d7d420d1d46c..f656f3ddfc3b2edc8de145822e6d65a58ff69060 100644
--- a/pd/src/s_loader.c
+++ b/pd/src/s_loader.c
@@ -250,7 +250,14 @@ gotone:
         ntdll = LoadLibrary(filename);
         if (!ntdll)
         {
-            verbose(1, "%s: couldn't load", filename);
+            wchar_t wbuf[MAXPDSTRING];
+            char buf[MAXPDSTRING];
+            DWORD count, err = GetLastError();
+            count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+                0, err, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), wbuf, MAXPDSTRING, NULL);
+            if (!count || !WideCharToMultiByte(CP_UTF8, 0, wbuf, count+1, buf, MAXPDSTRING, 0, 0))
+                *buf = '\0';
+            error("%s: %s (%d)", filename, buf, err);
             class_set_extern_dir(&s_);
             return (0);
         }
@@ -263,7 +270,7 @@ gotone:
     dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
     if (!dlobj)
     {
-        verbose(1, "%s: %s", filename, dlerror());
+        error("%s: %s", filename, dlerror());
         class_set_extern_dir(&s_);
         return (0);
     }
@@ -277,7 +284,7 @@ gotone:
 
     if (!makeout)
     {
-        verbose(1, "load_object: Symbol \"%s\" not found", symname);
+        error("load_object: Symbol \"%s\" not found", symname);
         class_set_extern_dir(&s_);
         return 0;
     }
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index 0fb8cc06556a53053ba314b961296393bee3221e..8b2abb0dbc395e40e44fc44bb7ebeee34eab2f53 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -389,6 +389,17 @@ int sys_main(int argc, char **argv)
 #ifndef MSW
     if (!noprefs)
         sys_rcfile();                           /* parse the startup file */
+#endif
+#ifdef __APPLE__
+    // Initialize libquicktime for Gem, so that it finds its plugins.
+    char *plugins = strdup(argv[0]), *t = strstr(plugins, "/Contents");
+    if (t) {
+      strncpy(t, "/Contents/Plugins/libquicktime", strlen(t));
+      fprintf(stderr, "LIBQUICKTIME_PLUGIN_DIR = %s\n", plugins);
+      // We don't override an existing value here, since the user may have
+      // already set up her own libquicktime plugin collection.
+      setenv("LIBQUICKTIME_PLUGIN_DIR", plugins, 0);
+    }
 #endif
     if (sys_argparse(argc-1, argv+1))           /* parse cmd line */
         return (1);