#!/usr/bin/make -f
#-*- Makefile -*-
# $Id: Makefile,v 1.4 2000/01/13 21:46:31 david Exp $

# Some of these "Reference" files are not used to build the package, 
# just to help a human modify the tasks file manually and/or
# communicate with relevant developers.

REFERENCE_FILES:=\
python-packages-available \
python-packages-summary \
python-packages-maintainers

# default target
build: local-build-stamp
.PHONY: build

local-build-stamp: debian/control
	touch local-build-stamp

# recreate debian/control when either of these has changed
debian/control: control.top control.generated.tasks
	cat $+ > $@

# the dependence on .py files here just makes my life easier while
# testing and changing them
control.generated.tasks: tasks $(REFERENCE_FILES) z.py modified_dpkg_packages.py 

	-rm -f control.generated.tasks
	./z.py 
# z.py reads tasks and reference files, appends to control.generated.tasks



# other targets

reference: $(REFERENCE_FILES)
.PHONY: reference

clean:
	rm -f *.pyc
	rm -f $(REFERENCE_FILES)
	rm -f control.generated.tasks
	rm -f local-build-stamp
.PHONY: clean


###REFERENCE FILES###

#all pacakges with "python" in name or description
# python-packages-apt-cache-search: /var/lib/dpkg/available
# 	apt-cache search python | sort > $@

# python-packages-apt-cache-search--full: /var/lib/dpkg/available
#	apt-cache --full search python > $@

python-packages-available: /var/lib/dpkg/available
#all packages with case-independent "python" in package name, description, or dependencies
	sgrep -i '(DEB_PKG containing ((DEB_PACKAGE or DEB_DEPENDS or DEB_RECOMMENDS or DEB_DESCRIPTION) containing "python"))' $< >$@

#all 'python'-named packages in the 'available' file
#python-packages-available: /var/lib/dpkg/available
#	grep-dctrl -i -FPackage python $< > $@

#all packages that depend on a 'python'-named package but are *not* 'python'-named
#python-dependent-packages-available: /var/lib/dpkg/available
#	sgrep '((DEB_PKG containing (DEB_DEPENDS containing "python")) containing (DEB_PACKAGE not containing "python"))' $< >$@
#	grep-dctrl -i -FDepends python $< | grep-dctrl -FPackage -v python > $@

#maintainers of python-named packages
python-packages-maintainers: python-packages-available
	grep '^Maintainer: ' $< | cut  -f2- -d\  | sort | uniq > $@

#maintainers of python-dependent packages
#python-dependent-package-maintainers: python-dependent-packages-available
#	grep '^Maintainer: ' $< | cut  -f2- -d\  | sort | uniq > $@

#summary (package, desription, dependencies) of packages
python-packages-summary: python-packages-available
#	grep '^Depends: \|^Package: \|^Description: ' $< | sed '/^Package: / { x ; p ; x ; }' > $@
	grep-dctrl -sPackage,Version,Depends,Recommends,Description '' $< >$@

#summary (package, desription, dependencies) of dependent packages
#python-dependent-packages-summary: python-dependent-packages-available
#	grep '^Depends: \|^Package: \|^Description: ' $< | sed '/^Package: / { x ; p ; x ; }' > $@
