NAME=	sony_fpga_driver
DSPEC=	dist/$(NAME).spec
SPEC=	dist/ulm-python3-$(NAME).spec

.PHONY:	all rpm clean

all:

$(DSPEC):	setup.py src/$(NAME)/__init__.py
	python3 setup.py bdist_rpm --spec-only
	python3 setup.py sdist

$(SPEC):	$(DSPEC) Makefile
	sed -e '/^%define name/s/name/pyname/' \
	    -e '/^Name/s/%/ulm-python3-%/' \
	    -e '/^Release/s/$$/%{?dist}/' \
	    -e '/^License/c License: Sony Proprietary' \
	    -e 's/%{name}/%{pyname}/g' \
	    $< > $@

rpm:	$(SPEC)
	#rpmbuild -ba --sign --define '_sourcedir $(CURDIR)/dist' $<
	rpmbuild -ba --define '_sourcedir $(CURDIR)/dist' $<
	rpm --addsign $(addprefix $(shell rpmbuild --eval %_rpmdir)/$(shell rpmspec -q --srpm --qf '%{arch}' $<)/,\
		$(addsuffix .rpm,$(shell rpmspec -q $<)))

release: rpm
	$(shell pwd)/make/script/rsync_ulmdnf.sh -r $(DNF_REPO) -v

create_rel_br:
	$(shell pwd)/make/script/create_rel_br.sh -v $(REL_VER) -b $(shell git rev-parse --abbrev-ref HEAD) -x

clean:
	$(RM) $(SPEC) $(DSPEC) dist/$(NAME)-*.tar.gz
