# -*- Makefile -*-
#
#  @configure_input@
#
# This file is NOT autogenerated, and need to be maintained.  Automake
# will generate the Makefile based on this file where all the
# appropiate variables are defined inside.
#
#
ACLOCAL_AMFLAGS  = -I m4

# Adding to SUBDIRS will automatically call/invoke the Makefile in
# these dirs
SUBDIRS = iptables-module collector

#man_MANS := xtables-addons.8

.PHONY: FORCE
FORCE:

#xtables-addons.8: FORCE
#	${MAKE} -f Makefile.mans all;

install-exec-hook:
	depmod -a || :;

#config.status: Makefile.iptrules.in

tmpdir := $(shell mktemp -dtu)
packer  = gzip
packext = .tar.gz

GIT_VERSION = $(shell if [ -d .git ]; then git describe; fi)

testver:
	@echo Detected GIT_VERSION:\"${GIT_VERSION}\"

.PHONY: tarball

#
# The tarball target is to be used together with the Git repository
#  and uses the git "version" provided by 'git describe'
#
tarball:
# do not use mkdir_p here.
	@if [ -z "${GIT_VERSION}" ]; then \
		echo " *** ERROR: Sorry target tarball require the git tree"; \
		exit 42;\
	else \
		echo " -- Creating tarball GIT version: ${GIT_VERSION}"; \
	fi
	@mkdir ${tmpdir}
	pushd ${top_srcdir} && git archive --prefix=${PACKAGE_NAME}-${GIT_VERSION}/ HEAD | tar -C ${tmpdir} -x && popd;
	pushd ${tmpdir}/${PACKAGE_NAME}-${GIT_VERSION} && ./autogen.sh && popd;
	tar --use=${packer} -C ${tmpdir} -cf ${PACKAGE_NAME}-${GIT_VERSION}${packext} --owner=root --group=root ${PACKAGE_NAME}-${GIT_VERSION}/;
	@rm -Rf ${tmpdir};
	@echo " -- Tarball ${PACKAGE_NAME}-${GIT_VERSION}${packext} ready"
