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

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

include /usr/share/dpkg/default.mk

export GEM2DEB_TEST_RUNNER = --check-dependencies

ifneq (,$(findstring $(DEB_BUILD_ARCH), armel m68k mips mipsel powerpc powerpcspe sh4))
export DEB_LDFLAGS_MAINT_APPEND  = -latomic
endif

SONAME=5
API_VERSION=$(SONAME)-0
PACKAGEVERSION = $(shell debian/get_ver.sh 'libzmq$(SONAME)-zendphp' '4.3.4')

%:
	dh $@ --with autoreconf || dh $@

ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
override_dh_auto_configure:
	dpkg-architecture -f -a$(DEB_BUILD_ARCH) -c dh_auto_configure

endif

PREFIX		  = /opt/zend/zendphp

override_dh_auto_configure: 
	export LDFLAGS= ; \
	export CFLAGS= ; \
	export CPPFLAGS= ; \
	export CXXFLAGS= ; \
	dh_auto_configure -- --enable-static --disable-shared --prefix=$(PREFIX) --libdir=$(PREFIX)/lib --with-zlib --disable-Werror CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC

override_dh_auto_build:
	dh_auto_build

override_dh_auto_clean:
	dh_auto_clean || true

override_dh_auto_test:
	:

override_dh_auto_install:
	dh_auto_install
	mkdir -p $(CURDIR)/debian/tmp/usr/lib && mv $(CURDIR)/debian/tmp/$(PREFIX)/lib/pkgconfig $(CURDIR)/debian/tmp/usr/lib
	dh_install

override_dh_installdocs:
	dh_installdocs

override_dh_gencontrol:
	dh_gencontrol -- -Vpb:API=${API_VERSION} -v$(PACKAGEVERSION)

override_dh_dwz:
	echo GCC bug

#override_dh_usrlocal:
#	echo Skip processing /usr/local	

