# generic utility modules # (c) 2001 jannet it services # contact@jannet.de # $Id$ IMAGES = $(patsubst %,$(IMAGEDIR)/%,$(FRONTLOGO_EPS) $(FRONTLOGO_WEB) \ $(ICON_UP) $(ICON_PREV) $(ICON_NEXT) $(ICON_INDEX) $(ICON_CONTENTS)) LOCAL_IMPORTED_TEMPLATES = $(notdir $(IMPORTED_TEMPLATES)) FMT_OFFLINE = tex dvi ps pdf txt FMT = $(FMT_OFFLINE) html OUT = $(DISTDIR)/$(OUTPUT) FMT_OUT = $(patsubst %,$(OUT).%.zip,$(FMT)) FMT_OFFLINE_OUT = $(patsubst %,$(OUT).%.zip,$(FMT_OFFLINE)) ALL = $(FMT_OUT) html_install PRE_HTML = $(patsubst %.tmpl,%,$(wildcard *.html.tmpl)) PRE_TEX = $(patsubst %.ger,%.tex,$(patsubst %.tmpl,%,$(wildcard *.tex.tmpl *.ger) $(LOCAL_IMPORTED_TEMPLATES))) TEXSRC = $(wildcard *.tex $(IMAGES) $(LOCAL_SRC)) $(PRE_TEX) DATE := $(shell date +'%b, %d, %Y') TEX_WARN_DONT_EDIT = "\ %+---------------------------------------------------+\n\ %| DO NOT EDIT THIS FILE! |\n\ %| It was automatically created during the build |\n\ %| process! |\n\ %+---------------------------------------------------+\n" WD = `pwd` NEWDIRS = $(DISTDIR) $(HTMLDIR) $(DVIDIR) define replace_macros @echo replacing macros in templates TMPIMAGEDIR="`echo $(IMAGEDIR) | sed -e 's/\//\\\\\//g;'`" ;\ cat $< | sed -e "\ s/__DATE__/$(DATE)/g; \ s/__AUTHORS__/$(AUTHORS)/g; \ s/__TITLE__/$(TITLE)/g; \ s/__VERSION__/$(VERSION)/g; \ s/__SUBTITLE__/$(SUBTITLE)/g; \ s/__HEADER__/$(HEADER)/g; \ s/__FRONTPAGE__/$(FRONTPAGE)/g; \ s/__FRONTLOGO_EPS__/$$TMPIMAGEDIR\/$(FRONTLOGO_EPS)/g; \ s/__FRONTLOGO_WEB__/$(FRONTLOGO_WEB)/g; \ s/__ICON_UP__/$(ICON_UP)/g; \ s/__ICON_INDEX__/$(ICON_INDEX)/g; \ s/__ICON_CONTENTS__/$(ICON_CONTENTS)/g; \ s/__ICON_PREV__/$(ICON_PREV)/g; \ s/__ICON_NEXT__/$(ICON_NEXT)/g; \ " >> $@ endef define replace_umlauts @echo replacing german umlauts with tex-style umlauts @echo -e $(TEX_WARN_DONT_EDIT) > $@ cat $< | sed -e "\ s/ä/\"a/g; \ s/Ä/\"A/g; \ s/ö/\"o/g; \ s/Ö/\"O/g; \ s/ü/\"u/g; \ s/Ü/\"Ü/g; \ s/ß/\"s/g; \ " >> $@ endef all: dirs $(ALL) tex: dirs $(OUT).tex.zip dvi: dirs $(OUT).dvi.zip ps: dirs $(OUT).ps.zip txt: dirs $(OUT).txt.zip html: dirs $(OUT).html.zip pdf: dirs $(OUT).pdf.zip %.tex: %.ger $(replace_umlauts) %.tex: %.tex.tmpl $(replace_macros) %.html: %.html.tmpl $(replace_macros) %.tmpl: cp $(TEX_TMPL_DIR)/$@ . cfgtest.done: test -n "$(OUTPUT)" # OUTPUT test -n "$(DISTDIR)" # DISTDIR test -n "$(HTMLDIR)" # HTMLDIR test -n "$(TARGET_HOST)" # TARGET_HOST test -n "$(TARGET_DIR)" # TARGET_DIR test -n "$(TARGET_DIR_MODE)" # TARGET_DIR_MODE test -n "$(TARGET_FILE_MODE)" # TARGET_FILE_MODE test -n "$(TARGET_USER)" # TARGET_USER test -n "$(MAIN)" # MAIN test -n "$(FRONTPAGE)" # FRONTPAGE test -n "$(IMAGES)" # IMAGES test -n "$(AUTHORS)" # AUTHORS test -n "$(TITLE)" # TITLE test -n "$(SUBTITLE)" # SUBTITLE test -d "$(IMAGEDIR)" # IMAGEDIR @for IMG in $(IMAGES); do if [ ! -f $$IMG ]; then echo "$$IMG is missing"; exit 1; fi; done test -n "$(VERSION)" # VERSION touch $@ cfgtest: cfgtest.done #%.clean: # rm -rf $(OUT).%.zip dirs.done: mkdir -p $(NEWDIRS) touch dirs.done dirs: dirs.done arch: test $(shell uname -s) = Linux xdvi: $(TEXSRC) @echo "-- running latex just once ..." latex $(MAIN).tex xdvi $(MAIN).dvi $(OUT).tex.zip: cfgtest $(TEXSRC) @echo "-- creating zipfile with tex source files" zip $@ $(TEXSRC) 2>/dev/null $(OUTPUT).dvi: $(TEXSRC) @echo "-- creating dvi file" echo $(TEXSRC) latex $(MAIN).tex; latex $(MAIN).tex; latex $(MAIN).tex; cp $(MAIN).dvi $@ $(OUT).dvi.zip: $(OUTPUT).dvi $(wildcard *.eps) zip $@ $^ $(OUTPUT).txt: $(OUTPUT).dvi @echo "-- creating plain ascii file" dvi2tty $< -w100 -o $@ $(OUT).txt.zip: $(OUTPUT).txt zip $@ $< $(HTMLDIR): $(TEXSRC) $(FMT_OFFLINE_OUT) $(PRE_HTML) test $(MAIN) != index rm -rf $@ mkdir -p $@ latex2html -split 4 -show_section_numbers -dir $(HTMLDIR) $(MAIN).tex for OLD in $(HTMLDIR)/*.html; do \ sed "s/file:\/usr\/lib\/latex2html\/icons\///g; s/$(MAIN).html/node1.html/g;" $$OLD>$$OLD.new; \ mv $$OLD.new $$OLD; \ done rm $(HTMLDIR)/$(MAIN).html cp -r $(DISTDIR) $@/download 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_tail.html >> $(HTMLDIR)/index.html cp $(IMAGES) $(HTMLDIR) touch $@ $(OUT).html.zip: $(HTMLDIR) @echo "-- creating zipfile with html source files" zip -r $@ $(HTMLDIR) $(OUTPUT).ps: $(OUTPUT).dvi @echo "-- creating postscript file" dvips $< $(OUT).ps.zip: $(OUTPUT).ps zip $@ $< $(OUTPUT).pdf: $(OUTPUT).ps @echo "-- creating pdf file" ps2pdf $< $(OUT).pdf.zip: $(OUTPUT).pdf zip $@ $< 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 -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) $(PRE_TEX) $(PRE_HTML) $(OUTPUT).txt \ $(LOCAL_IMPORTED_TEMPLATES)