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

clean:
	dh_testdir
	dh_clean
	rm -f debian/files || true

build:
	./bootstrap
	./configure CPPFLAGS=-Wno-cpp --without-ntfs-3g
	make
	pwd
	ls -la
	WORKDIR=$(pwd)
	echo "Building wimlib in ${WORKDIR}"
	ROOT_DIR_PATH=$(pwd)/rootfs
	echo "Creating rootfs directory at ${ROOT_DIR_PATH}"
	mkdir -p /tmp/wimlib
	echo "Build successful."
	echo "Installing files to /tmp/wimlib..."
	ls -la /tmp/wimlib
	make install DESTDIR=/tmp/wimlib
	ls -la /tmp/wimlib
	echo "Files copied to rootfs."
	mkdir -p rootfs
	cp -a /tmp/wimlib/* rootfs/
	ls -la rootfs

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	
	$(eval sys_arch=$(shell dpkg --print-architecture))
	if [ -d rootfs ]; then cp -a rootfs/* debian/wimlib/; fi;
	if [ -d rootfs-$(sys_arch) ]; then cp -a rootfs-$(sys_arch)/* debian/wimlib/; fi;
	
	dh_install

binary-indep: install
	dh_testdir -i
	dh_installdebconf
	dh_installchangelogs
	dh_installdocs
	dh_md5sums
	dh_gencontrol
	dh_installdeb
	dh_builddeb

binary: binary-indep
build:
.PHONY: clean binary-indep binary install build
