Generic Makefile for LyX and LaTeX documents

I have prepared a generic Makefile for LyX/LaTeX documents, called latex.mk. In order to use it prepare a simple Makefile containing just:

include latex.mk

Then type:

# make help

The Makefile can locate your source file (either LyX or LaTeX), export it if necessary and then compile:

# make final
# make finalps
# make export
# make figs
# make clean

You can even simplify usage of it by defining the following function in your shell (let it be Bash):

function mk() {
  if [ -f Makefile ]
  then
    make "$@"
  else
    make -f $HOME/path/to/latex.mk "$@"
  fi
}

Then you do not have to create Makefile, just type:

# mk final