#!/usr/bin/make -f

#export DH_VERBOSE=1

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
    MAKEFLAGS += -j$(NUMJOBS)
endif


configure: configure-stamp
configure-stamp:
	dh_testdir

	./configure $(CROSS) \
	    --prefix=/usr \
	    --with-system-pgm \
	    CFLAGS="$(CFLAGS)" \
	    LDFLAGS="-Wl,--as-needed -Wl,-z,defs" \

	touch configure-stamp

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp

build-stamp: configure-stamp
	dh_testdir

	$(MAKE) $(MAKEFLAGS)

	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp

	if [ -e Makefile ]; then make distclean; fi

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install


binary-indep: build install

binary-arch: build install
	sed -i "/dependency_libs/ s/'.*'/''/" `find . -name '*.la'`
	dh_testdir
	dh_testroot
	dh_install -X/usr/share/man --fail-missing
	dh_installman
	dh_installchangelogs
	dh_installdocs
	dh_lintian
	dh_link
	dh_strip --dbg-package=libzmq-dbg
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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

# vim: set filetype=make
