Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Tuesday, October 22, 2019

File: [Platon] / doc / diplomova-praca-rajo / Rules.make (download)

Revision 1.5, Thu Jul 7 17:02:18 2005 UTC (14 years, 3 months ago) by rajo


Changes since 1.4: +6 -6 lines

Fixed dependency for hotGas.c.LINENUM autogenerated file.

##
## Rules.make - make rules for diplomovka-text
##              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: doc/diplomova-praca-rajo/Rules.make,v 1.4 2005/04/21 13:49:23 rajo Exp $
##

##
## 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 # {{{
ifdef PREFIX
all: $(DEPEND) $(AUTOGENERATED_FILES) all-subdirs ps-subdir ps-prefixed-output
else
all: $(DEPEND) $(AUTOGENERATED_FILES) all-subdirs ps-subdir
endif # ifdef PREFIX
endif # }}} ifdef ps__OUTPUT

ifdef pdf_OUTPUT # {{{
ifdef PREFIX
all: $(DEPEND) $(AUTOGENERATED_FILES) all-subdirs pdf-subdir pdf-prefixed-output
else
all: $(DEPEND) $(AUTOGENERATED_FILES) all-subdirs pdf-subdir
endif # ifdef PREFIX

ifdef ps__OUTPUT # {{{
ifdef PREFIX
all: ps-subdir pdf-subdir ps-prefixed-output pdf-prefixed-output
    @echo 'PREFIX = "$(PREFIX)"'
else
all: ps-subdir pdf-subdir
endif # ifdef PREFIX
endif # }}} ifdef ps__OUTPUT

endif # }}} ifdef pdf_OUTPUT

## 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)

ifdef PREFIX # {{{
ps-prefixed-output:
    @-for file in $(ps__OUTPUT); do \
        echo "ln -f 'PostScript/$$file' '$(PREFIX)-$$file'"; \
        ln -f "PostScript/$$file" "$(PREFIX)-$$file" \
        || cp -f "PostScript/$$file $(PREFIX)"; \
     done

pdf-prefixed-output:
    @-for file in $(pdf_OUTPUT); do \
        echo "ln -f 'PDF/$$file' '$(PREFIX)-$$file'"; \
        ln -f "PDF/$$file" "$(PREFIX)-$$file" \
        || cp -f "PDF/$$file $(PREFIX)"; \
     done
endif # }}} ifdef PREFIX

# AUTOGENERATED_FILES: -- images
$(IMAGES_DIR)/%.eps: $(IMAGES_DIR)/%.gpi
    @$(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)


%.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)

## Empty - nothing to be done for install ;)
install:

#
# False targets.
#
.PHONY: dummy debug

#
# A rule to do nothing
#
dummy:

#
# A rule to make subdirectories
#
subdir-list-all = $(sort $(patsubst %,_subdir_%,$(SUBDIRS)))
all-subdirs: dummy $(subdir-list-all)

ifdef SUBDIRS
$(subdir-list-all) : dummy
    $(MAKE) -C $(patsubst _subdir_%,%,$@)
endif

#
# A rule to make clean in subdirectories
#
subdir-list-clean = $(sort $(patsubst %,_subdir_clean_%,$(SUBDIRS)))
clean-subdirs: dummy $(subdir-list-clean)

ifdef SUBDIRS
$(subdir-list-clean) : dummy
    $(MAKE) -C $(patsubst _subdir_clean_%,%,$@) clean
endif


    
## Clean {{{
## zmazanie docasnych suborov
clean: clean-first clean-tex-logs clean-graphs clean-postscript clean-pdf
    @$(COLOR_COMMANDS)
    -rm -f *.log *.dvi .first.* .second.* .third.* core core.* $(PROGRAM)
    -rm -f .used_datafiles.tmp 07-prilohy.tex.tmp hotGas.c.LINENUM*
    @$(END_COLOR_COMMANDS)

clean-first: clean-subdirs
    -rm -f Dependencies.make

clean-all: clean clean-auto
    @$(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)

clean-auto:
    @-test -z "$(AUTOGENERATED_FILES)" \
        || ( echo "rm -f $(AUTOGENERATED_FILES)";  rm -f $(AUTOGENERATED_FILES) )
## }}}

## Distribution {{{
dist: distdir
    @echo;
    @echo "Please, run command 'make' before 'make dist'"
    @echo;
    @$(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 $(GENERATED_DISTFILES) $(DISTFILES); do \
      d=$(srcdir); \
      if test -d $$d/$$file; then \
        mkdir $(distdir)/$$file; \
      else \
          if test -f $(distdir)/$$file; then \
            ln $$d/$$file $(distdir)/$$file \
            || cp $$d/$$file $(distdir)/$$file || :; \
          else \
              ln `realpath $$d/$$file` $(distdir)/$$file || :; \
        fi; \
      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