###############################################################################
#                                                                             #
# IPFire.org - A linux based firewall                                         #
# Copyright (C) 2007-2026  IPFire Team  <info@ipfire.org>                     #
#                                                                             #
# This program is free software: you can redistribute it and/or modify        #
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation, either version 3 of the License, or           #
# (at your option) any later version.                                         #
#                                                                             #
# This program is distributed in the hope that it will be useful,             #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
#                                                                             #
###############################################################################

###############################################################################
# Definitions
###############################################################################

include Config

SUMMARY    = Advanced Linux Sound Architecture

VER        = 1.2.15.3
UVER       = 1.2.15.2
CVER       = 1.2.15.3

THISAPP    = alsa-lib-$(VER)
DL_FILE    = $(THISAPP).tar.bz2
DL_FROM    = $(URL_IPFIRE)
DIR_APP    = $(DIR_SRC)/$(THISAPP)
PROG       = alsa
PAK_VER    = 26

DEPS       =

SERVICES   =

TARGET     = $(DIR_INFO)/$(THISAPP)

###############################################################################
# Top-level Rules
###############################################################################

objects = $(DL_FILE) alsa-utils-$(UVER).tar.bz2 alsa-ucm-conf-$(CVER).tar.bz2


$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
alsa-utils-$(UVER).tar.bz2 = $(DL_FROM)/alsa-utils-$(UVER).tar.bz2
alsa-ucm-conf-$(CVER).tar.bz2 = $(DL_FROM)/alsa-ucm-conf-$(CVER).tar.bz2

$(DL_FILE)_BLAKE2 = 13c21ad3686ed5a8dfa48e8fa8e1b6f3f9a138aeaef2ba778838a8c6f9cbe209a5ece0d9953e2dcdd1e5b90ce50409e77b9485010689adfe4aed176cb8774c0e
alsa-utils-$(UVER).tar.bz2_BLAKE2 = 0688e668241917027b5dd161ebe3ea4ab6f8fede612e148dee74e033ab09f9557c7610a6b506d2507402cca7007a031b85c8c0cb9af80652ae9f3cc5ea157973
alsa-ucm-conf-$(CVER).tar.bz2_BLAKE2 = 7b563fa4685988bf509f4accdab1146b49a807eae8d4ebff3d634c1086c70130930a0e09e08af0be0996dd56d4fdbd58e9d7daa37f762106fa493198589ceac4

install : $(TARGET)

check : $(patsubst %,$(DIR_CHK)/%,$(objects))

download :$(patsubst %,$(DIR_DL)/%,$(objects))

b2 : $(subst %,%_BLAKE2,$(objects))

dist:
	@$(PAK)

###############################################################################
# Downloading, checking, b2sum
###############################################################################

$(patsubst %,$(DIR_CHK)/%,$(objects)) :
	@$(CHECK)

$(patsubst %,$(DIR_DL)/%,$(objects)) :
	@$(LOAD)

$(subst %,%_BLAKE2,$(objects)) :
	@$(B2SUM)

###############################################################################
# Installation Details
###############################################################################

$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
	@$(PREBUILD)
	@rm -rf $(DIR_SRC)/alsa*
	cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
	cd $(DIR_APP) && tar xfj $(DIR_DL)/alsa-utils-$(UVER).tar.bz2
	$(UPDATE_AUTOMAKE)
	cd $(DIR_APP) && ./configure
	cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE)
	cd $(DIR_APP) && make install
	cd $(DIR_APP)/alsa-utils-$(UVER) && ./configure --disable-xmlto
	cd $(DIR_APP)/alsa-utils-$(UVER) && make $(MAKETUNING) $(EXTRA_MAKE)
	cd $(DIR_APP)/alsa-utils-$(UVER) && make install
	cd $(DIR_APP) && tar xfj $(DIR_DL)/alsa-ucm-conf-$(CVER).tar.bz2 \
		-C /usr/share/alsa --strip-components=1 --wildcards "*/ucm2"
	# install initscript
	$(call INSTALL_INITSCRIPTS,alsa)
	# install backup include file
	install -v -m 644 ${DIR_SRC}/config/backup/includes/alsa \
			/var/ipfire/backup/addons/includes/alsa
	@rm -rf $(DIR_SRC)/alsa*
	@$(POSTBUILD)
