# Simple makefile for VPB utility targets
# Ron Lee, 2007

TARGETS = bridgeports dtmfcheck measerl playwav proslicerl raw2wav recwav \
	  ringstat sendcid tonedebug tonegen tonetrain vdaaerl vpbecho

srcdir       := @srcdir@
top_srcdir   := @top_srcdir@
top_builddir := @top_builddir@

include $(top_builddir)/Makefile.common

vpath %.cpp $(srcdir)


CPPFLAGS += -pthread -MMD -I$(top_srcdir)/src/libvpb
LDFLAGS  += -pthread -L$(top_builddir)/src/libvpb
LDLIBS   += -lvpb


all: $(TARGETS)

dtmfcheck.o: CPPFLAGS += -I$(top_srcdir)/src/dsp


ifeq ($(LIB_TYPE),shared)
LDFLAGS += -Wl,-rpath-link,$(top_builddir)/src/libtoneg
else
lib-stamp: $(top_builddir)/src/libvpb/libvpb.a     \
           $(top_builddir)/src/libtoneg/libtoneg.a
	touch $@

$(TARGETS): lib-stamp
endif


install:
	@echo "These utilities are not installed by default"

clean:
	$(RM) $(TARGETS) lib-stamp *.o *.d core* linear??.wav

distclean: clean
	$(RM) Makefile VpbConfigurator


define CPLUSPLUS_TARGET
 $(1): CC=$(CXX)
 $(1): $(1).o
	$$(CXX) $$(LDFLAGS) $(1).o $$(LDLIBS) -o $$@
endef

$(foreach target,$(TARGETS),$(eval $(call CPLUSPLUS_TARGET,$(target))))

-include $(addsuffix .d,$(TARGETS))

.PHONY: all install clean distclean

