1VERSION = $(shell cat configure.in |grep INIT_AUTOMAKE |sed -e 's/.*,//;s/^ //;s/.$$//' )
2SRCDIR = $(shell pwd)
3
4all: autogen.sh configure.in
5	./autogen.sh
6
7grep-$(VERSION).tar:
8	[ -e configure.in ] || ( echo Must be run from grep source dir ; exit 1 )
9	rm -rf /tmp/grep-$(VERSION) && cp -aR $(SRCDIR) /tmp/grep-$(VERSION) && cd /tmp/grep-$(VERSION) && make -f Makefile.cvs cvs-clean && make -f Makefile.cvs && rm -rf autom4te.cache && (find . -type d -name CVS |xargs rm -rf) && cd .. && tar chf $(SRCDIR)/grep-$(VERSION).tar grep-$(VERSION)
10
11grep-$(VERSION).tar.bz2: grep-$(VERSION).tar
12	bzip2 -9f grep-$(VERSION).tar
13
14grep-$(VERSION).tar.gz: grep-$(VERSION).tar
15	gzip -9f grep-$(VERSION).tar
16
17rpm: grep-$(VERSION).tar.bz2
18	rpm -ts --define '_srcrpmdir $(SRCDIR)' grep-$(VERSION).tar.bz2
19
20# make cvs-clean blatantly stolen from KDE CVS ;)
21cvs-clean:
22	@if test ! -d CVS; then \
23	  echo "You don't have a toplevel CVS directory."; \
24	  echo "You most certainly didn't use cvs to get these sources."; \
25	  echo "But this function depends on cvs's information."; \
26	  exit 1 ;\
27	fi;\
28	pwd=`pwd` ;\
29	dirs=`find . -type d | grep -v CVS | sed -e "s#^./##"` ;\
30	for i in $$dirs; do \
31	  if test ! -d "$$pwd/$$i/CVS"; then \
32	    echo "D $$i" ;\
33	    rm -rf "$$pwd/$$i"; \
34	    continue; \
35	  fi ;\
36	  cd $$pwd/$$i ;\
37	  for f in * .*; do \
38	    if test ! -d "$$f"; then \
39	      if grep "^/$$f/" CVS/Entries > /dev/null; then \
40		a="b"; \
41	      else \
42	        echo "F $$i/$$f"; \
43		rm -f "$$pwd/$$i/$$f"; \
44	      fi; \
45	    fi ; \
46	  done; \
47	done
48