#!/usr/bin/env ruby

require 'find'

system("cd ext ; make distclean")

File.exist?('amatch.tgz') and File.unlink('amatch.tgz')
Dir.chdir('..')
list = []
Find.find('amatch') { |f|
	unless File.lstat(f).directory? or f =~ /CVS/ or f =~ /\/\./
		list << f
	end
}
list.empty? or system("tar cfvz amatch.tgz #{list.join ' '}")
File.rename('amatch.tgz', 'amatch/amatch.tgz')
