#!/usr/bin/make -f
# Generated automatically from debian/packages
# by yada v0.15, of Wed, 23 Jul 2003

DEB_HOST_ARCH        := $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_CPU     := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
DEB_HOST_GNU_TYPE    := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_HOST_GNU_SYSTEM  := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)

DEB_BUILD_ARCH       := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_BUILD_GNU_CPU    := $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
DEB_BUILD_GNU_TYPE   := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_BUILD_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)

VERSION:=$(shell LC_ALL=C dpkg-parsechangelog | sed -ne 's/^Version: *\([^2]*\)/\1/p')

SHELL=/bin/bash

.PHONY: default
default:
	@echo "Specify a target:"; \
	echo " build              compile the package"; \
	echo " build-arch         compile the architecture-dependent package"; \
	echo " build-indep        compile the architecture-independent package"; \
	echo " binary             make all binary packages"; \
	echo " binary-arch        make all architecture-dependent binary packages"; \
	echo " binary-indep       make all architecture-independent binary packages"; \
	echo " clean              clean up the source package"; \
	echo; \
	echo " clean-install-tree clean up only under debian/"; \
	echo

# Build the package and prepare the install tree

.PHONY: build-only build
build-only: debian/build-stamp
build: chmod-yada build-only

.PHONY: build-arch-only build-arch
build-arch-only: debian/build-arch-stamp
build-arch: chmod-yada build-arch-only

.PHONY: build-indep-only build-indep
build-indep-only: debian/build-indep-stamp
build-indep: chmod-yada build-indep-only

# Make sure these rules and the control file are up-to-date

.PHONY: rules control templates
rules: debian/rules
debian/rules: $(shell which yada) debian/packages-tmp
	$(shell which yada) rebuild rules

control: debian/control
debian/control: $(shell which yada) debian/packages-tmp
	$(shell which yada) rebuild control

templates: debian/templates
debian/templates: $(shell which yada) debian/packages-tmp
	$(shell which yada) rebuild templates

debian/build-stamp: debian/build-arch-stamp debian/build-indep-stamp
	@[ -f $(shell which yada) -a -f debian/rules ]
	@umask 022 \
	  && export pwd="$$(pwd)" \
	  && export TMPROOT="$$(pwd)/debian/tmp" \
	  && export SOURCE="securecgi" \
	  && export VERSION="$(VERSION)" \
	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'CC=$${CC:-gcc}';\
	echo -E 'CFLAGS="$${CFLAGS:--Wall -g -fsigned-char}"';\
	echo -E 'LDFLAGS=$$LDFLAGS';\
	echo -E 'if [ "$${DEB_BUILD_OPTIONS#*noopt}" != "$$DEB_BUILD_OPTIONS" ]; then';\
	echo -E '     CFLAGS="$$CFLAGS -O0"';\
	echo -E 'else';\
	echo -E '     CFLAGS="$$CFLAGS -O2"';\
	echo -E 'fi';\
	echo -E 'aclocal-1.7';\
	echo -E 'autoheader';\
	echo -E 'automake-1.7 --add-missing --copy';\
	echo -E 'autoconf';\
	echo -E 'CFLAGS="$$CFLAGS" LDFLAGS="$$LDFLAGS" CC="$$CC" ./configure \';\
	echo -E '    --prefix=/usr --bindir=/usr/lib/cgi-bin --mandir=/usr/share/man';\
	echo -E 'make') | /bin/sh
	touch debian/build-stamp

debian/build-arch-stamp:
	@[ -f $(shell which yada) -a -f debian/rules ]
	touch debian/build-arch-stamp

debian/build-indep-stamp:
	@[ -f $(shell which yada) -a -f debian/rules ]
	touch debian/build-indep-stamp

.PHONY: install-tree
install-tree: chmod-yada install-tree-any
install-tree-any: \
	debian/tmp-securecgi/DEBIAN/control

debian/tmp-securecgi/DEBIAN/control: debian/build-stamp debian/control
	rm -rf debian/tmp-securecgi
	umask 022 && install -d debian/tmp-securecgi/DEBIAN
	install -d debian/tmp-securecgi/usr/share/doc/securecgi
	umask 022; $(shell which yada) generate copyright \
	  > debian/tmp-securecgi/usr/share/doc/securecgi/copyright
	install -m 644 -p debian/changelog \
	  debian/tmp-securecgi/usr/share/doc/securecgi/changelog
	@umask 022 \
	  && export pwd="$$(pwd)" \
	  && export ROOT="$$(pwd)/debian/tmp-securecgi" \
	  && export TMPROOT="$$(pwd)/debian/tmp" \
	  && export CONTROL="$$(pwd)/debian/tmp-securecgi/DEBIAN" \
	  && export PACKAGE="securecgi" \
	  && export SOURCE="securecgi" \
	  && export VERSION="$(VERSION)" \
	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'make install DESTDIR=$$ROOT';\
	echo -E 'yada install -doc -as NEWS.Debian -gzip debian/NEWS') | /bin/sh
	@umask 022 \
	  && export pwd="$$(pwd)" \
	  && export ROOT="$$(pwd)/debian/tmp-securecgi" \
	  && export TMPROOT="$$(pwd)/debian/tmp" \
	  && export CONTROL="$$(pwd)/debian/tmp-securecgi/DEBIAN" \
	  && export PACKAGE="securecgi" \
	  && export SOURCE="securecgi" \
	  && export VERSION="$(VERSION)" && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'yada strip';\
	echo -E 'yada shlibdeps') | /bin/sh
	$(shell which yada) compress securecgi
	$(shell which yada) generate maintscripts securecgi
	find debian/tmp-securecgi -type f -print \
	  | sed -n 's/^debian\/tmp-securecgi\(\/etc\/.*\)$$/\1/p' \
	  > debian/tmp-securecgi/DEBIAN/conffiles
	if test ! -s debian/tmp-securecgi/DEBIAN/conffiles; then rm -f debian/tmp-securecgi/DEBIAN/conffiles; fi
	$(shell which yada) rebuild control
	$(shell which yada) generate substvars securecgi
	umask 022 && dpkg-gencontrol -isp -psecurecgi -Pdebian/tmp-securecgi

# Build package files

.PHONY: binary binary-arch binary-indep
binary: binary-arch binary-indep
binary-arch: chmod-yada binary-arch-any

.PHONY: binary-arch-any
binary-arch-any: \
	binary-package-securecgi
binary-indep: chmod-yada

.PHONY: binary-package-securecgi
binary-package-securecgi: check-root debian/tmp-securecgi/DEBIAN/control
	@[ -f $(shell which yada) -a -f debian/rules ]
	chown -R 0.0 debian/tmp-securecgi
	chmod -R u=rwX,go=rX debian/tmp-securecgi
	@umask 022 \
	  && export pwd="$$(pwd)" \
	  && export ROOT="$$(pwd)/debian/tmp-securecgi" \
	  && export TMPROOT="$$(pwd)/debian/tmp" \
	  && export CONTROL="$$(pwd)/debian/tmp-securecgi/DEBIAN" \
	  && export PACKAGE="securecgi" \
	  && export SOURCE="securecgi" \
	  && export VERSION="$(VERSION)" \
	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'chmod u+s $$ROOT/usr/lib/cgi-bin/securecgi';\
	echo -E 'chmod u+s $$ROOT/usr/lib/cgi-bin/nph-securecgi') | /bin/sh
	@if [ -d debian/tmp-securecgi/usr/doc/securecgi ]; then \
	  echo "*** Yada warning: /usr/doc/securecgi should be /usr/share/doc/securecgi";\
	fi
	dpkg-deb --build debian/tmp-securecgi ..

.PHONY: check-root
check-root:
	@[ `id -u` = 0 ] || (echo "You must be root to do this!"; false)

.PHONY: chmod-yada
chmod-yada:
	@if [ -f debian/yada -a ! -x debian/yada ]; then \
	  chmod +x debian/yada; \
	fi

debian/packages-tmp: debian/packages 
	$(shell which yada) rebuild packages

## Clean up afterwards

.PHONY: clean clean-install-tree clean-build

clean: chmod-yada clean-install-tree clean-build debian/control debian/rules
	rm -f debian/packages-tmp debian/packages-tmp-new debian/packages-tmp-include

clean-build:
	@[ -f $(shell which yada) -a -f debian/rules ]
	rm -f debian/build-stamp debian/build-arch-stamp debian/build-indep-stamp
	@umask 022 \
	  && export pwd="$$(pwd)" \
	  && export TMPROOT="$$(pwd)/debian/tmp" \
	  && export SOURCE="securecgi" \
	  && export VERSION="$(VERSION)" \
	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
	echo -E 'make distclean || make clean || true';\
	echo -E 'for i in $$(find -name .cvsignore); do';\
	echo -E '    ( cd $$(dirname $$i) && rm -rf $$(cat .cvsignore) )';\
	echo -E 'done') | /bin/sh
	$(shell which yada) unpatch
	rm -rf debian/tmp

clean-install-tree: chmod-yada debian/rules
	@[ -f $(shell which yada) -a -f debian/rules ]
	rm -f debian/install-tree-stamp
	rm -rf debian/tmp-* debian/files* debian/substvars debian/shlibs.local
