#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))

# link to libatomic on armel and mipsel
ifneq (,$(filter $(DEB_HOST_ARCH), armel mipsel))
  export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
endif

include /usr/share/dpkg/default.mk  # provides DEB_VERSION

%:
	dh $@

override_dh_auto_clean:
	scons -c
	rm -rf .sconf_temp config.log debian/goxel.1 goxel.xpm goxel.png
	rm -rf .sconsign.dblite

override_dh_auto_build:
	scons cycles=0 mode=release werror=0 clang=1 --jobs=$(NUMJOBS) --no-cache
	cp -a ./osx/goxel/goxel/Assets.xcassets/AppIcon.appiconset/64.png ./goxel.png

override_dh_installman:
	help2man -N --no-discard-stderr \
		--no-info --version-string="$(DEB_VERSION)" \
		-n "3D voxel editor" ./goxel > debian/goxel.1
	dh_installman ./debian/goxel.1

override_dh_usrlocal:
	true

override_dh_auto_install:
	PREFIX=/usr dh_auto_install
