Transitioned build system from Make to SCons
authorW. Trevor King <wking@drexel.edu>
Fri, 16 Apr 2010 05:13:21 +0000 (01:13 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 17 Apr 2010 00:23:07 +0000 (20:23 -0400)
74 files changed:
.gitignore [new file with mode: 0644]
README
tex/Makefile [deleted file]
tex/SConstruct [new file with mode: 0644]
tex/site_cons/__init__.py [new file with mode: 0644]
tex/site_cons/site_init.py [new file with mode: 0644]
tex/site_cons/site_tools/__init__.py [new file with mode: 0644]
tex/site_cons/site_tools/asymptote.py [new file with mode: 0644]
tex/site_cons/site_tools/gnuplot.py [new file with mode: 0644]
tex/src/Makefile [deleted file]
tex/src/SConscript [new file with mode: 0644]
tex/src/apparatus/Makefile [deleted file]
tex/src/cantilever-calib/Makefile [deleted file]
tex/src/cantilever-calib/test/Makefile [deleted file]
tex/src/cantilever-calib/test/SConscript [new file with mode: 0644]
tex/src/cantilever/Makefile [deleted file]
tex/src/contour-space/Makefile [deleted file]
tex/src/figures/Makefile [deleted file]
tex/src/figures/SConscript [new file with mode: 0644]
tex/src/figures/asy/SConscript [new file with mode: 0644]
tex/src/figures/biotin-streptavidin/Makefile [deleted file]
tex/src/figures/biotin-streptavidin/SConscript [new file with mode: 0644]
tex/src/figures/calibration-concept-map/Makefile [deleted file]
tex/src/figures/calibration-concept-map/SConscript [new file with mode: 0644]
tex/src/figures/cantilever-data/Makefile [deleted file]
tex/src/figures/cantilever-data/SConscript [new file with mode: 0644]
tex/src/figures/cantilever-data/make_v_dep_plots.sh
tex/src/figures/cantilever-data/wtk_graph.asy [deleted symlink]
tex/src/figures/cantilever-sim/Makefile [deleted file]
tex/src/figures/cantilever-sim/SConscript [new file with mode: 0644]
tex/src/figures/cantilever-sim/wtk_graph.asy [deleted symlink]
tex/src/figures/contour/Makefile [deleted file]
tex/src/figures/contour/SConscript [new file with mode: 0644]
tex/src/figures/expt-sawtooth/Makefile [deleted file]
tex/src/figures/expt-sawtooth/SConscript [new file with mode: 0644]
tex/src/figures/expt-sawtooth/fig.gp [moved from tex/src/figures/expt-sawtooth/plot.gp with 100% similarity]
tex/src/figures/fit-space/Makefile [deleted file]
tex/src/figures/fit-space/SConscript [new file with mode: 0644]
tex/src/figures/fit-space/fig.gp [moved from tex/src/figures/fit-space/plot.gp with 100% similarity]
tex/src/figures/fit-space/king_vs_best.gp
tex/src/figures/fit-space/king_vs_best.png [deleted file]
tex/src/figures/fit-space/means.gp
tex/src/figures/i27/Makefile [deleted file]
tex/src/figures/i27/SConscript [new file with mode: 0644]
tex/src/figures/kappa-sawteeth/Makefile [deleted file]
tex/src/figures/kappa-sawteeth/SConscript [new file with mode: 0644]
tex/src/figures/kappa-sawteeth/fig.gp [moved from tex/src/figures/kappa-sawteeth/plot.gp with 100% similarity]
tex/src/figures/order-dep/Makefile [deleted file]
tex/src/figures/order-dep/SConscript [new file with mode: 0644]
tex/src/figures/order-dep/fig.gp [moved from tex/src/figures/order-dep/plot.gp with 100% similarity]
tex/src/figures/schematic/Makefile [deleted file]
tex/src/figures/schematic/SConscript [new file with mode: 0644]
tex/src/figures/schematic/wtk_graph.asy [deleted symlink]
tex/src/figures/sim-hist/Makefile [deleted file]
tex/src/figures/sim-hist/SConscript [new file with mode: 0644]
tex/src/figures/sim-hist/fig.gp [moved from tex/src/figures/sim-hist/plot.gp with 100% similarity]
tex/src/figures/sim-sawtooth/Makefile [deleted file]
tex/src/figures/sim-sawtooth/SConscript [new file with mode: 0644]
tex/src/figures/sim-sawtooth/fig.gp [moved from tex/src/figures/sim-sawtooth/plot.gp with 100% similarity]
tex/src/figures/v-dep/Makefile [deleted file]
tex/src/figures/v-dep/SConscript [new file with mode: 0644]
tex/src/figures/v-dep/fig-sd.gp [moved from tex/src/figures/v-dep/plot-sd.gp with 100% similarity]
tex/src/figures/v-dep/fig.gp [moved from tex/src/figures/v-dep/plot.gp with 100% similarity]
tex/src/future/Makefile [deleted file]
tex/src/introduction/Makefile [deleted file]
tex/src/packages/Makefile [deleted file]
tex/src/packages/SConscript [new file with mode: 0644]
tex/src/sawsim/Makefile [deleted file]
tex/src/temperature-theory/Makefile [deleted file]
tex/src/temperature/Makefile [deleted file]
tex/src/tension/Makefile [deleted file]
tex/src/unfolding-distributions/Makefile [deleted file]
tex/src/unfolding/Makefile [deleted file]
tex/src/viscocity/Makefile [deleted file]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..a3f5fec
--- /dev/null
@@ -0,0 +1,3 @@
+*.pyc
+.sconsign.dblite
+config.log
diff --git a/README b/README
index 69d6731f959dd25d36e3516b6311050a2c662967..a085c5a03b3d6da874fd9cba53420eae564c9f0e 100644 (file)
--- a/README
+++ b/README
@@ -9,10 +9,10 @@ All the goodies are in the tex/ directory.
 
 Build with
   $ cd tex
-  tex$ make
+  tex$ scons
 
 Rebuild (after editing some file(s) in tex/src/) with
-  tex$ make
+  tex$ scons
 
 
 Getting the source
diff --git a/tex/Makefile b/tex/Makefile
deleted file mode 100644 (file)
index 2d1c300..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-LATEX = pdflatex
-#LATEX = xelatex
-
-thesis.pdf : build
-       (cd ./build && $(LATEX) root)
-       (cd ./build && bibtex root)
-       (cd ./build && $(LATEX) root)
-       (cd ./build && bibtex root)
-       (cd ./build && $(LATEX) root)
-       (cd ./build && bibtex root)
-       (cd ./build && makeindex root.nlo -s nomencl.ist -o root.nls)
-       (cd ./build && makeindex root.idx)
-       (cd ./build && $(LATEX) root)
-       (cd ./build && $(LATEX) root)
-       mv build/root.pdf $@
-
-.PHONY: build
-build :
-       rsync -a src/ build
-       $(MAKE) --directory build all
-
-clean :
-       rm -rf build thesis.pdf
diff --git a/tex/SConstruct b/tex/SConstruct
new file mode 100644 (file)
index 0000000..89d20a0
--- /dev/null
@@ -0,0 +1,8 @@
+#Help("""...""")
+
+VariantDir('build', 'src')
+thesis_build = SConscript('build/SConscript')
+Clean(thesis_build, 'build')
+thesis_pdf = Command('thesis.pdf', thesis_build, Copy("$TARGET", "$SOURCE"))
+Alias('pdf', thesis_pdf)
+Default(thesis_pdf)
diff --git a/tex/site_cons/__init__.py b/tex/site_cons/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tex/site_cons/site_init.py b/tex/site_cons/site_init.py
new file mode 100644 (file)
index 0000000..a4131ff
--- /dev/null
@@ -0,0 +1,43 @@
+import os.path
+import SCons.Node.FS
+
+
+def include_child_SConscripts(env, SConscript):
+    """Get all the nested SConscripts in that may alter and pass back
+    the environment.  They may also add thesis subdependencies to that
+    environment.
+    """
+    for subdir in env.Glob('*'):
+        if not isinstance(subdir, SCons.Node.FS.Dir):
+            continue # subdir isn't a directory
+        var_sconscript_path = os.path.join(subdir.abspath,
+                                           'SConscript')
+        src_sconscript_path = os.path.join(subdir.srcnode().abspath,
+                                           'SConscript')
+        if os.path.exists(src_sconscript_path):
+            if env.GetOption('silent') is False:
+                # ideally 'silent' should be -Q, not the current -s/--silent/--quiet
+                print 'Including', var_sconscript_path
+            env = SConscript(var_sconscript_path, 'env')
+    return env
+
+def check_exec(context, executible):
+    # TODO: context.env vs. context.vardict
+    context.Message('Checking for %s executible...' % executible)
+    if executible.upper() in context.env:
+        context.Result('yes')
+        return 'yes'
+    result = 'no'
+    for p in context.env.Dictionary()['ENV']['PATH']:
+        path = os.path.join(p, executible)
+        if os.path.exists(path):
+            result = 'yes'
+            break
+    context.Result(result)
+    if result is 'yes':
+        context.env[executible.upper()] = path
+    return result
+
+def link_wtk_graph(env):
+    return env.Command('wtk_graph.asy', '../asy/wtk_graph.asy',
+                       SCons.Script.Copy('$TARGET', '$SOURCE'))
diff --git a/tex/site_cons/site_tools/__init__.py b/tex/site_cons/site_tools/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tex/site_cons/site_tools/asymptote.py b/tex/site_cons/site_tools/asymptote.py
new file mode 100644 (file)
index 0000000..40de5ab
--- /dev/null
@@ -0,0 +1,89 @@
+import os.path
+import re
+import SCons.Action
+import SCons.Scanner
+import SCons.Script
+import SCons.Util
+import doctest
+
+
+double_quoted_string_re = re.compile(r'"([^"]*)"', re.M)
+
+def asymptote_scan(node, env, path, arg=None):
+    """
+    >>> class node (object):
+    ...     def __init__(self, path):
+    ...         self.path = path
+    ...         self.abspath = os.path.abspath(self.path)
+    ...         if os.path.isfile(self.path):
+    ...             self.dir = node(os.path.dirname(path))
+    ...     def get_text_contents(self):
+    ...         return open(self.path, 'r').read()
+    ...     def get_contents(self):
+    ...         return self.get_text_contents()
+    ...     def srcnode(self):
+    ...         return self
+    >>> for p in asymptote_scan(
+    ...         node('../../src/figures/cantilever-sim/v-dep.asy'),
+    ...         None, None, None):
+    ...     print p
+    v-dep.d/v_dep_127_8
+    v-dep.d/v_dep_27_8
+    v-dep.d/v_dep_127_30
+    v-dep.d/v_dep_27_30
+    v-dep.d/v_dep_0.1_1
+    v-dep.d/v_dep_0.1_30
+    """
+    try:
+        contents = node.get_text_contents()
+    except AttributeError:
+        contents = node.get_contents() # for older versions of SCons, fall back on binary read
+    ret = []
+    for string in double_quoted_string_re.findall(contents):
+        p = os.path.join(node.dir.srcnode().abspath, string)
+        if len(string) > 0 and \
+                ((string not in ret and os.path.exists(p))
+                 or string.endswith('.dat')):
+            ret.append(string)
+    return ret
+
+def asymptote_emitter(target, source, env):
+    assert str(source[0]).endswith('.asy'), str(source[0])
+    filebase = str(source[0])[:-len('.asy')]
+    target.extend(['%s_%s' % (filebase, ext)
+                   for ext in ['.tex', '.pre', '0.pdf']])
+    target.extend(['%s-comp.%s' % (filebase, ext)
+                   for ext in ['idx', 'log', 'nlo', 'pdf']])
+    source.append(SCons.Script.Alias('asytools'))
+    return target, source
+
+AsymptoteAction = None
+
+def generate(env):
+    """Add Builders and construction variables for Asymptote to an Environment."""
+    global AsymptoteAction
+    if AsymptoteAction is None:
+        AsymptoteAction = SCons.Action.Action('$ASYMPTOTECOM', '$ASYMPTOTECOMSTR')
+
+    #import pdf
+    #pdf.generate(env)
+
+    env['BUILDERS']['Asymptote'] = SCons.Script.Builder(
+        action=AsymptoteAction, suffix='_.tex', src_suffix = '.asy',
+        emitter=asymptote_emitter)
+    env['ASYMPTOTE'] = '../asy/asyprocess'
+    env['ASYMPTOTEFLAGS'] = SCons.Util.CLVar(
+        "--texinputs=../..: "
+        "--pretex='\documentclass{drexel-thesis} \input{packages}' "
+        "--")
+    env['ASYMPTOTECOM']  = 'cd ${TARGET.dir} && $ASYMPTOTE $ASYMPTOTEFLAGS ${SOURCE.filebase}'
+    env.Append(SCANNERS=SCons.Scanner.Base(
+            function=asymptote_scan,
+            name='Asymptote',
+            skeys=['.asy']))
+
+def exists(env):
+    return env.Detect('asymptote')
+
+if __name__ == '__main__':
+    doctest.testmod()
diff --git a/tex/site_cons/site_tools/gnuplot.py b/tex/site_cons/site_tools/gnuplot.py
new file mode 100644 (file)
index 0000000..7d62bc3
--- /dev/null
@@ -0,0 +1,75 @@
+import os.path
+import re
+import SCons.Action
+import SCons.Scanner
+import SCons.Script
+import SCons.Util
+import doctest
+
+quoted_string_re = re.compile(r"'([^']*)'", re.M)
+
+def gnuplot_scan(node, env, path, arg=None):
+    """
+    >>> class node (object):
+    ...     def __init__(self, path):
+    ...         self.path = path
+    ...         self.abspath = os.path.abspath(self.path)
+    ...         if os.path.isfile(self.path):
+    ...             self.dir = node(os.path.dirname(path))
+    ...     def get_text_contents(self):
+    ...         return open(self.path, 'r').read()
+    ...     def get_contents(self):
+    ...         return self.get_text_contents()
+    ...     def srcnode(self):
+    ...         return self
+    >>> for p in gnuplot_scan(
+    ...         node('../../src/figures/order-dep/fig.gp'),
+    ...         None, None, None):
+    ...     print p
+    data/order.avg-4
+    data/order.avg-8
+    data/order.avg-12
+    data/order.avg-16
+    data/hist3i.hist
+    data/hist3ii.hist
+    data/hist3iii.hist
+    """
+    try:
+        contents = node.get_text_contents()
+    except AttributeError:
+        contents = node.get_contents() # for older versions of SCons, fall back on binary read
+    ret = []
+    for string in quoted_string_re.findall(contents):
+        p = os.path.join(node.dir.srcnode().abspath, string)
+        if len(string) > 0 and \
+                ((string not in ret and os.path.exists(p))
+                 or string.endswith('.dat')):
+            ret.append(string)
+    return ret
+
+GnuplotAction = None
+
+def generate(env):
+    """Add Builders and construction variables for Gnuplot to an Environment."""
+    global GnuplotAction
+    if GnuplotAction is None:
+        GnuplotAction = SCons.Action.Action('$GNUPLOTCOM', '$GNUPLOTCOMSTR')
+
+    #import pdf
+    #pdf.generate(env)
+
+    env['BUILDERS']['Gnuplot'] = SCons.Script.Builder(
+        action=GnuplotAction, suffix='.pdf', src_suffix = '.gp')
+    env['GNUPLOT'] = 'gnuplot'
+    env['GNUPLOTFLAGS'] = '' #SCons.Util.CLVar('')
+    env['GNUPLOTCOM'] = 'cd ${TARGET.dir} && $GNUPLOT $GNUPLOTLAGS ${SOURCE.file}'
+    env.Append(SCANNERS=SCons.Scanner.Base(
+            function=gnuplot_scan,
+            name='Gnuplot',
+            skeys=['.gp']))
+
+def exists(env):
+    return env.Detect('gnuplot')
+
+if __name__ == '__main__':
+    doctest.testmod()
diff --git a/tex/src/Makefile b/tex/src/Makefile
deleted file mode 100644 (file)
index b747772..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-SUBDIRS = packages apparatus cantilever cantilever-calib contour-space \
-       figures future introduction sawsim temperature temperature-theory \
-       tension unfolding unfolding-distributions viscocity
-
-all :
-       @for i in $(SUBDIRS); do \
-        echo "make all in $$i..."; \
-        (cd $$i; $(MAKE) $(MFLAGS) all); done
-       @for file in $(shell find . -name '*.tex'); do \
-       cat local_words >> $$file; done
-
-clean :
-       @for i in $(SUBDIRS); do \
-        echo "make clean in $$i..."; \
-        (cd $$i; $(MAKE) $(MFLAGS) clean); done
diff --git a/tex/src/SConscript b/tex/src/SConscript
new file mode 100644 (file)
index 0000000..ce08fd4
--- /dev/null
@@ -0,0 +1,51 @@
+import os.path
+import SCons.Scanner
+
+from site_cons.site_init import include_child_SConscripts, check_exec
+from site_cons.site_tools import asymptote, gnuplot
+
+# Make a new environment.
+env = Environment(ENV={
+    'PATH':['/usr/local/bin', '/opt/bin', '/bin', '/usr/bin'],
+    'HOME':os.path.expanduser('~'),
+    'DISPLAY':os.environ['DISPLAY'],
+    'PYMOL_PATH':'/usr/lib/python2.6/site-packages/pymol',
+    'PYMOL_DATA':'/usr/share/pymol/data',
+    'PYMOL_SCRIPTS':'/usr/share/pymol/scripts',
+    })
+asymptote.generate(env)
+gnuplot.generate(env)
+
+if not env.GetOption('clean'):
+    # Configure the environment since we're not cleaning.
+    conf = Configure(env, custom_tests={'CheckExec':check_exec})
+    if not conf.CheckExec('pymol'):
+        print 'PyMol is not installed!'
+        Exit(1)
+    conf.CheckExec('dot')
+    env = conf.Finish()
+
+# Include sub-SConscript files with rules for figures, packages, etc.
+env = include_child_SConscripts(env, SConscript)
+
+# Alias the thesis' base latex, which is used by asyprocess when
+# building the Asymptote graphics.
+Alias('latex-base', [Glob('*.tex'), Alias('extra-packages')])
+
+# Add a rule for the thesis itself.
+#thesis = Command('thesis', objs, 'TODO')
+thesis = env.Command('thesis.pdf', [], Touch('$TARGET'))
+
+Return('thesis')
+
+#thesis.pdf : build
+#      (cd ./build && $(LATEX) root)
+#      (cd ./build && bibtex root)
+#      (cd ./build && $(LATEX) root)
+#      (cd ./build && bibtex root)
+#      (cd ./build && $(LATEX) root)
+#      (cd ./build && bibtex root)
+#      (cd ./build && makeindex root.nlo -s nomencl.ist -o root.nls)
+#      (cd ./build && makeindex root.idx)
+#      (cd ./build && $(LATEX) root)
+#      (cd ./build && $(LATEX) root)
diff --git a/tex/src/apparatus/Makefile b/tex/src/apparatus/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/cantilever-calib/Makefile b/tex/src/cantilever-calib/Makefile
deleted file mode 100644 (file)
index a260214..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all : 
-
-clean :
diff --git a/tex/src/cantilever-calib/test/Makefile b/tex/src/cantilever-calib/test/Makefile
deleted file mode 100644 (file)
index 386a300..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-PYTHON_FILES = Lorentz_root locate_roots test_integral test_roots
-
-all : $(PYTHON_FILES:%=%.png)
-
-%.png : %.py
-       python $<
-
-clean :
-       rm -f $(PYTHON_FILES:%=%.png)
diff --git a/tex/src/cantilever-calib/test/SConscript b/tex/src/cantilever-calib/test/SConscript
new file mode 100644 (file)
index 0000000..0ed1c31
--- /dev/null
@@ -0,0 +1,15 @@
+print 'reading', __file__
+
+# Get the passed in environment.
+Import('env')
+
+# Configure the builders. This is all we're doing here for this case.
+env = SConscript('builders.SConscript', 'env')
+
+for python_file in Glob('*.py'):
+    env.Command(python_file.replace('.py', '.png'),
+                python_file,
+                'python $SOURCE')
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/cantilever/Makefile b/tex/src/cantilever/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/contour-space/Makefile b/tex/src/contour-space/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/figures/Makefile b/tex/src/figures/Makefile
deleted file mode 100644 (file)
index 96fdf01..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-SUBDIRS = biotin-streptavidin cantilever-data cantilever-sim contour \
-       expt-sawtooth fit-space i27 kappa-sawteeth order-dep schematic \
-       sim-hist sim-sawtooth v-dep \
-       # calibration-concept-map
-
-all :
-       @for i in $(SUBDIRS); do \
-        echo "make all in $$i..."; \
-        $(MAKE) --directory $$i $(MFLAGS) all; \
-        done
-
-clean :
-       @for i in $(SUBDIRS); do \
-        echo "make all in $$i..."; \
-        $(MAKE) --directory $$i $(MFLAGS) clean; \
-        done
diff --git a/tex/src/figures/SConscript b/tex/src/figures/SConscript
new file mode 100644 (file)
index 0000000..0eac076
--- /dev/null
@@ -0,0 +1,9 @@
+from site_cons.site_init import include_child_SConscripts
+
+# Get the passed in environment.
+Import('env')
+
+env = include_child_SConscripts(env, SConscript)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/asy/SConscript b/tex/src/figures/asy/SConscript
new file mode 100644 (file)
index 0000000..3318e5c
--- /dev/null
@@ -0,0 +1,8 @@
+# Get the passed in environment.
+Import('env')
+
+asy = env.Alias('asytools', ['asyprocess', 'wtk_graph.asy'])
+Depends(asy, Alias('latex-base'))
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/biotin-streptavidin/Makefile b/tex/src/figures/biotin-streptavidin/Makefile
deleted file mode 100644 (file)
index 005062a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : 1SWE.png
-
-clean :
-       rm -f 1SWE.png
-
-%.png : %.pml %.pdb
-        pymol -cq $<
diff --git a/tex/src/figures/biotin-streptavidin/SConscript b/tex/src/figures/biotin-streptavidin/SConscript
new file mode 100644 (file)
index 0000000..5b88d51
--- /dev/null
@@ -0,0 +1,11 @@
+# Get the passed in environment.
+Import('env')
+
+swe = env.Command(
+    '1SWE.png',
+    ['1SWE.pml', '1SWE.pdb'],
+    'pymol -cq 1SWE.pml',
+    chdir=True)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/calibration-concept-map/Makefile b/tex/src/figures/calibration-concept-map/Makefile
deleted file mode 100644 (file)
index b9f8fec..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : concept_map.png
-
-clean :
-       rm -f concept_map.png
-
-concept_map.png :
-       dot -Tpng concept_map.dot > $@
diff --git a/tex/src/figures/calibration-concept-map/SConscript b/tex/src/figures/calibration-concept-map/SConscript
new file mode 100644 (file)
index 0000000..a66b71b
--- /dev/null
@@ -0,0 +1,10 @@
+# Get the passed in environment.
+Import('env')
+
+if 'DOT' in env:
+    env.Command('concept_map.png', 'concept_map.dot',
+                'dot -Tpng $SOURCE > $TARGET',
+               chdir=True)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/cantilever-data/Makefile b/tex/src/figures/cantilever-data/Makefile
deleted file mode 100644 (file)
index a10c733..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-ASYPROCESS = ../asy/asyprocess \
-  --texinputs=../..: \
-  --pretex='\documentclass{drexel-thesis} \input{packages}' \
-  --
-
-FIGS = v-dep loading-rate 
-V_DEP_DATA = v-dep.d/v_dep_131.98.dat \
-       v-dep.d/v_dep_131.98.fit \
-       v-dep.d/v_dep_24.33.dat \
-       v-dep.d/v_dep_24.33.fit
-LOADING_RATE_DATA = loading-rate.d/loading_rate_131.98.dat \
-       loading-rate.d/loading_rate_24.33.dat
-DATA = $(V_DEP_DATA) $(LOADING_RATE_DATA)
-DATA_DIRS = data v-dep.d loading-rate.d
-
-# Never delete intermediates.  (`info make` 10.4 Chains of Implicit Rules)
-.SECONDARY :
-
-
-all : $(FIGS:%=%_.tex)
-
-clean :
-       rm -f $(FIGS:%=%_*) $(FIGS:%=%-*) v-dep.asy v-dep.gp *.pyc
-       #rm -rf $(DATA_DIRS)
-
-%_.tex : %.asy $(DATA)
-       $(ASYPROCESS) $(patsubst %.asy, %, $<)
-
-$(DATA_DIRS) :
-       mkdir $@
-
-data/raw : extract_f_v_k_data.sh | data
-       touch data/raw
-#      ./$< > $@
-
-data/avg : avg_data.py data/raw
-       touch $@ # "avg" marks the time of last avg_data.py run
-       python $<
-
-data/spring-constants data/averaged-data : data/avg
-       @echo "$@ already build for target data/avg"
-
-v-dep.d/dat : get_v_dep.sh data/spring-constants data/averaged-data \
-               | v-dep.d
-       touch $@ # "dat" marks the time of last *.dat file generation
-       ./$<
-
-v-dep.d/v_dep_%.dat : v-dep.d/dat
-       @echo "$@ already build for target v-dep.d/dat"
-
-v-dep.d/v_dep_%.fit : fit_data.py v-dep.d/v_dep_%.dat
-       python $^ > $@
-
-v-dep.asy v-dep.gp : make_v_dep_plots.sh $(V_DEP_DATA)
-       ./$<
-
-v-dep.pdf : v-dep.gp $(V_DEP_DATA)
-       gnuplot $<
-
-v-dep.eps : v-dep.pdf
-       pdftoeps $<
-
-v-dep-rotated.pdf : v-dep.pdf
-       pdftk $< cat 1E output $@
-
-loading-rate.d/dat : get_loading_rates.py avg_data.py data/raw \
-               | loading-rate.d
-       touch $@ # "dat" marks the time of last *.dat file generation
-       python $<
-
-loading-rate.d/loading_rate_%.dat : loading-rate.d/dat
-       @echo "$@ already build for target loading-rate.d/dat"
diff --git a/tex/src/figures/cantilever-data/SConscript b/tex/src/figures/cantilever-data/SConscript
new file mode 100644 (file)
index 0000000..9331766
--- /dev/null
@@ -0,0 +1,89 @@
+import os.path
+
+from site_cons.site_init import link_wtk_graph
+
+
+FIGURES = ['v-dep', 'loading-rate']
+Ks = ['131.98', '24.33'] # HACK!  these are not static
+
+# Get the passed in environment.
+Import('env')
+
+data_dir = Dir('data')
+raw = File(os.path.join(str(data_dir), 'raw'))
+raw = [raw]
+# = env.Command(
+#    os.path.join(str(data_dir), 'raw'),
+#    ['extract_f_v_k_data.sh'],
+#    './$SOURCE > $TARGET')
+#env.Requires(raw, data_dir)
+
+averaged_data = env.Command(
+    os.path.join(str(data_dir), 'averaged-data'),
+    ['avg_data.py'] + raw,
+    'cd .. && python avg_data.py',
+    chdir=True)
+spring_constants = env.SideEffect(
+    os.path.join(str(data_dir), 'spring-constants'),
+    averaged_data)
+
+loading_rate_dir = Dir('loading-rate.d')
+def loading_rate_file(k):
+    return os.path.join(str(loading_rate_dir), 'loading_rate_%s.dat' % k)
+
+loading_rates = env.Command(
+    loading_rate_file(Ks[0]),
+    ['get_loading_rates.py', 'avg_data.py', raw],
+    'cd .. && python get_loading_rates.py',
+    chdir=True)
+#env.Requires(loading_rates, loading_rate_dir)
+
+loading_rate_data = [loading_rates]
+for k in Ks[1:]:
+    loading_rate_data.append(
+        env.SideEffect(loading_rate_file(k), loading_rates))
+
+v_dep_dir = Dir('v-dep.d')
+def v_dep_file(k):
+    return os.path.join(str(v_dep_dir), 'v_dep_%s.dat' % k)
+def v_dep_fit_file(k):
+    return os.path.join(str(v_dep_dir), 'v_dep_%s.fit.dat' % k)
+
+v_deps = env.Command(
+    v_dep_file(Ks[0]),
+    ['get_v_dep.sh', spring_constants, averaged_data],
+    'cd .. && ./get_v_dep.sh',
+    chdir=True)
+#env.Requires(v_deps, v_dep_dir)
+
+v_dep_data = [v_deps]
+for k in Ks[1:]:
+    v_dep_data.append(
+        env.SideEffect(v_dep_file(k), v_deps))
+    
+for k,data in zip(Ks, v_dep_data):    
+    v_dep_data.append(
+        env.Command(
+            v_dep_fit_file(k),
+            ['fit_data.py'] + data,
+            'python $SOURCES  > $TARGET'))
+
+v_dep = env.Command(
+        'v-dep.asy',
+        ['make_v_dep_plots.sh'] + v_dep_data,
+        './make_v_dep_plots.sh',
+        chdir=True)
+env.SideEffect('v-dep.gp', v_dep)
+
+
+wtk_graph = link_wtk_graph(env)
+
+for fig in FIGURES:
+    asyfile = '%s.asy' % fig  # static .asy file
+    pyfig = fig.replace('-', '_')
+    if pyfig in globals():    # generated .asy file
+        asyfile = globals()[pyfig]
+    env.Asymptote([asyfile, wtk_graph])
+
+# Pass back the modified environment.
+Return('env')
index 60fa9f7f6b5e4b78af17ef49dbd74f68d50e2ce4..c2178909d23fde1e574e7cbb7d6597116b0a6f4e 100755 (executable)
@@ -29,10 +29,10 @@ do
     esac
     ASYPLOTS=$(echo -e "$ASYPLOTS\ngraphFile(\"$FILE.dat\", xscale, yscale, $PEN, m8,
           markroutine=marksize(\"$FILE.dat\", $PEN, m8, 10), t=units(\"$K\",\"pN/nm\"), dots=true);")
-    ASYPLOTS=$(echo -e "$ASYPLOTS\ngraphFile(\"$FILE.fit\", xscale, yscale, $PEN,
+    ASYPLOTS=$(echo -e "$ASYPLOTS\ngraphFile(\"$FILE.fit.dat\", xscale, yscale, $PEN,
           t=units(\"$K\",\"pN/nm\"));")
     GPPLOTS="$GPPLOTS, '$FILE.dat' using 1:2:(sqrt(\$4)) with points pt 6 pointsize variable t '$K (pN/nm)'"
-    GPPLOTS="$GPPLOTS, '$FILE.fit' using 1:2 with lines notitle"
+    GPPLOTS="$GPPLOTS, '$FILE.fit.dat' using 1:2 with lines notitle"
 done < <(tac "$KFILE")
 GPPLOTS="${GPPLOTS:2}" # remove leading ' ,'
 
diff --git a/tex/src/figures/cantilever-data/wtk_graph.asy b/tex/src/figures/cantilever-data/wtk_graph.asy
deleted file mode 120000 (symlink)
index 6142fdb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../asy/wtk_graph.asy
\ No newline at end of file
diff --git a/tex/src/figures/cantilever-sim/Makefile b/tex/src/figures/cantilever-sim/Makefile
deleted file mode 100644 (file)
index 60d7187..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-ASYPROCESS = ../asy/asyprocess \
-  --texinputs=../..: \
-  --pretex='\documentclass{drexel-thesis} \input{packages}' \
-  --
-
-FIGS = loading-rate v-dep i-dep 
-
-all : $(FIGS:%=%_.tex)
-
-clean :
-       rm -f $(FIGS:%=%_*) $(FIGS:%=%-*)
-
-%_.tex : %.asy
-       $(ASYPROCESS) $(patsubst %.asy, %, $<)
diff --git a/tex/src/figures/cantilever-sim/SConscript b/tex/src/figures/cantilever-sim/SConscript
new file mode 100644 (file)
index 0000000..ee40383
--- /dev/null
@@ -0,0 +1,14 @@
+from site_cons.site_init import link_wtk_graph
+
+FIGURES = ['v-dep', 'i-dep'] #'loading-rate', 'i-dep']
+
+# Get the passed in environment.
+Import('env')
+
+wtk_graph = link_wtk_graph(env)
+
+for fig in FIGURES:
+    env.Asymptote(['%s.asy' % fig, wtk_graph])
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/cantilever-sim/wtk_graph.asy b/tex/src/figures/cantilever-sim/wtk_graph.asy
deleted file mode 120000 (symlink)
index 6142fdb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../asy/wtk_graph.asy
\ No newline at end of file
diff --git a/tex/src/figures/contour/Makefile b/tex/src/figures/contour/Makefile
deleted file mode 100644 (file)
index 377c7fa..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-ASYPROCESS = ../asy/asyprocess \
-  --texinputs=../..: \
-  --pretex='\documentclass{drexel-thesis} \input{packages}' \
-  --
-
-FIGS = contour
-
-all : $(FIGS:%=%_.tex)
-
-clean :
-       rm -f $(FIGS:%=%_*) $(FIGS:%=%-*)
-
-%_.tex : %.asy
-       $(ASYPROCESS) $(patsubst %.asy, %, $<)
diff --git a/tex/src/figures/contour/SConscript b/tex/src/figures/contour/SConscript
new file mode 100644 (file)
index 0000000..e096876
--- /dev/null
@@ -0,0 +1,14 @@
+from site_cons.site_init import link_wtk_graph
+
+FIGURES = ['contour']
+
+# Get the passed in environment.
+Import('env')
+
+wtk_graph = link_wtk_graph(env)
+
+for fig in FIGURES:
+    env.Asymptote(['%s.asy' % fig, wtk_graph])
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/expt-sawtooth/Makefile b/tex/src/figures/expt-sawtooth/Makefile
deleted file mode 100644 (file)
index fcfaa89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : fig.pdf
-
-clean :
-       rm -f fig.pdf
-
-fig.pdf :
-       gnuplot plot.gp
diff --git a/tex/src/figures/expt-sawtooth/SConscript b/tex/src/figures/expt-sawtooth/SConscript
new file mode 100644 (file)
index 0000000..d8ff28f
--- /dev/null
@@ -0,0 +1,8 @@
+# Get the passed in environment.
+Import('env')
+
+for gp in Glob('*.gp'):
+    env.Gnuplot(gp)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/fit-space/Makefile b/tex/src/figures/fit-space/Makefile
deleted file mode 100644 (file)
index fcfaa89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : fig.pdf
-
-clean :
-       rm -f fig.pdf
-
-fig.pdf :
-       gnuplot plot.gp
diff --git a/tex/src/figures/fit-space/SConscript b/tex/src/figures/fit-space/SConscript
new file mode 100644 (file)
index 0000000..d8ff28f
--- /dev/null
@@ -0,0 +1,8 @@
+# Get the passed in environment.
+Import('env')
+
+for gp in Glob('*.gp'):
+    env.Gnuplot(gp)
+
+# Pass back the modified environment.
+Return('env')
index b29574e38c8249784452a243504810aa5766b81e..db144f9712e3acd8e47440b4fe00f740ae92faf5 100644 (file)
@@ -1,5 +1,5 @@
-set terminal png
-set output 'king_vs_best.png'
+set terminal pdf enhanced font 'Times,7' size 9cm, 6cm
+set output 'king_vs_best.pdf'
 g(x) = 39.727*exp(-40.7215e9*x)                                                          
 f(x) = 25.4465*exp(-44.6235e9*x) 
 set logscale y
diff --git a/tex/src/figures/fit-space/king_vs_best.png b/tex/src/figures/fit-space/king_vs_best.png
deleted file mode 100644 (file)
index 51e4fb5..0000000
Binary files a/tex/src/figures/fit-space/king_vs_best.png and /dev/null differ
index 2875603b2cb7e83a152e7c60b5f8afa572cbed67..642348204b2a6b21a413ea0973dd1c5540a7838a 100644 (file)
@@ -1,4 +1,5 @@
-set terminal x11
+set terminal pdf enhanced font 'Times,7' size 9cm, 6cm
+set output 'means.pdf'
 set view map
 set contour base
 unset surface
diff --git a/tex/src/figures/i27/Makefile b/tex/src/figures/i27/Makefile
deleted file mode 100644 (file)
index 765c95a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : 1TIT.png
-
-clean :
-       rm -f 1TIT.png
-
-%.png : %.pml %.pdb
-        pymol -cq $<
diff --git a/tex/src/figures/i27/SConscript b/tex/src/figures/i27/SConscript
new file mode 100644 (file)
index 0000000..cd1fa48
--- /dev/null
@@ -0,0 +1,11 @@
+# Get the passed in environment.
+Import('env')
+
+tit = env.Command(
+    '1TIT.png',
+    ['1TIT.pml', '1TIT.pdb'],
+    'pymol -cq 1TIT.pml',
+    chdir=True)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/kappa-sawteeth/Makefile b/tex/src/figures/kappa-sawteeth/Makefile
deleted file mode 100644 (file)
index fcfaa89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : fig.pdf
-
-clean :
-       rm -f fig.pdf
-
-fig.pdf :
-       gnuplot plot.gp
diff --git a/tex/src/figures/kappa-sawteeth/SConscript b/tex/src/figures/kappa-sawteeth/SConscript
new file mode 100644 (file)
index 0000000..d8ff28f
--- /dev/null
@@ -0,0 +1,8 @@
+# Get the passed in environment.
+Import('env')
+
+for gp in Glob('*.gp'):
+    env.Gnuplot(gp)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/order-dep/Makefile b/tex/src/figures/order-dep/Makefile
deleted file mode 100644 (file)
index 8a3894b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : fig.pdf
-
-clean :
-       rm -f fig.pdf fit.params fit.log
-
-fig.pdf :
-       gnuplot plot.gp 2>&1 | grep -A10 '^Fitted Kwlcs:' > fit.params
diff --git a/tex/src/figures/order-dep/SConscript b/tex/src/figures/order-dep/SConscript
new file mode 100644 (file)
index 0000000..3e1e590
--- /dev/null
@@ -0,0 +1,19 @@
+# Get the passed in environment.
+Import('env')
+
+#order_data = Glob('data/order.avg-*')
+#hist_data = Glob('data/hist*.hist')
+#fig = env.Command('fig.pdf',
+#    ['fig.gp'] + order_data + hist_data, 
+#    'gnuplot fig.gp 2>&1 | grep -A10 "^Fitted Kwlcs:" > fit.params',
+#    chdir=True)
+envb = env.Clone()
+envb['GNUPLOTCOM'] = \
+    ('cd ${TARGET.dir} && $GNUPLOT $GNPLOTLAGS ${SOURCE.file} 2>&1 |'
+     'grep -A10 "^Fitted Kwlcs:" > fit.params')
+fig = envb.Gnuplot('fig.gp')
+env.SideEffect('fit.log', fig)
+env.SideEffect('fit.params', fig)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/schematic/Makefile b/tex/src/figures/schematic/Makefile
deleted file mode 100644 (file)
index 93ba39d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-ASYPROCESS = ../asy/asyprocess \
-  --texinputs=../..: \
-  --pretex='\documentclass{drexel-thesis} \input{packages}' \
-  --
-
-FIGS = unfolding afm landscape-cant monte-carlo
-
-all : $(FIGS:%=%_.tex)
-
-clean :
-       rm -f $(FIGS:%=%_*) $(FIGS:%=%-*)
-
-%_.tex : %.asy
-       $(ASYPROCESS) $(patsubst %.asy, %, $<)
diff --git a/tex/src/figures/schematic/SConscript b/tex/src/figures/schematic/SConscript
new file mode 100644 (file)
index 0000000..9ed8806
--- /dev/null
@@ -0,0 +1,17 @@
+from site_cons.site_init import link_wtk_graph
+
+FIGURES = ['unfolding', 'afm', 'landscape-cant', 'monte-carlo']
+
+# Get the passed in environment.
+Import('env')
+
+wtk_graph = link_wtk_graph(env)
+
+for fig in FIGURES:
+    deps = [wtk_graph]
+    if fig in ['afm']:
+        deps.append('base_afm.asy')
+    env.Asymptote(['%s.asy' % fig] + deps)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/schematic/wtk_graph.asy b/tex/src/figures/schematic/wtk_graph.asy
deleted file mode 120000 (symlink)
index 6142fdb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../asy/wtk_graph.asy
\ No newline at end of file
diff --git a/tex/src/figures/sim-hist/Makefile b/tex/src/figures/sim-hist/Makefile
deleted file mode 100644 (file)
index fcfaa89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : fig.pdf
-
-clean :
-       rm -f fig.pdf
-
-fig.pdf :
-       gnuplot plot.gp
diff --git a/tex/src/figures/sim-hist/SConscript b/tex/src/figures/sim-hist/SConscript
new file mode 100644 (file)
index 0000000..d8ff28f
--- /dev/null
@@ -0,0 +1,8 @@
+# Get the passed in environment.
+Import('env')
+
+for gp in Glob('*.gp'):
+    env.Gnuplot(gp)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/figures/sim-sawtooth/Makefile b/tex/src/figures/sim-sawtooth/Makefile
deleted file mode 100644 (file)
index fcfaa89..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all : fig.pdf
-
-clean :
-       rm -f fig.pdf
-
-fig.pdf :
-       gnuplot plot.gp
diff --git a/tex/src/figures/sim-sawtooth/SConscript b/tex/src/figures/sim-sawtooth/SConscript
new file mode 100644 (file)
index 0000000..8ecd2a1
--- /dev/null
@@ -0,0 +1,9 @@
+# Get the passed in environment.
+Import('env')
+
+for gp in Glob('*.gp'):
+    env.Gnuplot(gp)
+
+# Pass back the modified environment.
+Return('env')
+
diff --git a/tex/src/figures/v-dep/Makefile b/tex/src/figures/v-dep/Makefile
deleted file mode 100644 (file)
index 51c81bd..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-all : fig.pdf fig-sd.pdf
-
-clean :
-       rm -f fig.pdf fig-sd.pdf
-
-fig.pdf :
-       gnuplot plot.gp
-
-fig-sd.pdf :
-       gnuplot plot-sd.gp
diff --git a/tex/src/figures/v-dep/SConscript b/tex/src/figures/v-dep/SConscript
new file mode 100644 (file)
index 0000000..d8ff28f
--- /dev/null
@@ -0,0 +1,8 @@
+# Get the passed in environment.
+Import('env')
+
+for gp in Glob('*.gp'):
+    env.Gnuplot(gp)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/future/Makefile b/tex/src/future/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/introduction/Makefile b/tex/src/introduction/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/packages/Makefile b/tex/src/packages/Makefile
deleted file mode 100644 (file)
index 53ad8af..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-PACKAGES = $(shell ls *.sty) $(shell ls *.ist) $(shell ls *.cfg) \
-       $(shell ls *.pdf) $(shell ls *.eps)
-TARGETS = $(PACKAGES:%=../%)
-
-all : $(TARGETS)
-
-../% : %
-       (cd ../ ; ln -s packages/$<)
-
-clean :
-       rm -f $(TARGETS)
diff --git a/tex/src/packages/SConscript b/tex/src/packages/SConscript
new file mode 100644 (file)
index 0000000..87ab164
--- /dev/null
@@ -0,0 +1,16 @@
+import os.path
+
+# Get the passed in environment.
+Import('env')
+
+# Copy all non-SConscript files into the parent directory.
+packages = []
+for path in Glob('*'):
+    if str(path) is not 'SConscript':
+        packages.append(env.Command(
+                os.path.join('..', str(path)), path,
+                Copy('$TARGET', '$SOURCE')))
+env.Alias('extra-packages', packages)
+
+# Pass back the modified environment.
+Return('env')
diff --git a/tex/src/sawsim/Makefile b/tex/src/sawsim/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/temperature-theory/Makefile b/tex/src/temperature-theory/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/temperature/Makefile b/tex/src/temperature/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/tension/Makefile b/tex/src/tension/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/unfolding-distributions/Makefile b/tex/src/unfolding-distributions/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/unfolding/Makefile b/tex/src/unfolding/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :
diff --git a/tex/src/viscocity/Makefile b/tex/src/viscocity/Makefile
deleted file mode 100644 (file)
index a1f4f4c..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-all :
-
-clean :