NAME = netoik-home
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
BRANCH = $(shell [ -d ".git" ] && git branch --show-current)

SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
VARDIR = $(shell rpm --eval "%{_var}")

BOOTSTRAP_VERSION = 5.1.3
FONTAWESOME_VERSION = 6.1.1
JQUERY_VERSION = 3.6.0

.PHONY: version
version:
	@echo $(VERSION)

.PHONY: tarball
tarball: $(HOME)/rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz

$(HOME)/rpmbuild/SOURCES/$(NAME)-%.tar.gz: .
	git archive --format=tar.gz --output=$@ --prefix=$(NAME)-$(VERSION)/ --worktree-attributes --verbose $(BRANCH)

.PHONY: install
install:
	install -D --target-directory $(DESTDIR)$(SYSCONFDIR)/nginx/conf.d                                      nginx/*.conf 
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)                                           src/*.{html,ico}
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/bootstrap-$(BOOTSTRAP_VERSION)     src/assets/bootstrap-$(BOOTSTRAP_VERSION)/*.js
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/css                                src/assets/css/*.css
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/docs                               src/assets/docs/*.pdf
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/fontawesome-$(FONTAWESOME_VERSION) src/assets/fontawesome-$(FONTAWESOME_VERSION)/*.{js,css}
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/googleapis                         src/assets/googleapis/roboto
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/img                                src/assets/img/*.{png,svg}
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/img/services                       src/assets/img/services/*.svg
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/jquery-$(JQUERY_VERSION)           src/assets/jquery-$(JQUERY_VERSION)/*.js
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/assets/js                                 src/assets/js/*.js
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/share/cg                                  src/share/cg/index.html
	install -D --target-directory $(DESTDIR)$(VARDIR)/www/$(NAME)/share/in                                  src/share/in/index.html

.PHONY: bootstrap_version
bootstrap_version:
	@echo $(BOOTSTRAP_VERSION) 

.PHONY: fontawesome_version
fontawesome_version:
	@echo $(FONTAWESOME_VERSION) 

.PHONY: jquery_version
jquery_version:
	@echo $(JQUERY_VERSION) 
