#!/usr/bin/make -f

# Include _SOLARIS_ flag for byteorder.h.patch's ifdef to work
CFLAGS += -D_SOLARIS_ -g -gdwarf-2 -fno-omit-frame-pointer
CXXFLAGS += -D_SOLARIS_ -g -gdwarf-2 -fno-omit-frame-pointer
LDFLAGS += -lsocket -lnsl

ifeq ($(DEB_HOST_ARCH),solaris-i386)
CFLAGS += -msave-args
endif
#ifeq ($(DEB_HOST_ARCH),solaris-sparc)
#endif

export CFLAGS CXXFLAGS LDFLAGS

TMP=$(CURDIR)/debian/tmp/

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

override_dh_auto_configure:
	dh_auto_configure -- --enable-jobserver=no \
		ax_cv_check_cflags__Werror__fPIE=no \
		ax_cv_check_cflags__Werror__pie=no \
		ax_cv_check_cxxflags__Werror__fPIE=no \
		ax_cv_check_cxxflags__Werror__pie=no

override_dh_auto_install:
	dh_auto_install
	# Naming conflict: rename commandline programs
	for memfile in $(TMP)/usr/bin/mem*; do \
		mv $$memfile `echo $$memfile | sed 's/\bmem/memc/'` ; \
	done

override_dh_installman:
	dh_installman
	# Naming conflict: rename commandline programs
	for memfile in debian/libmemcached-tools/usr/share/man/man1/mem*.1; do \
		mv $$memfile `echo $$memfile | sed 's/\bmem/memc/'` ; \
	done

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog

override_dh_strip:
	dh_strip --dbg-package=libmemcached-dbg \
		--no-ctfconvert=libmemcached.so.11.0.0 \
		--no-ctfconvert=libmemcachedutil.so.2.0.0 \
		--no-ctfconvert=libhashkit.so.2.0.0 \
		--no-ctfconvert=memcexist \
		--no-ctfconvert=memcslap \
		--no-ctfconvert=memcrm \
		--no-ctfconvert=memccat \
		--no-ctfconvert=memcerror \
		--no-ctfconvert=memcdump \
		--no-ctfconvert=memcflush \
		--no-ctfconvert=memccapable \
		--no-ctfconvert=memctouch \
		--no-ctfconvert=memccp \
		--no-ctfconvert=memcparse \
		--no-ctfconvert=memcping \
		--no-ctfconvert=memcstat \

override_dh_auto_test:

get-orig-source:
	uscan --verbose --force-download --rename --repack --destdir=..
