Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, December 8, 2022

File: [Platon] / doc / grafy-zbierka / Rules.make (download)

Revision 1.1, Fri Jul 18 17:07:37 2003 UTC (19 years, 4 months ago) by nepto

Document "grafy-zbierka" imported into CVS.

##
## Rules.make - make rules for ztp-zbierka
##              This file is included by 'make' from Makefile
##
## Developed by Lubomir Host 'rajo' <rajo AT platon.sk>
## Copyright (c) 2003 Platon SDG
## Licensed under terms of GNU General Public License.
## All rights reserved.
##
## $Platon$
##

##
## Usage:
##   Include this file in your Makefile and set
##       USE_CSLATEX = 1
##   or
##       USE_LATEX = 1
##   or
##       USE_CSTEX = 1
##   or
##       USE_TEX = 1
##
##   Specify also output:
##
##       ps__OUTPUT = diplomovka.ps
##       pdf_OUTPUT = diplomovka.pdf
##

##
## TeX compiler setup
## {{{

## if USE_CSLATEX defined, try compile *.tex with `cslatex'
## fallback to `latex' if `cslatex' not found
ifdef USE_CSLATEX
    LATEX    := $(shell if [ -x "`which cslatex`" ];    then echo "cslatex";    else echo "latex";    fi 2>/dev/null)
    PDFLATEX := $(shell if [ -x "`which pdfcslatex`" ]; then echo "pdfcslatex"; else echo "pdflatex"; fi 2>/dev/null)
endif
## if USE_LATEX defined, try compile *.tex with `latex'
## fallback to `tex' if `latex' not found
ifdef USE_LATEX
    LATEX    := $(shell if [ -x "`which latex`" ];    then echo "latex";    else echo "tex";    fi 2>/dev/null)
    PDFLATEX := $(shell if [ -x "`which pdflatex`" ]; then echo "pdflatex"; else echo "pdftex"; fi 2>/dev/null)
endif
## define USE_CSTEX if you will use `csplain' instead of `tex'
## if `csplain' is not found, fallback to `tex'
ifdef USE_CSTEX
    LATEX    := $(shell if [ -x "`which csplain`" ];    then echo "csplain";    else echo "tex";    fi 2>/dev/null)
    PDFLATEX := $(shell if [ -x "`which pdfcsplain`" ]; then echo "pdfcsplain"; else echo "pdftex"; fi 2>/dev/null)
endif
## define USE_TEX if you will use `tex'
ifdef USE_TEX
    LATEX    := $(shell if [ -x "`which tex`" ];    then echo "tex";    fi 2>/dev/null)
    PDFLATEX := $(shell if [ -x "`which pdftex`" ]; then echo "pdftex"; fi 2>/dev/null)
endif


LATEX_BATCH    := $(LATEX) -interaction=batchmode
PDFLATEX_BATCH := $(PDFLATEX) -interaction=batchmode
## }}}

export IMAGES_DIR
export DEPEND
DEPEND_all  = $(DEPEND) $(IMAGES) $(DATA) $(GRAPHS) $(AUTOGENERATED_FILES)

OUTPUT            = $(ps__OUTPUT) $(pdf_OUTPUT)
export OUTPUT
export ps__OUTPUT
export pdf_OUTPUT

ps__INPUT    = $(patsubst %.ps,%.tex,$(ps__OUTPUT))
pdf_INPUT    = $(patsubst %.pdf,%.tex,$(pdf_OUTPUT))
export ps__INPUT
export pdf_INPUT

DVI_ps__OUTPUT    = $(patsubst %.ps,%.dvi,$(ps__OUTPUT))
DVI_pdf_OUTPUT    = $(patsubst %.pdf,%.dvi,$(pdf_OUTPUT))
DVI_OUTPUT        = $(DVI_ps__OUTPUT) $(DVI_pdf_OUTPUT)

ps__OUTPUT_first  = $(patsubst %.ps,.ps__first.%,$(ps__OUTPUT))
pdf_OUTPUT_first  = $(patsubst %.pdf,.pdf_first.%,$(pdf_OUTPUT))
OUTPUT_first      = $(ps__OUTPUT_first)

ps__OUTPUT_second = $(patsubst %.ps,.ps__second.%,$(ps__OUTPUT))
pdf_OUTPUT_second = $(patsubst %.pdf,.pdf_second.%,$(pdf_OUTPUT))
OUTPUT_second     = $(ps__OUTPUT_second)

ps__OUTPUT_third  = $(patsubst %.ps,.ps__third.%,$(ps__OUTPUT))
pdf_OUTPUT_third  = $(patsubst %.pdf,.pdf_third.%,$(pdf_OUTPUT))
OUTPUT_third      = $(ps__OUTPUT_third)

.SUFFIXES:

##
## Now create target `all'
##
## With variables $(ps__OUTPUT) and $(pdf_OUTPUT) you can customize,
## which type of output you will create.
##
ifdef ps__OUTPUT
all: $(DEPEND) $(AUTOGENERATED_FILES) ps-subdir
endif

ifdef pdf_OUTPUT
all: $(DEPEND) $(AUTOGENERATED_FILES) pdf-subdir

ifdef ps__OUTPUT
all: $(DEPEND) $(AUTOGENERATED_FILES) ps-subdir pdf-subdir
endif

endif
## end of taget `all'

ifdef COLORIZE_SHELL_CMDS
COLOR_COMMANDS     = echo -en '';
END_COLOR_COMMANDS = echo -en '';
endif

#
# Debugging:
# - run shell with -v flag
debug:
    @echo "Runnig debug mode:"; \
     echo "All shell commands are color"; echo;
    $(MAKE) SHELL='$(SHELL) -v' $(COLORS)

#
# Colorizing shell commands:
#
color:
    $(MAKE) COLORIZE_SHELL_CMDS=1

ps-subdir:
    @$(COLOR_COMMANDS)
    -@./build-struct "PostScript" \
        && $(MAKE) -C PostScript PostScript
    @$(END_COLOR_COMMANDS)

pdf-subdir:
    -@./build-struct "PDF" \
        && $(MAKE) -C PDF PDF

PostScript: $(ps__OUTPUT_first) $(ps__OUTPUT_second) $(ps__OUTPUT_third) $(DVI_ps__OUTPUT) $(ps__OUTPUT)

PDF: $(pdf_OUTPUT_first) $(pdf_OUTPUT)

# AUTOGENERATED_FILES: -- images
# gnuplot generated images
$(IMAGES_DIR)/%.eps: $(IMAGES_DIR)/%.gpi $(IMAGES_DIR)/*.dat
    @$(COLOR_COMMANDS)
    @echo "Creating gnuplot image '$@'"
    cd images \
    && $(GNUPLOT) $(*F).gpi
$(IMAGES_DIR)/%.pdf: $(IMAGES_DIR)/%.eps
    @echo "Converting image to '$@'"
    epstopdf $<
    @$(END_COLOR_COMMANDS)
# XFig generated images
$(IMAGES_DIR)/%.png: $(IMAGES_DIR)/%.fig
    @$(COLOR_COMMANDS)
    @echo "Creating XFig image '$@'"
    cd images \
    &&  fig2dev -L png $(*F).fig > $(*F).png
$(IMAGES_DIR)/%.eps: $(IMAGES_DIR)/%.fig
    @$(COLOR_COMMANDS)
    @echo "Creating XFig image '$@'"
    cd images \
    &&  fig2dev -L eps $(*F).fig > $(*F).eps

%.ps: %.dvi .ps__first.% .ps__second.% .ps__third.%
    @$(COLOR_COMMANDS)
    $(DVIPS) -o $@ $<
    @$(END_COLOR_COMMANDS)

%.pdf: .pdf_first.% $(DEPEND_all)
    @$(COLOR_COMMANDS)
    @file="`echo '$@'`"; \
    echo "$(PDFLATEX) $${file%.pdf}.tex"; \
    $(PDFLATEX) $${file%.pdf}.tex \
        || (cat $${file%.pdf}.log; \
            rm -f    .pdf_first.$${file%.pdf} \
                    .pdf_second.$${file%.pdf} \
                    .pdf_third.$${file%.pdf}; exit 1)
    @$(END_COLOR_COMMANDS)

%.dvi: .ps__third.%

.ps__third.%: %.tex $(DEPEND_all) .ps__second.%
    @$(COLOR_COMMANDS)
    @file="`echo '$@' | sed 's/^.ps__third.//g;'`"; \
    echo "$(LATEX) $<"; \
    $(END_COLOR_COMMANDS) \
    $(LATEX) $< \
        && touch $@ \
        || (rm -f    .ps__first.$${file} \
                    .ps__second.$${file} \
                    .ps__third.$${file}; exit 1)
    @$(END_COLOR_COMMANDS)

.ps__second.%: .ps__first.%
    @$(COLOR_COMMANDS)
    @file="`echo '$@' | sed 's/^.ps__second.//g;'`"; \
    echo "$(LATEX_BATCH) $${file}.tex"; \
    $(END_COLOR_COMMANDS) \
    $(LATEX_BATCH) $${file}.tex \
        && touch $@ \
        || (cat $${file}.log; \
            rm -f    .ps__first.$${file} \
                    .ps__second.$${file} \
                    .ps__third.$${file}; exit 1)
    @$(END_COLOR_COMMANDS)
    
.pdf_first.%:
    @$(COLOR_COMMANDS)
    @file="`echo '$@' | sed 's/^.pdf_first.//g;'`"; \
    echo "$(PDFLATEX_BATCH) $${file}.tex"; \
    $(END_COLOR_COMMANDS) \
    $(PDFLATEX_BATCH) $${file}.tex \
        && touch $@ && touch --date="1 second ago" $${file}.pdf \
        || (cat $${file}.log; \
            rm -f    .pdf_first.$${file} \
                    .pdf_second.$${file} \
                    .pdf_third.$${file}; exit 1)
    @$(END_COLOR_COMMANDS)

.ps__first.%:
    @$(COLOR_COMMANDS)
    @file="`echo '$@' | sed 's/^.ps__first.//g;'`"; \
    echo "$(LATEX_BATCH) $${file}.tex"; \
    $(END_COLOR_COMMANDS) \
    $(LATEX_BATCH) $${file}.tex \
        && touch $@ \
        || (cat $${file}.log; \
            rm -f    .ps__first.$${file} \
                    .ps__second.$${file} \
                    .ps__third.$${file}; exit 1)
    @$(END_COLOR_COMMANDS)

view: 
    @$(COLOR_COMMANDS)
    for i in $(OUTPUT); do \
        test -f "$$i" && $(GV) $$i & \
    done
    @$(END_COLOR_COMMANDS)

## Vytvaranie grafov programom gnuplot
%.eps: %.gp $(DATA)
    $(GNUPLOT) $<

## Empty - nothing to be done for install ;)
install:
    
## Clean {{{
## zmazanie docasnych suborov
clean: clean-tex-logs clean-graphs clean-postscript clean-pdf
    @$(COLOR_COMMANDS)
    -rm -f *.log *.dvi .first.* .second.* .third.* core core.* $(PROGRAM)
    @$(END_COLOR_COMMANDS)

clean-all: clean
    @$(COLOR_COMMANDS)
    -test -z "$(AUTOGENERATED_FILES)" || rm -f $(AUTOGENERATED_FILES)
    -test -z "$(ps__OUTPUT)" || rm -f $(ps__OUTPUT)
    -test -z "$(pdf_OUTPUT)" || rm -f $(pdf_OUTPUT)
    @$(END_COLOR_COMMANDS)

clean-postscript:
    @$(COLOR_COMMANDS)
    -rm -rf PostScript/
    @$(END_COLOR_COMMANDS)

clean-pdf:
    @$(COLOR_COMMANDS)
    -rm -rf PDF/
    @$(END_COLOR_COMMANDS)

## zmazanie docasnych suborov vytvorenych programom latex
clean-tex-logs:
    @$(COLOR_COMMANDS)
    @ file_list=""; \
    for OUT in $(OUTPUT); \
    do \
        file="$${OUT%.ps}"; \
        for i in $${file%.pdf}{.aux,.brf,.log,.lof,.lot,.out,.toc,.dvi,.ps,.pdf} ; \
        do \
            file_list="$$file_list $$i"; \
        done; \
    done; \
    filelist="`echo $$file_list | awk -v RS=' ' '{print}' | sort -u | awk -v ORS=' ' '{print}'`"; \
    echo -en "Deleting extensions `echo $$asdf{.aux,.brf,.log,.lof,.lot,.out,.toc,.dvi,.ps,.pdf} `"; echo; \
    echo "rm -f $$filelist"; \
    rm -f $$filelist;
    @$(END_COLOR_COMMANDS)

## zmazanie vytvorenych grafov
clean-graphs:
    @$(COLOR_COMMANDS)
    @test -z "$(GRAPHS)" || \
    for i in "$(GRAPHS)" ; \
    do \
        echo "rm -f $$i"; rm -f $$i; \
    done
    @$(END_COLOR_COMMANDS)
## }}}

## Distribution {{{
dist: distdir
    @$(COLOR_COMMANDS)
    GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz  $(distdir)
    @#BZIP=$(GZIP_ENV) $(TAR) chojf $(distdir).tar.bz2 $(distdir)
    -rm -rf $(distdir)
    @#-@banner="md5sum is: `md5sum $(distdir).tar.gz |tee md5sum.$(distdir)`"; \
    dashes=`echo "$$banner" | sed s/./=/g`; \
    echo "$$dashes"; \
    echo "$$banner"; \
    echo "$$dashes"
    @$(END_COLOR_COMMANDS)

distdir: $(DISTFILES)
    @$(COLOR_COMMANDS)
    -rm -rf $(distdir)
    mkdir $(distdir)
    -chmod a+rx $(distdir)
    @here=`cd $(top_builddir) && pwd`; \
    top_distdir=`cd $(distdir) && pwd`; \
    distdir=`cd $(distdir) && pwd`; \
    umask 022; \
    for file in $(DISTFILES); do \
      d=$(srcdir); \
      if test -d $$d/$$file; then \
        mkdir $(distdir)/$$file; \
      else \
        test -f $(distdir)/$$file \
        || cp $$d/$$file $(distdir)/$$file || :; \
      fi; \
    done
    @$(END_COLOR_COMMANDS)

## }}}

## vim: ts=4 isk+=- ft=make
## vim600: fdm=marker fdc=3


Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top