#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules for cimg-dev package
# GNU copyright 2009 Andreas Tille <tille@debian.org>

pkg=cimg-dev
examples=cimg-examples
doc=cimg-doc

%:
	dh $@

override_dh_compress:
	dh_compress --exclude=.shtml \
	            --exclude=.pdf \
	            --exclude=.h \
	            --exclude=.cpp \
	            --exclude=.bmp \
	            --exclude=.pgm \
	            --exclude=.ppm \
	            --exclude=Makefile \
	            --exclude=.raw \
	            --exclude=.gmic

override_dh_installdocs:
	dh_installdocs
	find debian/cimg-doc -type f -name "*.html" -exec debian/remove_privacy_violating_js_code \{\} \;

override_dh_auto_test:
	cd examples && $(MAKE) Mlinux "LDFLAGS=-lm -lpthread -lHalf"
	# After test build of examples remove remaining object files
	cd examples && $(MAKE) clean

CHANGEFILES=gaussian_fit1d.cpp \
            use_RGBclass.cpp

override_dh_install:
	dh_install
	# In gaussian_fit1d.cpp the files is included into itself and thus the current directory needs to be in include path
	cd debian/$(examples)/usr/share/doc/$(pkg)/examples; \
	    sed -i 's?\(CFLAGS[[:space:]=]*-I\)\.\. -Wall -W?\1`pwd` -Wall -W?' Makefile; \
	    for file in $(CHANGEFILES) ; do \
		sed -i "s?#define cimg_plugin \"examples/$$file\"?#define cimg_plugin \"$$file\"?" $$file ; \
	    done

override_dh_auto_clean:
	-cd examples && $(MAKE) clean
	dh_clean 

get-orig-source:
	uscan --verbose --rename --repack --force-download --repack-compression xz
