From 673f7bc25a7efd5169536e46767d1425f9c271e1 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 9 Jul 2001 18:34:15 +0000 Subject: [PATCH] tex.mk: Some new targets and some bugfixes --- make/tex.mk | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/make/tex.mk b/make/tex.mk index 6d4fcfef..7ea05b8e 100644 --- a/make/tex.mk +++ b/make/tex.mk @@ -3,19 +3,31 @@ # contact@jannet.de # $Id$ -CFG_VARS = PROJECT DISTDIR HTMLDIR TARGET_HOST TARGET_DIR \ - TARGET_DIR_MODE TARGET_FILE_MODE TARGET_USER MAIN FMT_OFFLINE = tex dvi ps pdf txt FMT = $(FMT_OFFLINE) html OUT = $(DISTDIR)/$(PROJECT) FMT_OUT = $(patsubst %,$(OUT).%.zip,$(FMT)) FMT_OFFLINE_OUT = $(patsubst %,$(OUT).%.zip,$(FMT_OFFLINE)) ALL = $(FMT_OUT) html_install -TEXSRC = $(wildcard *.tex *.gif *.bmp Makefile) +PRE_HTML = $(patsubst %.tmpl,%,$(wildcard *.html.tmpl)) +PRE_TEX = $(patsubst %.tmpl,%,$(wildcard *.tex.tmpl)) +TEXSRC = $(wildcard *.tex $(IMAGEDIR)/* $(LOCAL_SRC)) $(PRE_TEX) + +DATE := $(shell date +'%b, %d, %Y') WD = `pwd` NEWDIRS = $(DISTDIR) $(HTMLDIR) $(DVIDIR) +define replace_macros + @echo replacing macros in templates + cat $< | sed -e "\ + s/__DATE__/$(DATE)/g; \ + s/__AUTHORS__/$(AUTHORS)/g; \ + s/__TITLE__/$(TITLE)/g; \ + s/__SUBTITLE__/$(SUBTITLE)/g; \ + " > $@ +endef + all: $(ALL) tex: $(OUT).tex.zip @@ -24,6 +36,12 @@ ps: $(OUT).ps.zip txt: $(OUT).txt.zip html: $(OUT).html.zip +%.tex: %.tex.tmpl + $(replace_macros) + +%.html: %.html.tmpl + $(replace_macros) + cfgtest.done: test -n "$(PROJECT)" # PROJECT test -n "$(DISTDIR)" # DISTDIR @@ -34,6 +52,10 @@ cfgtest.done: test -n "$(TARGET_FILE_MODE)" # TARGET_FILE_MODE test -n "$(TARGET_USER)" # TARGET_USER test -n "$(MAIN)" # MAIN + test -n "$(IMAGEDIR)" # MAIN + test -n "$(AUTHORS)" # AUTHORS + test -n "$(TITLE)" # TITLE + test -n "$(SUBTITLE)" # SUBTITLE touch $@ cfgtest: cfgtest.done @@ -61,6 +83,7 @@ $(OUT).tex.zip: cfgtest dirs $(TEXSRC) $(PROJECT).dvi: $(TEXSRC) @echo "-- creating dvi file" + echo $(TEXSRC) latex $(MAIN).tex; latex $(MAIN).tex; latex $(MAIN).tex; cp $(MAIN).dvi $@ @@ -74,7 +97,7 @@ $(PROJECT).txt: $(PROJECT).dvi $(OUT).txt.zip: $(PROJECT).txt zip $@ $< -$(HTMLDIR): $(TEXSRC) $(FMT_OFFLINE_OUT) +$(HTMLDIR): $(TEXSRC) $(FMT_OFFLINE_OUT) $(PRE_HTML) test $(MAIN) != index rm -rf $@ mkdir -p $@ @@ -83,13 +106,14 @@ $(HTMLDIR): $(TEXSRC) $(FMT_OFFLINE_OUT) rm $(HTMLDIR)/$(MAIN).html cd $(HTMLDIR); sed "s/$(MAIN).html/index.html/g;" node1.html > node1.html.new ; mv node1.html.new node1.html cp -r $(DISTDIR) $@/download - cat index_template_head.html > $(HTMLDIR)/index.html - for FILE in $(DISTDIR); do SIZE=`ls -lk $$FILE | awk '{print $$5}'`;\ - echo \\$$FILE \(size = $$SIZE Bytes\)\\ >> $(HTMLDIR)/index.html ;\ + cat index_head.html > $(HTMLDIR)/index.html + for FILE in $(wildcard $(DISTDIR)/*); do SIZE=`ls -lk $$FILE | awk '{print $$5}'`;\ + echo \\`basename $$FILE`\ + \(size = $$SIZE Bytes\)\\ >> $(HTMLDIR)/index.html ;\ echo >> $(HTMLDIR)/index.html ;\ done - cat index_template_tail.html >> $(HTMLDIR)/index.html - cp *.gif $(HTMLDIR) + cat index_tail.html >> $(HTMLDIR)/index.html + cp $(IMAGEDIR)/* $(HTMLDIR) touch $@ $(OUT).html.zip: dirs $(HTMLDIR) @@ -114,11 +138,12 @@ html_install: $(HTMLDIR) @echo "-- installing html to $(TARGET_HOST):$(TARGET_DIR) as user $(TARGET_USER)" ssh -l $(TARGET_USER) $(TARGET_HOST) -C "\ mkdir -p $(TARGET_DIR); chmod $(TARGET_DIR_MODE) $(TARGET_DIR)" - /usr/bin/rsync -a --delete -v --links -e /usr/bin/ssh $(HTMLDIR)/* $(TARGET_USER)@$(TARGET_HOST):$(TARGET_DIR) + /usr/bin/rsync -az --delete -v --links -e /usr/bin/ssh $(HTMLDIR)/* $(TARGET_USER)@$(TARGET_HOST):$(TARGET_DIR) ssh -l $(TARGET_USER) $(TARGET_HOST) -C "\ cd $(TARGET_DIR); find . -type d | xargs chmod $(TARGET_DIR_MODE); find . -type f | xargs chmod $(TARGET_FILE_MODE)" clean: @echo "-- cleaning up ..." - rm -rf *.aux *.toc *.dvi *.pdf *.ps *~ *.log *.done $(NEWDIRS) + rm -rf *.aux *.toc *.dvi *.pdf *.ps *~ *.log *.done \ + $(NEWDIRS) $(PRE_TEX) $(PRE_HTML) $(PROJECT).txt