#
# PortAudio V19 Makefile.in
#
# Dominic Mazzoni
# Modifications by Mikael Magnusson
#

top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
top_builddir = .
PREFIX = @prefix@
prefix = $(PREFIX)
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
CC = @CC@
CFLAGS = @CFLAGS@ -I$(top_srcdir)/include -I$(top_srcdir)/src/common -I$(top_srcdir)/src/os/unix @DEFS@
LIBS = @LIBS@
AR = @AR@
RANLIB = @RANLIB@
LIBTOOL = @LIBTOOL@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
SHARED_FLAGS = @SHARED_FLAGS@
LDFLAGS = @LDFLAGS@
DLL_LIBS = @DLL_LIBS@
CXXFLAGS = @CXXFLAGS@
NASM = @NASM@
NASMOPT = @NASMOPT@
LN_S = @LN_S@
LT_RELEASE=@LT_RELEASE@
LT_CURRENT=@LT_CURRENT@
LT_REVISION=@LT_REVISION@
LT_AGE=@LT_AGE@

OTHER_OBJS = @OTHER_OBJS@

PALIB = libportaudio.la
PAINC = include/portaudio.h

PA_LDFLAGS = $(LDFLAGS) $(SHARED_FLAGS) -rpath $(libdir) -no-undefined -export-symbols-regex "(Pa|PaMacCore)_.*" -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
#MAKEFILE = Makefile

COMMON_OBJS = \
	src/common/pa_allocation.o \
	src/common/pa_converters.o \
	src/common/pa_cpuload.o \
	src/common/pa_dither.o \
	src/common/pa_debugprint.o \
	src/common/pa_front.o \
	src/common/pa_process.o \
	src/common/pa_skeleton.o \
	src/common/pa_stream.o \
	src/common/pa_trace.o

TESTS = \
	test/paqa_devs \
	test/paqa_errs \
	test/patest1 \
	test/patest_buffer \
	test/patest_callbackstop \
	test/patest_clip \
	test/patest_dither \
	test/patest_hang \
	test/patest_in_overflow \
	test/patest_latency \
	test/patest_leftright \
	test/patest_longsine \
	test/patest_many \
	test/patest_maxsines \
	test/patest_multi_sine \
	test/patest_out_underflow \
	test/patest_pink \
	test/patest_prime \
	test/patest_read_record \
	test/patest_read_write_wire \
	test/patest_record \
	test/patest_ringmix \
	test/patest_saw \
	test/patest_sine8 \
	test/patest_sine \
  test/patest_sine_channelmaps \
	test/patest_sine_formats \
	test/patest_sine_time \
	test/patest_start_stop \
	test/patest_stop \
	test/patest_stop_playout \
	test/patest_toomanysines \
	test/patest_underflow \
	test/patest_wire \
	test/patest_write_sine \
	test/pa_devs \
	test/pa_fuzz \
	test/pa_minlat

# Most of these don't compile yet.  Put them in TESTS, above, if
# you want to try to compile them...
ALL_TESTS = \
	$(TESTS) \
	test/patest_sync \
	test/debug_convert \
	test/debug_dither_calc \
	test/debug_dual \
	test/debug_multi_in \
	test/debug_multi_out \
	test/debug_record \
	test/debug_record_reuse \
	test/debug_sine_amp \
	test/debug_sine \
	test/debug_sine_formats \
	test/debug_srate \
	test/debug_test1

OBJS = $(COMMON_OBJS) $(OTHER_OBJS)

LTOBJS:= $(OBJS:.o=.lo)

SUBDIRS =
@ENABLE_CXX_TRUE@SUBDIRS += bindings/cpp

all: lib/$(PALIB) all-recursive

tests: bin-stamp $(TESTS)


lib/$(PALIB): lib-stamp $(LTOBJS) $(MAKEFILE) $(PAINC)
	$(LIBTOOL) --mode=link $(CC) $(PA_LDFLAGS) -o lib/$(PALIB) $(LTOBJS) $(DLL_LIBS)

$(ALL_TESTS): lib/$(PALIB) $(MAKEFILE) $(PAINC)
	$(LIBTOOL) --mode=link $(CC) -o $@ $(CFLAGS) $(top_srcdir)/$@.c lib/$(PALIB) $(LIBS)

install: lib/$(PALIB) portaudio-2.0.pc
	$(INSTALL) -d $(DESTDIR)$(libdir)
	$(LIBTOOL) --mode=install $(INSTALL) lib/$(PALIB) $(DESTDIR)$(libdir)
	$(INSTALL) -d $(DESTDIR)$(includedir)
	$(INSTALL_DATA) -m 644 $(top_srcdir)/$(PAINC) $(DESTDIR)$(includedir)/portaudio.h
	$(INSTALL) -d $(DESTDIR)$(libdir)/pkgconfig
	$(INSTALL) -m 644 portaudio-2.0.pc $(DESTDIR)$(libdir)/pkgconfig/portaudio-2.0.pc
	@echo ""
	@echo "------------------------------------------------------------"
	@echo "PortAudio was successfully installed."
	@echo ""
	@echo "On some systems (e.g. Linux) you should run 'ldconfig' now"
	@echo "to make the shared object available.  You may also need to"
	@echo "modify your LD_LIBRARY_PATH environment variable to include"
	@echo "the directory $(libdir)"
	@echo "------------------------------------------------------------"
	@echo ""
	$(MAKE) install-recursive

uninstall:
	$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(PALIB)
	$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(includedir)/portaudio.h
	$(MAKE) uninstall-recursive

clean:
	$(LIBTOOL) --mode=clean rm -f $(LTOBJS) $(ALL_TESTS) lib/$(PALIB)
	rm -f bin-stamp lib-stamp
	-rm -rf bin lib

distclean: clean
	rm -f config.log config.status Makefile libtool portaudio-2.0.pc

.SUFFIXES:
.SUFFIXES: .c .lo .o .cpp

.c.o: $(MAKEFILE) $(PAINC)
	$(CC) -c $(CFLAGS) $< -o $@

.c.lo: $(MAKEFILE) $(PAINC)
	$(LIBTOOL) --mode=compile $(CC) -c $(CFLAGS) $< -o $@

.cpp.o: $(MAKEFILE) $(PAINC)
	$(CXX) -c $(CXXFLAGS) $< -o $@

.asm.o:
	$(NASM) $(NASMOPT) -o $@ $<

bin-stamp:
	-mkdir bin
	touch $@

lib-stamp:
	-mkdir lib
	-mkdir -p src/os/win src/os/unix src/os/mac_osx src/common \
src/hostapi/oss src/hostapi/alsa src/hostapi/jack src/hostapi/asihpi \
src/hostapi/wmme src/hostapi/wdmks src/hostapi/dsound src/hostapi/wasapi
	touch $@

Makefile: Makefile.in config.status
	$(SHELL) config.status

all-recursive:
	for dir in $(SUBDIRS); do make -C $$dir all; done

install-recursive:
	for dir in $(SUBDIRS); do make -C $$dir install; done

uninstall-recursive:
	for dir in $(SUBDIRS); do make -C $$dir uninstall; done