#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)       
                                                                               
ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)                                            
PLATFORM=freebsd
endif                                                                          
ifeq ($(DEB_HOST_ARCH_OS),linux)                                               
PLATFORM=linux
endif                                                                          
  
%:
	dh $@

override_dh_auto_build:
	$(MAKE) all installdir=/usr/share/gogoc platform=$(PLATFORM) 
	$(MAKE) -C gogoc-tsp/conf gogoc.conf.sample PLATFORM=$(PLATFORM) PLATFORM_DIR=../platform installdir=/usr/share/gogoc BIN_DIR=.

override_dh_auto_clean:
	$(MAKE) clean platform=$(PLATFORM) 
	-rm gogoc-tsp/conf/gogoc.conf.sample

override_dh_auto_install:
	install -D gogoc-tsp/conf/gogoc.conf.sample debian/gogoc/etc/gogoc/gogoc.conf

override_dh_install:
	dh_install
	install	-m 755 gogoc-tsp/template/$(PLATFORM).sh debian/gogoc/usr/share/gogoc/template

override_dh_fixperms:
	dh_fixperms
	chmod 600 debian/gogoc/etc/gogoc/gogoc.conf
