Commits

Dan Drake  committed b0d5d03

couple bits in example.tex; improve Makefile, test script

  • Participants
  • Parent commits 51c5759

Comments (0)

Files changed (3)

 SHELL=/bin/bash
 pkg=sagetexpackage
 dest=/home/drake/texmf/tex/latex/sagetex/
+dtxs=$(wildcard *.dtx)
 # the subdir stuff makes the tarball have the directory correct
 srcs=../sagetex/example.tex ../sagetex/README ../sagetex/sagetexpackage.dtx ../sagetex/sagetexpackage.ins
-ver=2.0.2
+ver=2.1
 
-all: ins
+.SUFFIXES:
+
+all: sagetex.sty sagetex.py example.pdf $(pkg).pdf
+
+# just depend on the .ind file, since we'll make the .gls and .ind together
+$(pkg).pdf: $(dtxs) $(pkg).ind
 	latex $(pkg).dtx
 	sage $(pkg).sage
-	make index
 	latex $(pkg).dtx
 	sage $(pkg).sage
 	latex $(pkg).dtx
 	pdflatex $(pkg).dtx
+
+example.pdf: example.tex sagetex.sty sagetex.py
 	latex example.tex
 	sage example.sage
 	latex example.tex
 	pdflatex example.tex
 
-index:
+%.ind: $(dtxs)
+	latex $(pkg).dtx
 	sed -e 's/usage|hyperpage/usagehyperpage/g' -i sagetexpackage.idx
 	makeindex -s gglo.ist -o $(pkg).gls $(pkg).glo 
 	makeindex -s gind.ist -o $(pkg).ind $(pkg).idx
 
-ins:
+sagetex.sty: py-and-sty.dtx
+	yes | latex $(pkg).ins
+
+sagetex.py: py-and-sty.dtx
 	yes | latex $(pkg).ins
 
 clean: 
 auxclean:
 	rm -f {$(pkg),example}.{glo,gls,aux,sout,out,toc,dvi,pdf,ps,log,ilg,ind,idx,sage}
 
-install: ins
+install: sagetex.sty sagetex.py
 	cp sagetex.sty $(dest)
 
 # make a tarball suitable for CTAN uploads, or for someone who knows how
 	@echo
 	tar zcf sagetex.tar.gz $(srcs) ../sagetex/example.pdf ../sagetex/sagetexpackage.pdf
 
-# this may seem silly, since running 'all' runs Sage just like the test
-# script does, but sometimes it scrolls by too fast, and I want obvious
-# output in front of me that tells me the results.
-test: all
-	clear
+# otherwise, make gets confused since there's a file named "test"
+.PHONY: test
+test:
 	./test
 
 # make a source distribution, used for building the spkg
 dist: all
 	python setup.py sdist --formats=tar
+
 
 \begin{sageblock}
   var('x')
-  f = log(sin(x)/x)
+  f(x) = log(sin(x)/x)
 \end{sageblock}
-The Taylor Series of $f$ is: $\sage{ f.taylor(x, 0, 10) }$.
+The Taylor Series of $f$ begins: $\sage{ f.taylor(x, 0, 10) }$.
 
 \section{Plotting}
 
 \sageplot{E.plot(-3,3)}
 
 \begin{sagesilent}
+  # the var line is unecessary unless you've defined x to be something
+  # other than a symbolic variable
   var('x')
-  f=-x^3+3*x^2+7*x-4
+  f(x) = -x^3+3*x^2+7*x-4
 \end{sagesilent}
 
 You can use variables to hold plot objects and do stuff with them.
 3D plotting right now is problematic because there's no convenient way
 to produce vector graphics. We can make PNGs, though, and since the
 \verb|sageplot| command defaults to EPS and PDF, \emph{you must specify
-a valid format for 3D plotting}. Sage right now (version 3.2.2) can't
+a valid format for 3D plotting}. Sage right now (version 3.4.2) can't
 produce EPS or PDF files from plot3d objects, so if you don't specify a
 valid format, things will go badly. You can specify the
 ``\texttt{imagemagick}'' option, which will use the Imagemagick
-#!/bin/bash
+#!/usr/bin/env bash
 
-# run Sage on the generated .sage files and see what happens.
+# this runs Sage on the generated .sage files to see if they work ok
+# this is basically the spkg-check file
 
-# In an ideal world, this could be automatically run as part of
-# doctesting, but for now this is about as good as we can do.
+function checkdotsage
+{
+    sage $1.sage
+    if [ $? -ne 0 ]
+    then
+        echo "Error running Sage on $1.sage!"
+        exit 1
+    else
+        echo "No problem that spkg-check can detect running Sage on $1.sage."
+    fi
+}
 
-for F in example sagetexpackage
-do
-  if [ $(sage $F.sage 2>&1 | grep -c 'failed') -gt 0 ]
-  then
-    echo "Error running Sage on $F.sage!"
-  else
-    echo "No problem running Sage on $F.sage."
-  fi
-done
+latex example.tex > /dev/null
+checkdotsage example
+
+latex sagetexpackage.dtx > /dev/null
+checkdotsage sagetexpackage
+
+# if we get here, we assume the .sage files are good, and exit successfully
+exit 0