-BUILDDIRS = bin doc etc include info lib man sbin share vlc-lib tmp
-
-all: FORCE
-# @echo "Do you mean to make src or make bin ?"
- @echo " 'make bin' isn't functional at the moment,"
- @echo " running 'make src' instead..."
- $(MAKE) src
-
-src: FORCE
- $(MAKE) -C src all
-
-contrib-macosx.tar.bz2: FORCE
- $(WGET) $(CONTRIB_URL)
-
-bin: FORCE
- @echo "make bin isn't in a functional state at this moment. Please use make src"
-
-#The disabled make bin
-#bin: contrib-macosx.tar.bz2
-# @if test -d tmp; then \
-# echo "Move away ./tmp, it's in the way" ; \
-# exit 1 ; \
-# fi
-# mkdir tmp
-# bunzip2 -c $< | (cd tmp; tar xf -)
-# ./change_prefix.sh tmp @@CONTRIB_PREFIX@@ $(PREFIX)
-# (cd tmp; tar cf - .) | tar xf -
-# rm -rf tmp
-# ranlib lib/*\.a
-
-clean-src: FORCE
+BUILDDIRS = hosts build
+
+ifdef HAVE_DARWIN_OS
+TARGETALL=using-bin
+else
+TARGETALL=using-src
+endif
+
+all: $(TARGETALL)
+
+using-src:
+ $(MAKE) -C src
+ifdef HAVE_DARWIN_10
+ (cd $(PREFIX)/lib && sed -e 's%/usr/lib/libiconv.la%$(PREFIX)/lib/libiconv.la%g' -i.orig *.la && rm -f *.la.orig)
+endif
+
+# shortcut
+src: using-src
+
+ifdef HAVE_DARWIN_OS
+
+CONTRIBREV=23
+
+contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2:
+ $(WGET) http://downloads.videolan.org/pub/videolan/testing/contrib/$@
+
+hosts/$(HOST)/.$(CONTRIBREV): contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2
+ @if test -d tmp; then \
+ echo "Move away ./tmp, it's in the way" ; \
+ exit 1 ; \
+ fi
+ mkdir tmp
+ mkdir -p $(PREFIX)
+ (cd tmp && tar jxvf ../$<)
+ ./change_prefix.sh tmp @@CONTRIB_PREFIX@@ $(PREFIX)
+ (cd tmp && find . -type d) | while read dir; do mkdir -p -- "$(PREFIX)/$$dir"; done
+ (cd tmp && find . -not -type d) | while read i; do mv -f -- tmp/"$$i" "$(PREFIX)/$$i"; done
+ rm -rf tmp
+ # libiconv.la is no longer present on Snow Leopard, so fix possible references to it, which would
+ # result in linking issues
+ifdef HAVE_DARWIN_10
+ (cd $(PREFIX)/lib && sed -e 's%/usr/lib/libiconv.la%$(PREFIX)/lib/libiconv.la%g' -i.orig *.la && rm -f *.la.orig)
+ (cd src && $(MAKE) .iconv)
+endif
+ touch hosts/$(HOST)/.$(CONTRIBREV)
+
+using-bin: hosts/$(HOST)/.$(CONTRIBREV)
+
+endif
+
+clean: