#!/usr/bin/make -f

%:
	dh $@

override_dh_auto_clean:

override_dh_auto_build:
	MANDIR=/usr/share/man DOCDIR=/usr/share/doc/opensysusers $(MAKE)

override_dh_auto_install:
	mkdir -p $(CURDIR)/debian/opensysusers/usr/share/man/man8
	PREFIX=/usr MANDIR=/usr/share/man DOCDIR=/usr/share/doc/opensysusers DESTDIR=$(CURDIR)/debian/opensysusers $(MAKE) install

	# These are too specific to artix-linux, and conflicting with
	# stuff from systemd, so let's remove them
	$(RM) $(CURDIR)/debian/opensysusers/usr/lib/sysusers.d/basic.conf

	# Rename the manpages to avoid a conflict with systemd
	mv $(CURDIR)/debian/opensysusers/usr/share/man/man5/sysusers.d.5 \
	  $(CURDIR)/debian/opensysusers/usr/share/man/man5/opensysusers.d.5
	mv $(CURDIR)/debian/opensysusers/usr/share/man/man8/systemd-sysusers.8 \
	  $(CURDIR)/debian/opensysusers/usr/share/man/man8/opensysusers-sysusers.8
	# no service file in opensysuser, so removing the link
	$(RM) $(CURDIR)/debian/opensysusers/usr/share/man/man8/systemd-sysusers.service.8

	# We move this away, so we can install the alternatives
	mv $(CURDIR)/debian/opensysusers/usr/bin/sysusers $(CURDIR)/debian/opensysusers/usr/bin/opensysusers-sysusers

override_dh_installinit:
	dh_installinit --no-start
