all: @LOCAL_LIBS@ @BUILDLIBS@

# Allegro
allegro-recursive:
	$(MAKE) -C allegro
allegro.a: allegro-recursive
	ln -sf allegro/allegro.a allegro.a

# dlcompat
dl-recursive:
	$(MAKE) -C dlcompat
libdl.a: dl-recursive
	ln -sf dlcompat/libdl.a libdl.a

# expat
expat-recursive:
	$(MAKE) -C expat
expat.a: expat-recursive
	ln -sf expat/expat.a expat.a

# libogg
libogg-recursive:
	$(MAKE) -C libogg
libogg.a: libogg-recursive
	ln -sf libogg/src/.libs/libogg.a libogg.a

# libvorbis
libvorbis-recursive:
	$(MAKE) -C libvorbis
libvorbis.a libvorbisfile.a libvorbisenc.a: libvorbis-recursive
	ln -sf libvorbis/lib/.libs/libvorbis.a libvorbis.a
	ln -sf libvorbis/lib/.libs/libvorbisfile.a libvorbisfile.a
	ln -sf libvorbis/lib/.libs/libvorbisenc.a libvorbisenc.a

# libflac
libflac-recursive:
	$(MAKE)  -C libflac
libFLAC++.a libFLAC.a: libflac-recursive
	ln -sf libflac/src/libFLAC++/.libs/libFLAC++.a libFLAC++.a
	ln -sf libflac/src/libFLAC/.libs/libFLAC.a libFLAC.a

# libnyquist
libnyquist-recursive:
	$(MAKE) -C libnyquist
libnyquist.a: libnyquist-recursive
	ln -sf libnyquist/libnyquist.a libnyquist.a

# libmad
libmad-recursive:
	$(MAKE) -C libmad
libmad.a: libmad-recursive
	ln -sf libmad/.libs/libmad.a libmad.a
libmad/mad.h: libmad-recursive

# libid3tag
libid3tag-recursive:
	$(MAKE) -C libid3tag
libid3tag.a: libid3tag-recursive
	ln -sf libid3tag/.libs/libid3tag.a libid3tag.a

# libsamplerate
libsamplerate-recursive:
	$(MAKE) -C libsamplerate
libsamplerate.a: libsamplerate-recursive
	ln -sf libsamplerate/src/.libs/libsamplerate.a libsamplerate.a

# libresample
libresample-recursive:
	$(MAKE) -C libresample
libresample.a: libresample-recursive
	ln -sf libresample/libresample.a libresample.a


# libsndfile
libsndfile-recursive:
	$(MAKE) -C libsndfile
libsndfile.a: libsndfile-recursive
	ln -sf libsndfile/src/.libs/libsndfile.a libsndfile.a

# SoundTouch
soundtouch-recursive:
	$(MAKE) -C soundtouch
libSoundTouch.a: soundtouch-recursive
	ln -sf soundtouch/source/SoundTouch/.libs/libSoundTouch.a .

# PortAudio
portaudio/pa_unix_oss/portaudio.a:
	$(MAKE) -C portaudio/pa_unix_oss

portaudio-v19/lib/libportaudio.a:
	$(MAKE) -C portaudio-v19

portaudio/pa_mac_core/portaudio.a:
	$(MAKE) -C portaudio/pa_mac_core

portmixer/px_unix_oss/portmixer.a:
	$(MAKE) -C portmixer/px_unix_oss

portmixer/px_mac_core/portmixer.a:
	$(MAKE) -C portmixer/px_mac_core


# Utility rules
clean:
	-$(MAKE) -C allegro clean
	-$(MAKE) -C dlcompat clean	
	-$(MAKE) -C expat clean
	-$(MAKE) -C libid3tag clean
	-$(MAKE) -C libmad clean
	-$(MAKE) -C libnyquist clean
	-$(MAKE) -C libogg clean
	-$(MAKE) -C libsamplerate clean
	-$(MAKE) -C libresample clean
	-$(MAKE) -C libsndfile clean
	-$(MAKE) -C libvorbis clean
	-$(MAKE) -C libflac clean
	-$(MAKE) -C portaudio/pa_unix_oss clean
	-$(MAKE) -C portaudio/pa_mac_core clean
	-$(MAKE) -C portmixer/px_unix_oss clean
	-$(MAKE) -C portmixer/px_mac_core clean
	-$(MAKE) -C soundtouch clean

distclean:
	-$(MAKE) -C allegro distclean
	-$(MAKE) -C dlcompat distclean
	-$(MAKE) -C expat distclean
	-$(MAKE) -C libid3tag distclean
	-$(MAKE) -C libmad distclean
	-$(MAKE) -C libnyquist distclean
	-$(MAKE) -C libogg distclean
	-$(MAKE) -C libsamplerate distclean
	-$(MAKE) -C libresample distclean
	-$(MAKE) -C libsndfile distclean
	-$(MAKE) -C libvorbis distclean
	-$(MAKE) -C libflac distclean
	-$(MAKE) -C portaudio/pa_unix_oss distclean
	-$(MAKE) -C portaudio/pa_mac_core distclean
	-$(MAKE) -C portmixer/px_unix_oss distclean
	-$(MAKE) -C portmixer/px_mac_core distclean
	-$(MAKE) -C soundtouch distclean

.PHONY: allegro-recursive expat-recursive libogg-recursive \
	libvorbis-recursive libnyquist-recursive libmad-recursive \
	libid3tag-recursive soundtouch-recursive libsndfile-recursive \
	libresample-recursive libsamplerate-recursive
