#!/usr/bin/make -f
# vim: syntax=make
export DH_VERBOSE = 1

derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes") || echo "no")
VERSION := 1.28

export DESTROOT=$(CURDIR)/debian
export INSTPREFIX=$(DESTROOT)/clifm/usr/bin
export DESKTOPPREFIX=$(DESTROOT)/clifm/usr/share
export ICONPREFIX=$(DESKTOPPREFIX)/icons/hicolor
export PROG=clifm

DEB_TARGET_GNU_CPU ?= $(DEB_BUILD_GNU_CPU)

%:
	dh $@

override_dh_auto_clean:

override_dh_auto_build:
	make

override_dh_auto_install:
	mkdir -p $(INSTPREFIX)
	cp clifm $(INSTPREFIX)
	mkdir -p $(DESKTOPPREFIX)/applications
	mkdir -p $(DESKTOPPREFIX)/man/man1
	mkdir -p $(DESKTOPPREFIX)/bash-completion/completions
	mkdir -p $(DESKTOPPREFIX)/applications
	mkdir -p $(DESKTOPPREFIX)/zsh/site-functions
	mkdir -p $(DESKTOPPREFIX)/fish/vendor_completions.d
	mkdir -p $(DESKTOPPREFIX)/icons/hicolor/scalable/apps
	mkdir -p $(DESKTOPPREFIX)/locale/es/LC_MESSAGES
	mkdir -p $(DESKTOPPREFIX)/$(PROG)/plugins
	mkdir -p $(DESKTOPPREFIX)/$(PROG)/tools
	mkdir -p $(DESKTOPPREFIX)/$(PROG)/functions
	mkdir -p $(DESKTOPPREFIX)/$(PROG)/colors
	cp misc/$(PROG).1 $(DESKTOPPREFIX)/man/man1/
	cp misc/completions.bash $(DESKTOPPREFIX)/bash-completion/completions/$(PROG)
	cp misc/completions.zsh $(DESKTOPPREFIX)/zsh/site-functions/_$(PROG)
	cp misc/completions.fish $(DESKTOPPREFIX)/fish/vendor_completions.d/$(PROG).fish
	cp misc/$(PROG).desktop $(DESKTOPPREFIX)/applications
	cp misc/*.clifm $(DESKTOPPREFIX)/$(PROG)
	cp misc/$(PROG)rc $(DESKTOPPREFIX)/$(PROG)
	cp misc/colors/*.clifm $(DESKTOPPREFIX)/$(PROG)/colors
	cp misc/logo/$(PROG).svg $(ICONPREFIX)/scalable/apps
	cp plugins/* $(DESKTOPPREFIX)/$(PROG)/plugins
	cp misc/tools/*.py $(DESKTOPPREFIX)/$(PROG)/tools
	cp misc/tools/imgprev/clifmimg $(DESKTOPPREFIX)/$(PROG)/plugins
	cp misc/tools/imgprev/clifmrun $(DESKTOPPREFIX)/$(PROG)/plugins
	chmod 755 misc/tools/*.py
	chmod 755 plugins/*
	chmod 644 plugins/BFG.cfg
	cp functions/* $(DESKTOPPREFIX)/$(PROG)/functions
