From ef9a55314304f6a4eb756542304b3d20ffd91e46 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 9 May 2009 00:39:37 +0200 Subject: Initial contents --- Makefile.sample | 53 +++++++++++++++++++++ chapter1.nw | 15 ++++++ contents.tex | 9 ++++ index.tex | 12 +++++ intro.tex | 19 ++++++++ noweb.mk | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 253 insertions(+) create mode 100644 Makefile.sample create mode 100644 chapter1.nw create mode 100644 contents.tex create mode 100644 index.tex create mode 100644 intro.tex create mode 100644 noweb.mk diff --git a/Makefile.sample b/Makefile.sample new file mode 100644 index 0000000..da14ca9 --- /dev/null +++ b/Makefile.sample @@ -0,0 +1,53 @@ +# Author: Jose A Ortega Ruiz +# Start date: Mon Jan 06, 2003 01:15 +# +# Copyright (C) 2003, 2009 by Jose Antonio Ortega Ruiz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +# document languages (comma separated) +# NW_LANGUAGES = spanish + +# The name of the main tex file to be created +# NW_MAIN = main + +# File containing the main tex file contents (included nw files loaded with +# \input) +# NW_CONTENTS = contents.tex + +# The document class for the main tex file +# NW_DOCUMENT_CLASS ?= report + +# Files \input in the main file before noweb ones (listed in NW_CONTENTS) +NW_PRE_TEX = intro.tex +# Files \input in the main file after noweb ones (listed in NW_CONTENTS) +NW_POST_TEX = index.tex + +# List of dirs to recurse into +NW_SUBDIRS = . + +# Line format flag to noweb +# NW_LINEFORMAT = -L"\# %L \"%F\" %N" +NW_LINEFORMAT = + +# Location of noweb.mk +NW_MAKEFILE = noweb.mk + +include $(NW_MAKEFILE) + +# Your all target here. noweb.mk provides: tangle, weave, dvi, html, clean +all: tangle weave + diff --git a/chapter1.nw b/chapter1.nw new file mode 100644 index 0000000..03a85b9 --- /dev/null +++ b/chapter1.nw @@ -0,0 +1,15 @@ +% -*- mode: Noweb; noweb-code-mode: scheme-mode -*- + +% Noweb sample file, the first one \input in NW_CONTENTS + +\chapter{First sample chapter} + +Here you've got some code: + +<>= + +(define identity (lambda (x) x)) + +@ %def identity + +More text. diff --git a/contents.tex b/contents.tex new file mode 100644 index 0000000..8c58747 --- /dev/null +++ b/contents.tex @@ -0,0 +1,9 @@ +% This file, referenced as NW_CONTENTS in the Makefile, inputs the +% contents of the main tex file to be created. It will consist mainly +% of a series of input commands loading the different .nw files +% (without extension), but can contain arbitrary TeX code. + + +\input{chapter1} % chapter1.nw + + diff --git a/index.tex b/index.tex new file mode 100644 index 0000000..481b685 --- /dev/null +++ b/index.tex @@ -0,0 +1,12 @@ +% This file is listed in NW_POST_TEX in the Makefile, and, therefore, +% will be loaded after the ones listed in NW_CONTENTS, without +% weaving. + +\chapter{Index} +\noindent Here is a list of all identifiers and code chunks defined +and used in this document, and where they appear. Underlined entries +indicate the place of definition. +\subsubsection*{Identifiers} +\nowebindex +\subsubsection*{Chunks} +\nowebchunks diff --git a/intro.tex b/intro.tex new file mode 100644 index 0000000..7b8fc31 --- /dev/null +++ b/intro.tex @@ -0,0 +1,19 @@ +% This file is listed in NW_PRE_TEX in the Makefile, and, therefore, +% will be loaded before the ones listed in NW_CONTENTS, without +% weaving. + +\title{MzTube} +\author{Jos\'e A Ortega Ruiz} + +\maketitle + +\begin{abstract} + Your abstract goes here +\end{abstract} + +\tableofcontents + +\chapter{Introduction} +\label{sec:introduction} + +And put here the introductory text diff --git a/noweb.mk b/noweb.mk new file mode 100644 index 0000000..4abf01a --- /dev/null +++ b/noweb.mk @@ -0,0 +1,145 @@ +# Author: Jose A Ortega Ruiz +# Start date: Mon Jan 06, 2003 00:47 +# +# Copyright (C) 2003, 2009 by Jose Antonio Ortega Ruiz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +NOTANGLE ?= notangle +NOWEAVE ?= noweave +NOROOTS ?= noroots +CPIF ?= cpif +NODEFS ?= nodefs +NOINDEX ?= noindex + +NW_LINEFORMAT ?= -L"\# %L \"%F\" %N" +NW_MAIN ?= main +NW_DOCUMENT_CLASS ?= report +NW_CONTENTS ?= contents.tex + +f_notangle = $(NOTANGLE) $(NW_LINEFORMAT) -R$(2) $(1) | $(CPIF) $(2); +f_latex = $(1) '\scrollmode \input '"$(2)";\ + while grep -s 'Rerun to get cross-references right' $(2).log;\ + do $(1) '\scrollmode \input '"$(2)"; done +f_roots = $(shell $(NOROOTS) $(1) | sed -r 's/^(<<)(.*)>>$$/\2/') + +f_extract_inputs = $(strip $(shell \ + cat $(1) | grep '^\\input' | \ + sed -r 's/\\\input\{(.*)\}.*/\1/')) + +f_read_nw_files = $(foreach f, $(call f_extract_inputs, $(1)), $(dir $(1))$(f)) + +nw_contents_files = $(foreach d, $(NW_SUBDIRS), $d/$(NW_CONTENTS)) +nw_files = $(foreach f, $(nw_contents_files), $(call f_read_nw_files, $(f))) + +NW_FILES = $(strip $(nw_files)) + +nw_sources = $(NW_FILES:%=%.nw) +local_nw_files = $(call f_extract_inputs, $(NW_CONTENTS)) +local_nw_sources = $(local_nw_files:%=%.nw) +code_targets = $(local_nw_sources:%.nw=.%.tangle) +main_tex = $(NW_MAIN).tex +main_html = $(NW_MAIN).html +main_dvi = $(NW_MAIN).dvi +main_pdf = $(NW_MAIN).pdf +main_defs = $(NW_MAIN).defs +tex_files = $(NW_FILES:%=%.tex) +defs_files = $(NW_FILES:%=%.defs) +code_files = $(foreach f, $(NW_FILES), $(call f_roots, $(f).nw)) +code_dirs = $(sort $(filter-out ./, \ + $(foreach src, $(code_files), $(dir $(src))))) + + +%.tex : %.nw ; $(NOWEAVE) -n -indexfrom $(main_defs) $< > $@ + +%.defs : %.nw ; $(NODEFS) $< > $@ + +$(main_tex): $(nw_contents_files) $(main_defs) $(tex_files) \ + $(NW_PRE_TEX) $(NW_POST_TEX) + @echo "\documentclass[a4paper]{$(NW_DOCUMENT_CLASS)}" > $(main_tex) + @echo "\usepackage{noweb}" >> $(main_tex) + @echo "\noweboptions{longchunks}" >> $(main_tex) + @echo "\noweboptions{externalindex}" >> $(main_tex) + @if [ ! -z $(NW_LANGUAGES) ]; \ + then echo "\usepackage[$(NW_LANGUAGES)]{babel}" >> $(main_tex); fi + @echo "\usepackage[utf8]{inputenc}" >> $(main_tex) + @for f in $(NW_PACKAGES); do echo "\usepackage{$$f}" >> $(main_tex); \ + done + @echo "\usepackage{hyperref}" >> $(main_tex) + @echo "\begin{document}" >> $(main_tex) + @for f in $(NW_PRE_TEX); do echo "\input{$$f}" >> $(main_tex); done + @for f in $(nw_contents_files); do \ + foo=`dirname $$f`; \ + cat $$f | grep -v "^%" | \ + sed -r "s/\\\input\{(.+)\}/\\\input\{$$foo\/\1\}/" \ + >> $(main_tex); done + @for f in $(NW_POST_TEX); do echo "\input{$$f}" >> $(main_tex); done + @echo "\\end{document}" >> $(main_tex) + +$(code_dirs): $(nw_sources) + mkdir -p $@ + +$(code_targets): .%.tangle: %.nw + $(foreach root, $(call f_roots,$<), $(call f_notangle,$<,$(root))) + touch $@ + +$(main_defs): $(defs_files) + sort -u $(defs_files) | $(CPIF) $(main_defs) + +$(main_dvi): $(main_defs) $(tex_files) $(main_tex) $(nw_sources) + latex $(NW_MAIN) + $(NOINDEX) $(NW_MAIN) + $(call f_latex, latex, $(NW_MAIN)) + +$(main_pdf): $(main_defs) $(tex_files) $(main_tex) $(nw_sources) + pdflatex $(NW_MAIN) + $(NOINDEX) $(NW_MAIN) + $(call f_latex, pdflatex, $(NW_MAIN)) + +$(main_html): $(nw_sources) + cat $(nw_sources) > $(NW_MAIN).nw + $(NOWEAVE) -filter l2h -index -html $(NW_MAIN).nw | htmltoc \ + > $(main_html) + rm -f $(NW_MAIN).nw + +tangle: t_subdirs = $(filter-out ., $(NW_SUBDIRS)) +tangle: $(code_dirs) $(code_targets) + for d in $(t_subdirs); do cd $$d && $(MAKE) tangle; done + +weave: $(main_defs) $(tex_files) $(main_tex) + +debug: + @echo "sources: $(nw_sources)" + @echo "contents files: $(nw_contents_files)" + @echo "noweb files: $(NW_FILES)" + @echo "code targets: $(code_targets)" + @echo "tex files: $(tex_files)" + +dvi: $(main_dvi) + +pdf: $(main_pdf) + +html: $(main_html) + +NW_TRASH_FILES = $(code_targets) $(code_files) $(tex_files) $(defs_files) \ + $(main_html) $(main_defs) $(main_tex) $(main_pdf) \ + $(NW_MAIN).out $(NW_MAIN).nwi *.toc *.log *.aux *.dvi + +clean: + rm -rf $(NW_TRASH_FILES) + +.PHONY: clean dvi html weave tangle + -- cgit v1.2.3