#!/usr/bin/make -f
# Debian rules file for ebtables.
# Created by Jan Christoph Nordholz <hesso@pool.math.tu-berlin.de>,
# based on the debhelper templates.

MAKE_PATH_REDIRECTIONS:=LIBDIR=/lib/ebtables \
			BINDIR=/sbin \
			DESTDIR=debian/ebtables

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  DEBCFLAGS+=-O0
else
  DEBCFLAGS+=-O2
endif

build: build-stamp
build-stamp:
	dh_testdir
	make CFLAGS="$(DEBCFLAGS)" $(MAKE_PATH_REDIRECTIONS)
	touch build-stamp

clean:
	dh_testdir
	rm -f build-stamp
	make clean
	rm -f ebtables.8_ ebtables.sysv_ ebtables-config_ ebtables-save_
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs
	make install $(MAKE_PATH_REDIRECTIONS)
	rm -f debian/ebtables/sbin/ebtables-save debian/ebtables/sbin/ebtables-restore
	mv debian/ebtables/etc/default/ebtables-config debian/ebtables/etc/default/ebtables
	rm -f debian/ebtables/etc/init.d/ebtables
	mkdir -p debian/ebtables/usr/share/lintian/overrides
	cp debian/ebtables.override debian/ebtables/usr/share/lintian/overrides/ebtables

binary: binary-indep binary-arch
binary-indep: build install
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs ChangeLog
	dh_installinit -r -- start 30 S . stop 70 0 6 .
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	# Ignore warnings on /lib/ebtables libraries - they don't bear SONAMEs
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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