#
#  Makefile for cool.ps
#
.SUFFIXES: .fig .latex

CHAPTERS = 	intro/preface.tex \
		basics/hw.tex basics/sw.tex \
		mm/memory.tex \
		kernel/processes.tex \
		ipc/ipc.tex \
		dd/drivers.tex dd/interrupts.tex dd/pci.tex \
		fs/filesystem.tex \
		net/net.tex \
		kernel/kernel.tex \
		sources/sources.tex \
		modules/modules.tex

MISC = 		tlk2e.sty \
		misc/copyright.tex \
		misc/dedication.tex  \
		misc/definitions.tex \
		misc/macros.tex 

PICTURES = 	basics/board.latex \
		mm/vm.latex mm/pte.latex mm/vm_area.latex \
		mm/free-area.latex mm/vm-axp.latex \
		mm/page-tables.latex mm/mm.latex \
		mm/shm.latex mm/page-cache.latex \
		dd/pci-structures.latex \
		dd/pci-system.latex dd/pci-bars.latex dd/pci-config-header.latex \
		dd/pci-pci-config-eg-1.latex dd/pci-pci-config-eg-2.latex \
		dd/pci-pci-config-eg-3.latex dd/pci-pci-config-eg-4.latex \
		dd/pci-cycle-0.latex dd/pci-cycle-1.latex \
		dd/interrupts.latex dd/interrupt-handling.latex \
		dd/blk_dev.latex dd/gendisk.latex \
		dd/scsi.latex dd/chrdevs.latex \
		fs/ext2_inode.latex fs/ext2.latex fs/ext2_dir.latex \
		fs/file-systems.latex fs/vfs.latex fs/mounted.latex \
		fs/buffer-cache.latex \
		modules/modules.latex \
		kernel/bh.latex kernel/tqueue.latex kernel/timers.latex \
		kernel/binfmt.latex kernel/files.latex ipc/pipes.latex \
		kernel/process-vm.latex kernel/elf.latex \
		ipc/msg.latex ipc/shm.latex ipc/sem.latex \
		net/protocols.latex net/fib.latex net/sk_buff.latex \
		net/layers.latex net/sockets.latex

APPENDICES = \
		appendices/glossary.tex \
		appendices/www.tex \
		appendices/axp.tex \
		appendices/bibliography.tex \
		appendices/gpl.tex \
		ds/ds.tex ds/sk_buff.tex ds/device.tex ds/mem_map_t.tex \
		ds/mm_struct.tex ds/vm_area_struct.tex ds/task_struct.tex \
		ds/files_struct.tex ds/fs_struct.tex ds/file.tex \
		ds/ipc_perm.tex ds/timer_list.tex ds/linux_binfmt.tex \
		ds/pci_dev.tex ds/pci_bus.tex ds/irqaction.tex ds/device_struct.tex \
		ds/blk_dev_struct.tex ds/device.tex ds/request.tex ds/gendisk.tex ds/inode.tex \
		ds/buffer_head.tex ds/socket.tex ds/sock.tex \
		ds/rtable.tex ds/tq_struct.tex ds/semaphore.tex 

tlk.dvi:	tlk.tex $(MISC) $(CHAPTERS) $(PICTURES) $(APPENDICES) version.tex
		./version
		latex tlk.tex
		latex tlk.tex

chapter.dvi:	chapter.tex $(MISC) $(CHAPTERS) $(PICTURES) $(APPENDICES)
	latex chapter.tex
	latex chapter.tex

tlk.ps:	tlk.dvi
	dvips -o tlk.ps tlk.dvi

all:		tlk.ps
	echo	'done'

figures:	$(PICTURES)
	echo	'done'

#
# Index
#
index:		tlk.dvi
	makeindex -o tlk.ind tlk.idx
	latex tlk.tex
	
#
# Pictures.
#
.fig.latex:
	fig2dev -L latex $< > $@

#
# Index
#
tlk.ind:		tlk.idx $(CHAPTERS)
	makeindex -o tlk.ind tlk.idx

#
#
# Always clean up...
#
clean:		
	rm -f *.log *.toc *.aux *~
	rm -f *.ps *.dvi
	rm -f ./*/*.latex ./*/*.aux ./*/*~
	rm -f *.idx *.ind
	rm -f *.ilg *.lof
	rm -f ./*/*.bak
	rcsclean


