From 76f457cbe78101034f0254a9ea940ca65cee1535 Mon Sep 17 00:00:00 2001
From: mdw <mdw>
Date: Tue, 2 Oct 2001 23:05:52 +0000
Subject: [PATCH] Turn .sty to .cls, use .cfg files for config, add no-answers
 version.

---
 .cvsignore         |  4 ++--
 Makefile           | 39 ++++++++++++++++++++++++++++++---------
 ips.sty => ips.cls | 23 ++++++++++++++++++++---
 ips.tex            |  6 ++----
 slides.tex         | 10 ----------
 5 files changed, 54 insertions(+), 28 deletions(-)
 rename ips.sty => ips.cls (93%)
 delete mode 100644 slides.tex

diff --git a/.cvsignore b/.cvsignore
index 0382342..8553af5 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,2 +1,2 @@
-slides
-ips.ps slides.ps ips.pdf slides.pdf ips.dvi slides.dvi ips.log auth-mac.aux auth-sig.aux basics.aux enc-ies.aux enc-intro.aux enc-pub.aux enc-symm.aux ips.aux ips.ans ips.toc ips.bbl ips.blg
+slides noans
+*.ps *.pdf *.dvi *.log *.aux *.ans *.toc *.bbl *.blg
diff --git a/Makefile b/Makefile
index 8630a4d..6b29398 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,15 @@
 # Makefile for IPS
 
 SOURCES = \
-	ips.tex slides.tex ips.sty \
+	ips.tex ips.cls \
 	basics.tex \
 	auth-mac.tex auth-sig.tex \
 	enc-intro.tex enc-pub.tex enc-symm.tex enc-ies.tex
 
-all: ips.dvi ips.ps ips.pdf slides.dvi slides.ps slides.pdf
+all: \
+	ips.dvi ips.ps ips.pdf \
+	noans.dvi noans.ps noans.pdf \
+	slides.dvi slides.ps slides.pdf
 
 ips.dvi: $(SOURCES)
 	latex ips && bibtex ips && \
@@ -16,23 +19,41 @@ ips.pdf: ips.dvi
 ips.ps: ips.dvi
 	dvips -o ips.ps ips.dvi
 
+noans.dvi: $(SOURCES)
+	@if [ ! -d noans ]; then \
+	  mkdir noans; \
+	  for i in $(SOURCES); do ln -s ../$$i noans; done; \
+	  echo '\ipsanswersfalse' >noans/ips.cfg; \
+	fi
+	cd noans && \
+	latex ips && bibtex ips && \
+	latex ips && latex ips && \
+	cp ips.dvi ../noans.dvi
+noans.pdf: noans.dvi
+	cd noans && pdflatex ips.tex && cp ips.pdf ../noans.pdf
+noans.ps: noans.dvi
+	dvips -o noans.ps noans.dvi
+
 slides.dvi: $(SOURCES)
 	@if [ ! -d slides ]; then \
 	  mkdir slides; \
 	  for i in $(SOURCES); do ln -s ../$$i slides; done; \
+	  echo '\ipsslidestrue' >slides/ips.cfg; \
 	fi
 	cd slides && \
-	latex slides && bibtex slides && \
-	latex slides && latex slides && \
-	cp slides.dvi ..
+	latex ips && bibtex ips && \
+	latex ips && latex ips && \
+	cp ips.dvi ../slides.dvi
 slides.pdf: slides.dvi
-	cd slides && pdflatex slides.tex && cp slides.pdf ..
+	cd slides && pdflatex ips.tex && cp ips.pdf ../slides.pdf
 slides.ps: slides.dvi
 	dvips -o slides.ps slides.dvi
 
 clean:
-	rm -f ips.dvi ips.ps ips.pdf slides.dvi slides.ps slides.pdf
-	rm -f *.log *.bbl *.blg *.toc *.ans
-	rm -rf slides ips
+	rm -f ips.dvi ips.ps ips.pdf
+	rm -f noans.dvi noans.ps noans.pdf
+	rm -f slides.dvi slides.ps slides.pdf
+	rm -f *.log *.bbl *.blg *.toc *.ans *.aux
+	rm -rf slides noans ips.cfg
 
 .PHONY: clean
diff --git a/ips.sty b/ips.cls
similarity index 93%
rename from ips.sty
rename to ips.cls
index 8375e7b..2ecc62a 100644
--- a/ips.sty
+++ b/ips.cls
@@ -2,6 +2,24 @@
 %%%
 %%% Definitions for IPS course
 
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{ips}[2001/10/02]
+
+%%%----- Document class stuff -----------------------------------------------
+
+\newif\ifipsslides \ipsslidesfalse
+\newif\ifipsanswers \ipsanswerstrue
+\InputIfFileExists{ips.cfg}\relax\relax
+
+\ifipsslides
+  \PassOptionsToClass{a4, slidesonly}{seminar}
+\else
+  \PassOptionsToClass{a4, article, twoside}{seminar}
+\fi
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{seminar}}
+\ProcessOptions
+\LoadClass{seminar}
+
 %%%----- Required packages --------------------------------------------------
 
 \RequirePackage[palatino, helvetica, courier, maths=cmr]{mdwfonts}
@@ -13,9 +31,8 @@
 \RequirePackage{url}
 
 \ifx\pdfoutput\@@undefined
-  \def\next{\RequirePackage[all, dvips]{xy}}
+  \PassOptionsToPackage{dvips}{xy}
 \else
-  \def\next{\RequirePackage[all]{xy}}
   \ifarticle
     \pdfpagewidth\paperwidth
     \pdfpageheight\paperheight
@@ -24,7 +41,7 @@
     \pdfpageheight\paperwidth
   \fi
 \fi
-\next
+\RequirePackage[all]{xy}
 
 %%%----- Miscellaneous settings ---------------------------------------------
 
diff --git a/ips.tex b/ips.tex
index 8702127..ad1b04c 100644
--- a/ips.tex
+++ b/ips.tex
@@ -2,8 +2,7 @@
 %%%
 %%% Main document sequencing for IPS course
 
-\ifx\printslides\notdef\documentclass[a4, article, twoside]{seminar}\fi
-\usepackage{ips}
+\documentclass{ips}
 
 \title{Introduction to Provable Security}
 \author{Mark Wooding}
@@ -39,8 +38,7 @@
 %% \include{zk}
 %% \include{chan}
 
-\section{Answers to exercises}
-\answers
+\ifipsanswers\section{Answers to exercises}\answers\fi
 
 \section{Acknowledgements}
 
diff --git a/slides.tex b/slides.tex
deleted file mode 100644
index 2773783..0000000
--- a/slides.tex
+++ /dev/null
@@ -1,10 +0,0 @@
-\documentclass[a4, slidesonly]{seminar}
-\let\printslides\relax
-\input{ips}
-
-\endinput
-
-%%% Local Variables: 
-%%% mode: latex
-%%% TeX-master: t
-%%% End: 
-- 
2.11.0

