static function archiveDir( $sourcedir, $archivefile, $no_top_dir=false )
    {
        // please tar cmd on win - OH MY!

        $archivefile = str_replace( '\\', '/', $archivefile );
        $sourcedir = str_replace( '\\', '/', realpath( $sourcedir ) );

        if( $no_top_dir )
        {
            $srcdir = '.';
            $workdir = $sourcedir;
        }
        else
        {
            $srcdir = basename( $sourcedir );
            $workdir = dirname( $sourcedir );
        }
        $archivedir = dirname( $archivefile );
        $extra = '';

        $tar = self::getTool( 'tar' );

        if ( substr( $archivefile, -7 ) == '.tar.gz' || substr( $archivefile, -4 ) == '.tgz' )
        {
            $cmd = "$tar -z -cvf";
            $extra = "-C " . escapeshellarg( $workdir );
            $workdir = $archivedir;
            $archivefile = basename( $archivefile );
        }
        else if ( substr( $archivefile, -8 ) == '.tar.bz2' )
        {
            $cmd = "$tar -j -cvf";
            $extra = "-C " . escapeshellarg( $workdir );
            $workdir = $archivedir;
            $archivefile = basename( $archivefile );
        }
        else if ( substr( $archivefile, -4 ) == '.tar' )
        {
            $cmd = "$tar -cvf";
            $extra = "-C " . escapeshellarg( $workdir );
            $workdir = $archivedir;
            $archivefile = basename( $archivefile );
        }
        else if ( substr( $archivefile, -4 ) == '.zip' )
        {
            $zip = self::getTool( 'zip' );
            $cmd = "$zip -9 -r";
        }
        else
        {
            throw new pakeException( "Can not determine archive type from filename: $archivefile" );
        }

        pake_sh( self::getCdCmd( $workdir ) . " && $cmd $archivefile $extra $srcdir" );

        pake_echo_action( 'file+', $archivefile );
    }