#!/usr/bin/python
import sys
import os
import commands
import datetime

directory = sys.argv[1]
cwd = os.getcwd()
today = datetime.date.today()
release="%04d%02d%02d"%(today.year,today.month,today.day)

#clean
os.chdir("%s/src"%directory)
commands.getoutput("make distclean")
commands.getoutput("rm cscope.*")
commands.getoutput("rm -rf doc/latex")
commands.getoutput("rm -rf doc/html")
os.chdir("./testsuite")
commands.getoutput("make clean")

# release
os.chdir(cwd)
print commands.getoutput("cp -r %s/src m4ri-%s"%(directory,release))
print commands.getoutput("tar cvfz m4ri-%s.tar.gz m4ri-%s/"%(release,release)) 


