
# Makefile (man-pages-it)

LANG=it
OURMANDIR=/usr/man/$(LANG)

all:
	@echo "Fare \"make install\" per installare, o leggete \"INSTALL\""
	@echo "Please issue \"make install\", or look at \"INSTALL.eng\" first"
	@exit 1

install.dir:
	for i in man?; do \
		install -d -m 755 $(OURMANDIR)/$$i; \
	done

install: install.dir
	for i in man?; do \
		echo "Installing $$i"; \
		install -m 644 $$i/* $(OURMANDIR)/$$i; \
	done

# questo mi sembra abbastanza veloce, ma da` messaggi ogni tanto
install.gz: install.dir
	for i in man?; do \
		echo "Installing $$i"; \
		install -m 644 $$i/* $(OURMANDIR)/$$i; \
		files=`ls $$i/*[0-9] 2> /dev/null`; \
		if [ "x$$files" != "x" ]; then \
			echo "Compressing $$i"; \
			(cd $(OURMANDIR) && gzip -f $$files); \
		fi; \
	done

gz gzip:
	gzip man?/*[0-9]

gunzip:
	gunzip man?/*.gz

# fare cosi` e` il piu` veloce che ho trovato (meno processi in gioco)
uninstall remove:
	@echo "Removing files from $(OURMANDIR):"
	@files=`ls man?/* | sed 's/.gz$$//'`; \
	filesgz=`ls man?/* | sed -e 's/.gz$$//' -e 's/$$/.gz/'`; \
	(cd $(OURMANDIR) && rm -f $$files $$filesgz)

forceinstall: uninstall install

forceinstall.gz: uninstall install.gz


######################## Queste regole, invece le uso io per la mia
######################## manutenzione del pacchetto.

distrib tar: clean
	n=`basename \`/bin/pwd\``; cd ..; tar cvf - $$n | gzip > $$n.tar.gz


LIST = ../wholemanlist
FILES = $(wildcard man?/*)
PAGES = $(FILES:.gz=)

clean:
	rm -f current* whole* missing* *~ */*~
	rm -rf packages
	chmod -R +rw .; chmod -R g-w .

current: man? $(LIST)
	rm $@; touch $@
	for n in $(PAGES); do \
		grep -i /$$n $(LIST) >> $@ || echo "*** unknown $$n"; \
	done

whole:
	cp $(LIST) $@

%.sorted: %
	sort $^ | uniq | sed 's/: .*[0-9]\//: /' > $@

%.oneline: %.sorted
	awk '$$1!=S {printf "\n%s",$$1; S=$$1} {printf " %s",$$2}' $^ > $@

checkpkg: current.oneline whole.oneline
	for n in `cut -f 1 current.oneline`; do \
		grep $$n $^ | sed 's/^.*://' ; echo ""; \
	done

	
whois: current.oneline
	pages=`grep $(PKG): $^ | sed 's/^.*://'`; \
	for n in $$pages; do grep -i tradu */$$n; done; \
	echo ""; echo "used $$pages"


packages:
	mkdir packages
	for n in tags/*; do \
	   name=`basename $$n`; \
	   itname=$$name; \
	   tmp=packages/$$itname; \
	   echo "Processing $$n"; \
	   set +x; \
	   pages=`awk '/ENDTAGS/ {exit;} \
	      /Pagine:/ {for (N=2; N<=NF; N++) \
	      printf("man?/%s\n",$$N);}' $$n`; \
	   if [ -z "$$pages" ]; then continue; fi; \
	   echo "  Including `echo $$pages | wc -w` pages"; \
	   mkdir $$tmp; cp README* INSTALL* Makefile tags/$$name* $$tmp; \
	   tar cf - $$pages | (cd $$tmp && tar xf -); \
	   (cd $$tmp; for n in `ls man?/*.[1-8]? 2> /dev/null`; do \
		mv $$n `echo $$n | sed 's/.$$//'`; done); \
	   (cd packages; tar czf $$itname.tar.gz $$itname); \
	   rm -rf $$tmp; \
	   set +x; \
	done
