#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

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


%:
	dh $@


FAILBOOTDIR = $(CURDIR)/debian/partclone/usr/share/partclone
MAN8DIR = $(CURDIR)/debian/partclone/usr/share/man/man8

override_dh_auto_configure:
	./autogen
	# disable reiserfs
	dh_auto_configure -- --prefix=/usr --enable-ncursesw \
		--enable-xfs \
		--enable-extfs \
		--disable-reiserfs \
		--enable-reiser4 \
		--enable-hfsp \
		--enable-apfs \
		--enable-fat \
		--enable-exfat \
		--enable-ntfs \
		--disable-ufs \
		--disable-vmfs \
		--disable-jfs \
		--enable-btrfs \
		--enable-minix \
		--enable-f2fs \
		--disable-nilfs2


override_dh_clean: # keep the special file fail-mbr/fail-mbr.bin.orig
	dh_clean
	# for some reason, dh_clean kills .orig files,
	# so we restore fail-mbr.bin.orig
	cp debian/fail-mbr.bin fail-mbr/fail-mbr.bin.orig
	# remove files generated by autogen and no removed by
	# dh_clean
	rm -f depcomp missing compile
	rm -f Makefile.in
	rm -f aclocal.m4
	rm -f config.h.in
	rm -f configure
	rm -f config.log
	rm -f docs/Makefile.in
	rm -f fail-mbr/Makefile.in
	rm -f ltmain.sh
	rm -rf m4/
	rm -f src/Makefile.in
	rm -f tests/Makefile.in


override_dh_auto_test:
	echo Skipping tests.

override_dh_auto_install:
	dh_auto_install
	install -d $(FAILBOOTDIR)
	cp fail-mbr/fail-mbr.bin $(FAILBOOTDIR)
	install -d $(MAN8DIR)
	cd $(MAN8DIR); \
	  ln -s partclone.fat.8.gz partclone.vfat.8.gz; \
	  ln -s partclone.fat.8.gz partclone.fat12.8.gz; \
	  ln -s partclone.fat.8.gz partclone.fat16.8.gz; \
	  ln -s partclone.fat.8.gz partclone.fat32.8.gz; \
	  ln -s partclone.hfsp.8.gz partclone.hfs+.8.gz; \
	  ln -s partclone.hfsp.8.gz partclone.hfsplus.8.gz; \
	  ln -s partclone.extfs.8.gz partclone.ext2.8.gz; \
	  ln -s partclone.extfs.8.gz partclone.ext3.8.gz; \
	  ln -s partclone.extfs.8.gz partclone.ext4.8.gz; \
	  ln -s partclone.extfs.8.gz partclone.ext4dev.8.gz