#!/usr/bin/env sh ## ## wrapper for chklref program ## Automatically generated by configure from chklref.in ## ######################################################################### # Written and (C) by Jérôme Lelong # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # ######################################################################### prefix=@prefix@ bindir=@bindir@ SCRIPTSDIR=@SCRIPTSDIR@ PERL=@PERL_PATH@ LATEX=@LATEX_PATH@ PDFLATEX=@PDFLATEX_PATH@ VERSION=@VERSION@ LATEXDIR=@LATEXDIR@ DOCDIR=@DOCDIR@ SCRIPTSDIR=@SCRIPTSDIR@ print_usage() { cat << EOF chklref This is a latex utility to check for unused labels and bibitems in a LaTeX file. usage: chklref [OPTIONS] file[.tex] OPTIONS -p,--pdf : Use pdflatex instead of latex -q,--quiet : Run LaTeX quietly -d,--debug : Run in deubgging mode -h,--help : Display this help --version : Display the version number EOF } out='/dev/stdout' latex_cmd=$LATEX debug=0 while test -n "$1" do case "$1" in -p|--pdf) latex_cmd=$PDFLATEX shift ;; -h|--help) print_usage exit 0 ;; -q|--quiet) out='/dev/null' shift ;; -d|--debug) debug=1 shift ;; --version) echo "chklref version $VERSION" exit 0 ;; -*) echo "Unknown option: $1" print_usage exit 1 ;; *) break ;; esac done INFILE=$1 if test -z "$INFILE"; then echo "$0: You must specify an input file" exit 1 fi if test ! -f "${INFILE}"; then INFILE=${INFILE}.tex fi if test ! -f "${INFILE}"; then echo "$0: Neither ${INFILE} nor ${INFILE}.tex exists" exit 1 fi # POSIX extractions of dirname and basename basetexfile=${INFILE##*/} basetexfile=${basetexfile%.tex} dirtexfile=${INFILE%/*} if [ "${dirtexfile}" = "$1" ]; then dirtexfile="."; fi cd -- "${dirtexfile}" echo "Running $latex_cmd on $basetexfile.tex to collect labels, references and environment declarations\n\n" > "$out" $latex_cmd --interaction errorstopmode "${basetexfile}" > "$out" 2>&1 rm -f -- "$basetexfile".tex.chk $latex_cmd --interaction errorstopmode --jobname "$basetexfile" \ '\RequirePackage{chklref}\input' "{$basetexfile.tex}" > "$out" 2>&1 $PERL "$SCRIPTSDIR"/chkparser "$basetexfile".chk [ $debug -ne 0 ] || rm -f -- "$basetexfile".chk