#############################################################
#
# alsa-lib
#
#############################################################
ALSA_LIB_VERSION = 1.0.16
ALSA_LIB_SOURCE = alsa-lib-$(ALSA_LIB_VERSION).tar.bz2
ALSA_LIB_SITE = ftp://ftp.alsa-project.org/pub/lib
ALSA_LIB_INSTALL_STAGING = YES
ALSA_LIB_INSTALL_TARGET = YES
ALSA_LIB_CONF_OPT = --enable-shared --enable-static --disable-docs --disable-python $(DISABLE_NLS)
ALSA_LIB_DEPENDENCIES = uclibc

ifeq ($(BR2_arm),y)
ALSA_LIB_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -mabi=aapcs-linux"
endif

ifeq ($(BR2_SOFT_FLOAT),y)
ALSA_LIB_CONF_OPT += --with-softfloat
endif

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

$(ALSA_LIB_TARGET_INSTALL_TARGET): $(ALSA_LIB_TARGET_INSTALL_STAGING)
	$(call MESSAGE,"Installing to target")
	mkdir -p $(TARGET_DIR)/usr/share/alsa $(TARGET_DIR)/usr/lib/alsa-lib
	cp -dpf $(STAGING_DIR)/usr/lib/libasound.so* $(TARGET_DIR)/usr/lib/
	cp -rdpf $(STAGING_DIR)/usr/share/alsa/* $(TARGET_DIR)/usr/share/alsa/
	cp -rdpf $(STAGING_DIR)/usr/lib/alsa-lib/* $(TARGET_DIR)/usr/lib/alsa-lib/
	find $(TARGET_DIR)/usr/lib/alsa-lib/ -regex '.*((\.la)|(\.a))[~]{0,1}' -exec rm {} \;
	-$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/usr/lib/libasound.so*
	-$(STRIPCMD) $(STRIP_STRIP_UNNEEDED) $(TARGET_DIR)/usr/lib/alsa-lib/smixer/*.so
	$(Q)touch $@

$(ALSA_LIB_TARGET_UNINSTALL):
	$(call MESSAGE,"Uninstalling")
	-rm -f $(TARGET_DIR)/usr/lib/libasound*.so*
	-rm -rf $(TARGET_DIR)/usr/lib/alsa-lib/
	$(ALSA_LIB_MAKE_ENV) $(MAKE) $(ALSA_LIB_UNINSTALL_STAGING_OPT) -C $(@D)/$(ALSA_LIB_SUBDIR)
	$(Q)-rm $(@D)/$(ALSA_LIB_SUBDIR)/.stamp_target_installed
	$(Q)-rm $(@D)/$(ALSA_LIB_SUBDIR)/.stamp_staging_installed

