#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2011 IOhannes m zmölnig <zmoelnig@iem.at>
#
# Description: Main Debian packaging script for assimp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

## assimp-utils depends on libassimp3
binary/assimp-utils:: binary/libassimp3

# trying to get clean done
.PHONY: cleanbuilddir-force
cleanbuilddir-force:
	-$(if $(call cdbs_streq,$(DEB_BUILDDIR),$(DEB_SRCDIR)),,rm -rf $(DEB_BUILDDIR))
	mkdir -p $(DEB_BUILDDIR)

cleanbuilddir:: cleanbuilddir-force



include /usr/share/cdbs/1/rules/upstream-tarball.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/cmake.mk
include /usr/share/cdbs/1/rules/utils.mk

# provides a means to handle "size_t" on different architectures
#  on i386 (size_t)==(unsigned int), whereas on amd64 (size_t)==(unsigned long)
include /usr/share/pkg-kde-tools/makefiles/1/cdbs/symbolshelper.mk

DEB_PYTHON_SETUP_CMD = debian/setup.py
include /usr/share/cdbs/1/class/python-distutils.mk

LDFLAGS+=-Wl,--as-needed

## to get new sources, use
## $ debian/rules get-orig-source
DEB_UPSTREAM_URL = http://downloads.sourceforge.net/assimp
DEB_UPSTREAM_TARBALL_EXTENSION = zip
DEB_UPSTREAM_TARBALL_BASENAME = $(DEB_UPSTREAM_PACKAGE)--$(DEB_UPSTREAM_TARBALL_VERSION)-sdk

DEB_UPSTREAM_REPACKAGE_EXCLUDES = ./lib/
DEB_UPSTREAM_REPACKAGE_EXCLUDES += ./bin/
DEB_UPSTREAM_REPACKAGE_EXCLUDES += ./test/models-nonbsd/

DEB_UPSTREAM_TARBALL_MD5 = 9f41662501bd9d9533c4cf03b7c25d5b

# In order to regenerate 'debian/control' :
#    DEB_AUTO_UPDATE_DEBIAN_CONTROL=yes fakeroot debian/rules clean
# Then check manually if everything's ok

# Suppress scanning documentation images causing false alarms.
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^((Documentation|CommandLine).chm|tools\/assimp_view\/(base\.PNG|HUD\.png)|tools\/shared\/(default_icon\.xcf|assimp_tools_icon\.png)|port\/Assimp\.NET\/CSharpViewerScreenShot\.PNG|doc\/AssimpCmdDoc_Html\/(dragonsplash\.png|AssimpCmdDoc.chm)|doc\/AssimpDoc_Html\/(dragonsplash\.png|AssimpDoc.chm)|debian/(changelog|copyright(|_hints|_newhints)))$


DEB_DH_MAKESHLIBS_ARGS_ALL := -- -v$(DEB_UPSTREAM_VERSION)

DEB_CMAKE_EXTRA_FLAGS=-DASSIMP_BUILD_ARCHITECTURE=$(DEB_HOST_ARCH) \
	-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--version-script=$(CURDIR)/debian/libassimp3.ver $(LDFLAGS)" \
	-DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)" \
	-DBUILD_ASSIMP_SAMPLES=OFF

build/libassimp-doc::
	cd doc && doxygen Doxyfile

build/assimp-utils::
	cd doc && doxygen Doxyfile_Cmd

install/libassimp-doc::
	install -d $(cdbs_curdestdir)/usr/share/doc/libassimp-doc/samples/SimpleOpenGL
	install -T debian/Makefile.samples \
		$(cdbs_curdestdir)/usr/share/doc/libassimp-doc/samples/SimpleOpenGL/GNUmakefile


.PHONY: cleandoxydocs
clean:: cleandoxydocs
cleandoxydocs:
	rm -rf doc/AssimpCmdDoc_Html_tmp/
	rm -rf doc/AssimpDoc_Html_tmp/

