Index: SConstruct
===================================================================
--- SConstruct	(revision 226)
+++ SConstruct	(revision 232)
@@ -1,19 +1,24 @@
+import sys
+import os
+
 cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64 -DREGFI_WIN32'
 
-libiconv_path='win32/libiconv/'
-libpthreads_path='win32/libpthreads/'
+libiconv_path='.export/win32/libiconv/'
+libpthreads_path='.export/win32/libpthreads/'
 libpthread_name='pthreadGC2'
-libtalloc_path='win32/libtalloc/'
+libtalloc_path='.export/win32/libtalloc/'
 
-source_targets=('reglookup-src-trunk.tar.gz',)
-win32_targets=('reglookup-win32-trunk.zip',)
-doc_targets=('reglookup-doc-trunk.tar.gz',)
-all_targets = source_targets+win32_targets+doc_targets 
+source_targets=('src-trunk',)
+win32_targets=('win32-trunk',)
+doc_targets=('doc-trunk',)
+all_targets = source_targets+win32_targets+doc_targets
 
-def target2version(target):
+
+
+def parse_target(target):
     chunks = target.split('-')
-    if len(chunks) != 3:
+    if len(chunks) != 2:
         return None
-    return chunks[2].split('.')[0]
+    return chunks
 
 def version2input(version):
@@ -24,14 +29,27 @@
 
 
-source_cmds='''
-rm -rf .release;
-svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/$SOURCE .release/%s;
-cd .release/%s && scons doc
-cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
-mv .release/%s.tar.gz . && rm -rf .release
+export_cmds='''
+rm -rf .export
+svn export --depth files svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup .export
+svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/doc .export/doc
+svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/win32 .export/win32
+svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/%s .export/%s
 '''
 
+version_cmds='''
+echo 'REGFI_VERSION="%s"' > .export/%s/regfi_version.py
+'''
+
+cleanup_cmds='''
+rm -rf .export
+'''
+
+source_cmds='''
+cd %s && scons doc
+mv %s %s && tar cf %s.tar %s && gzip -9 %s.tar;
+'''+cleanup_cmds
+
 win32_cmds='''
-rm -rf .release && mkdir -p .release/%s/python/pyregfi
+mkdir -p .release/%s/python/pyregfi
 cp %s/src/*.exe .release/%s
 
@@ -39,31 +57,28 @@
 cp %s/python/pyregfi/*.py .release/%s/python/pyregfi
 
-cp win32/libiconv/bin/*.dll win32/libpthreads/bin/*.dll win32/libtalloc/bin/*.dll trunk/lib/*.dll .release/%s
+cp .export/win32/libiconv/bin/*.dll .export/win32/libpthreads/bin/*.dll .export/win32/libtalloc/bin/*.dll trunk/lib/*.dll .release/%s
 cd .release && zip -r %s.zip %s
 mv .release/%s.zip . && rm -rf .release
-'''
+'''+cleanup_cmds
 
 doc_cmds='''
-rm -rf .release;
-svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/ .release;
-cd .release && doxygen Doxyfile.regfi
-cd .release && doxygen Doxyfile.pyregfi
-mv .release/doc .release/%s
-cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
-mv .release/%s.tar.gz . && rm -rf .release
-'''
+cd .export && doxygen Doxyfile.regfi
+cd .export && doxygen Doxyfile.pyregfi
+mv .export/doc .export/%s
+cd .export && tar cf %s.tar %s && gzip -9 %s.tar
+mv .export/%s.tar.gz .
+'''+cleanup_cmds
 
 def generate_cmds(source, target, env, for_signature):
     ret_val = ''
+    input_prefix = str(source[0])+'/'
+
     for t in target:
-        t = str(t)
-        t_base = t.split('.tar.gz')[0].split('.zip')[0]
-        if t in source_targets:
-            ret_val += source_cmds % (t_base,t_base,t_base,
-                                      t_base,t_base,t_base)
-        elif t in win32_targets:
-            version = target2version(t)
-            input_prefix = version2input(version)
+        ttype,version = parse_target(str(t))
+        t_base = 'reglookup-%s-%s' % (ttype, version)
 
+        if ttype == 'src':
+            ret_val += source_cmds % (input_prefix, input_prefix, t_base, t_base, t_base, t_base)
+        elif ttype == 'win32':
             env['platform']='cygwin'
             env['CC']='i586-mingw32msvc-cc'
@@ -122,8 +137,8 @@
 
             ret_val += win32_cmds % (t_base,input_prefix,t_base,input_prefix,
-                                     t_base,input_prefix,
-                                     t_base,t_base,t_base,t_base,t_base)
+                                     t_base,input_prefix,t_base,
+                                     t_base,t_base,t_base,t_base)
 
-        elif t in doc_targets:
+        elif ttype == 'doc':
             ret_val += doc_cmds % (t_base,t_base,t_base,t_base,t_base)
         
@@ -131,12 +146,12 @@
 
 
-
 release_builder = Builder(generator = generate_cmds,
-                          suffix = '.tar.gz',
+                          suffix = '',
                           src_suffix = '',
-                          prefix='reglookup-')
-
+                          prefix='')
 
 env = Environment()
+env['ENV']['SSH_AGENT_PID'] = os.environ['SSH_AGENT_PID']
+env['ENV']['SSH_AUTH_SOCK'] = os.environ['SSH_AUTH_SOCK']
 env['BUILDERS']['Release'] = release_builder
 
@@ -145,10 +160,16 @@
 
 for target in COMMAND_LINE_TARGETS:
-    AlwaysBuild(target)
     if target not in all_targets:
         print('ERROR: cannot build "%s".  Acceptable targets: %s'
               % (target, repr(all_targets)))
-        break
-    env.Release(target, Dir(version2input(target2version(target))))
+        sys.exit(1)
+    AlwaysBuild(target)
+    ttype,version = parse_target(target)
+
+    i = version2input(version)
+    env.Execute(export_cmds % (i, i))
+    if version != 'trunk':
+        env.Execute(version_cmds % (version, i))
+    env.Release(target, Dir('.export/'+i))
 
 Default(None)
