#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

export PYBUILD_NAME=djangorestframework

%:
	dh $@ --buildsystem=pybuild

ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
execute_after_dh_auto_build:
	# Build the HTML documentation.
	mkdir $(CURDIR)/docs.debian
	LC_ALL=C.UTF-8 PYTHONPATH=/usr/share/mkdocs/themes mkdocs build -v && mv site docs.debian/html
	$(RM) docs.debian/html/404.html
	$(RM) docs.debian/html/fonts/*
endif

execute_after_dh_python3:
	# Don't embed what's already provided elsewhere
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/fonts/*
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/css/font-awesome*.css
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/css/bootstrap*.min.css
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/css/prettify*.css
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/js/bootstrap*.js
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/js/jquery*.js
	$(RM) debian/python3-djangorestframework/usr/lib/python3/dist-packages/rest_framework/static/rest_framework/js/prettify*.js

execute_after_dh_auto_clean:
	rm -rf docs.debian
	rm -rf .mypy_cache

override_dh_installchangelogs:
	dh_installchangelogs docs/community/release-notes.md

override_dh_mkdocs:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	dh_mkdocs
endif

override_dh_installdocs:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	dh_installdocs -ppython-djangorestframework-doc --doc-main-package=python3-djangorestframework
	dh_installdocs --remaining-packages
endif
