#############################################################
#
# alsa-utils
#
#############################################################
ALSA_UTILS_VERSION = 1.0.16
ALSA_UTILS_SOURCE = alsa-utils-$(ALSA_UTILS_VERSION).tar.bz2
ALSA_UTILS_SITE = ftp://ftp.alsa-project.org/pub/utils
ALSA_UTILS_INSTALL_STAGING = YES
ALSA_UTILS_INSTALL_TARGET = YES
ALSA_UTILS_CONF_OPT = $(DISABLE_NLS)
ALSA_UTILS_DEPENDENCIES = uclibc alsa-lib ncurses

ALSA_UTILS_TARGETS_ :=
ALSA_UTILS_TARGETS_y :=

ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ALSACONF) += usr/sbin/alsaconf
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ALSACTL) += usr/sbin/alsactl
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ALSAMIXER) += usr/bin/alsamixer
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_AMIDI) += usr/bin/amidi
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_AMIXER) += usr/bin/amixer
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_APLAY) += usr/bin/aplay
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ARECORD) += usr/bin/arecord
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_IECSET) += usr/bin/iecset
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ACONNECT) += usr/bin/aconnect
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_APLAYMIDI) += usr/bin/aplaymidi
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ARECORDMIDI) += usr/bin/arecordmidi
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ASEQDUMP) += usr/bin/aseqdump
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_ASEQNET) += usr/bin/aseqnet
ALSA_UTILS_TARGETS_$(BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST) += usr/bin/speaker-test


$(eval $(call AUTOTARGETS,package/multimedia,alsa-utils))

$(ALSA_UTILS_TARGET_INSTALL_TARGET): $(ALSA_UTILS_TARGET_INSTALL_STAGING)
	$(call MESSAGE,"Installing to target")
	$(Q)mkdir -p $(TARGET_DIR)/usr/bin
	$(Q)mkdir -p $(TARGET_DIR)/usr/sbin
	$(Q)for file in $(ALSA_UTILS_TARGETS_y); do \
		cp -dpf $(STAGING_DIR)/$$file $(TARGET_DIR)/$$file; \
		$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/$$file; \
		echo "Copy to target: $(TARGET_DIR)/$$file"; \
	done
ifeq ($(BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST),y)
	$(Q)mkdir -p $(TARGET_DIR)/usr/share/alsa/speaker-test
	$(Q)mkdir -p $(TARGET_DIR)/usr/share/sounds/alsa
	$(Q)echo "Copy to target: speaker-test data"
	$(Q)cp -rdpf $(STAGING_DIR)/usr/share/alsa/speaker-test/* $(TARGET_DIR)/usr/share/alsa/speaker-test/
	$(Q)cp -rdpf $(STAGING_DIR)/usr/share/sounds/alsa/* $(TARGET_DIR)/usr/share/sounds/alsa/
endif
	$(Q)touch $@

$(ALSA_UTILS_TARGET_UNINSTALL):
	$(call MESSAGE,"Uninstalling")
	$(Q)for file in $(ALSA_UTILS_TARGETS_y); do \
		rm -f $(TARGET_DIR)/$$file; \
		echo "Remove: $(TARGET_DIR)/$$file"; \
	done
	-rm -rf $(TARGET_DIR)/usr/share/alsa/speaker-test/
	-rm -rf $(TARGET_DIR)/usr/share/sounds/alsa/
	$(ALSA_UTILS_MAKE_ENV) $(MAKE) $(ALSA_UTILS_UNINSTALL_STAGING_OPT) -C $(@D)/$(ALSA_UTILS_SUBDIR)
	$(Q)-rm $(@D)/$(ALSA_UTILS_SUBDIR)/.stamp_target_installed
	$(Q)-rm $(@D)/$(ALSA_UTILS_SUBDIR)/.stamp_staging_installed

