## linux/rpm/Makefile
##
##    AudioScience HPI driver
##    Copyright (C) 1997-2018  AudioScience Inc. <support@audioscience.com>
##
##    This program is free software; you can redistribute it and/or modify
##    it under the terms of version 2 of the GNU General Public License as
##    published by the Free Software Foundation;
##
##    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.
##

-include build_overrides.mk
# hpi_version.mk must exist
include hpi_version.mk
# Include dist file lists
include distfiles.mk

.DEFAULT_GOAL := all

RPM_ROOT=$(shell pwd)/rpmbuild

rpm-build: hpklinux.spec
	rm -rf $(RPM_ROOT)
	mkdir -p $(RPM_ROOT)/{RPMS,SPECS,SRPMS,SOURCES}
	ln -sf $(shell pwd)/.. $(RPM_ROOT)/BUILD
	echo '%_topdir ${RPM_ROOT}' > ~/.rpmmacros
	rpmbuild -ba hpklinux.spec
	rm ~/.rpmmacros

setup: $(src-dist-files)

all: setup rpm-build

.PHONY: all rpm-build build
