
stamp-configure: src/Configuration
	@if [ -f debian/Configuration.$(ARCH) ]; \
		then echo; cp -v debian/Configuration.$(ARCH) \
		src/Configuration; fi
	@echo; cd src && ./Configure && echo
	touch stamp-configure


.PHONY: install-perl binary-apache-doc binary-apache-dev check-apache-scripts


install-perl: $(modperl)/blib/arch/auto/Apache/Apache.so
	@echo -e "\n--- installing mod-perl ---\n"
	install -d debian/tmp/usr/lib/perl5/$(ARCH)-linux/5.004/auto/Apache
	install -d debian/tmp/usr/{lib/perl5/Apache,man/man3}
	cp $$(find $(modperl) -name "*.3pm") debian/tmp/usr/man/man3
	cp $$(find $(modperl) -name "*.so") \
		debian/tmp/usr/lib/perl5/$(ARCH)-linux/5.004/auto/Apache
	@cd debian/tmp/usr/lib/perl5/$(ARCH)-linux/5.004/auto/Apache && ( \
		for so in *.so; do \
			mod=$$(basename $$so .so); \
			touch $$mod.bs; \
			chmod 644 $$so; \
			case $$mod in ?pache) continue; esac; \
			( set -x ; \
				install -d $$mod; \
				mv $$mod.* $$mod; \
			); \
		done; \
	)
	cp -r $(modperl)/blib/lib/{A*,B*} debian/tmp/usr/lib/perl5
	rm -rf debian/tmp/usr/doc/$(package)/mod_perl
	cp -r $(modperl)/eg debian/tmp/usr/doc/$(package)/mod_perl


binary-apache-doc: 
	@echo -e "\n\n*** Package $(package)-doc\n"
	mkdir -p debian/doc/{DEBIAN,usr/doc/$(package)/examples}
	cp -r htdocs/* debian/doc/usr/doc/$(package)
	chown -R root.root debian/doc && chmod -R go=rX debian/doc
	dpkg-gencontrol -p$(package)-doc -Pdebian/doc
	dpkg --build debian/doc ..


binary-apache-dev:
	@echo -e "\n\n*** Package $(package)-dev\n"
	rm -rf debian/dev
	install -d debian/dev/{DEBIAN,usr/{doc,src/$(package)-$(version)}}
	install debian/$(package)-dev.postinst debian/dev/DEBIAN/postinst
	install debian/$(package)-dev.postrm debian/dev/DEBIAN/postrm
	install debian/$(package)-dev.preinst debian/dev/DEBIAN/preinst
	install debian/$(package)-dev.prerm debian/dev/DEBIAN/prerm
	ln -s $(package) debian/dev/usr/doc/$(package)-dev
	rm -f src/regexp && cp -a src/* debian/Makefile.modules \
		debian/dev/usr/src/$(package)-$(version)
	-cd debian/dev/usr/src/$(package)-$(version); make clean
	rm -f $$(find debian/dev -name "*.o" -o -name "httpd" \
		-o -name "*.a" -o -name "*.so")
	chown -R root.root debian/dev && chmod -R go=rX debian/dev
	dpkg-gencontrol -p$(package)-dev -Pdebian/dev
	dpkg --build debian/dev ..


check-apache-scripts:
	if grep "trap SIG" debian/{*.p*,*.d*,p*,*html}; then false; fi
	if grep "/var/web" debian/{*.p*,*.d*,p*,*html} src/*.c; then false; fi
	if grep "/home/www" debian/{*.p*,*.d*,p*,*html} src/*.c; then false; fi
	if grep "Authorative" debian/*info src/*.c}; then false; fi
	bash -n debian/$(package)-dev.postinst
	bash -n debian/$(package)-dev.postrm
	bash -n debian/$(package)-dev.preinst
	bash -n debian/$(package)-dev.prerm
	bash -n debian/cron.daily
	bash -n debian/init.d
	bash -n debian/preinst
	bash -n debian/postinst
	bash -n debian/prerm
	bash -n debian/postrm



.PHONY: check-apache-links install-apache-dirs


check-apache-links:
	-(cd ../common && ls) | xargs -t -i sh -c \
		"diff ../common/{} debian/{}"


install-apache-dirs:
	install -d debian/tmp/DEBIAN
	install -d debian/tmp/usr/{bin,sbin}
	install -d debian/tmp/usr/lib/cgi-bin
	install -d debian/tmp/etc/{cron.daily,init.d}
	install -d debian/tmp/usr/man/man{1,8} usr/sbin
	install -d debian/tmp/etc/$(package)
	install -d debian/tmp/usr/doc/$(package)/examples/cgi-bin
	install -d debian/tmp/usr/doc/$(package)/icons
	install -d debian/tmp/var/log/$(package)
	install -d debian/tmp/var/run/$(package)
	install -d debian/tmp/var/spool/$(package)












