eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q' if 0; # todo: second run of checksum of mp file with --nomprun changes # todo: warning if no args # todo: <<<< in messages # todo: cleanup #D \module #D [ file=texexec.pl, #D version=2002.05.04, #D title=running \ConTeXt, #D subtitle=\TEXEXEC, #D author=Hans Hagen, #D date=\currentdate, #D copyright={PRAGMA / Hans Hagen \& Ton Otten}] #C #C This module is part of the \CONTEXT\ macro||package and is #C therefore copyrighted by \PRAGMA. See licen-en.pdf for #C details. # Thanks to Tobias Burnus for the german translations. # Thanks to Thomas Esser for hooking it into web2c # Thanks to Taco Hoekwater for suggesting improvements # Thanks to Wybo Dekker for the advanced help interface # (I still have to completely understand the help code -) #D We started with a hack provided by Thomas Esser. This #D expression replaces the unix specific line \type #D {#!/usr/bin/perl}. use Cwd ; use Time::Local ; use Config ; use Getopt::Long ; use Class::Struct ; # needed for help subsystem # Data::Dumper ; # needed for help subsystem my %ConTeXtInterfaces ; # otherwise problems with strict my %ResponceInterface ; # since i dunno how to allocate else # my %Help ; # use strict ; #D In this script we will launch some programs and other #D scripts. \TEXEXEC\ uses an ini||file to sort out where #D those programs are stored. Two boolean variables keep #D track of the way to call the programs. In \TEXEXEC, #D \type {$dosish} keeps track of the operating system. #D It will be no surprise that Thomas Esser provided me #D the neccessary code to accomplish this. $ENV{"MPXCOMMAND"} = "0" ; # otherwise loop my $TotalTime = time ; ## $dosish = ($Config{'osname'} =~ /dos|mswin/i) ; ## $dosish = ($Config{'osname'} =~ /^(ms)?dos|^os\/2|^(ms|cyg)win/i) ; my $dosish = ($Config{'osname'} =~ /^(ms)?dos|^os\/2|^mswin/i) ; my $escapeshell = ($ENV{'SHELL'} =~ m/sh/i); my $TeXUtil = 'texutil' ; my $TeXExec = 'texexec' ; my $DVIspec = 'dvispec' ; my $SGMLtoTeX = 'sgml2tex' ; my $FDFtoTeX = 'fdf2tex' ; my $MetaFun = 'metafun' ; my $MpToPdf = 'mptopdf' ; $Getopt::Long::passthrough = 1 ; # no error message $Getopt::Long::autoabbrev = 1 ; # partial switch accepted my $AddEmpty = '' ; my $Alone = 0 ; my $Optimize = 0 ; my $ForceTeXutil = 0 ; my $Arrange = 0 ; my $BackSpace = '0pt' ; my $Background = '' ; my $CenterPage = 0 ; my $ConTeXtInterface = 'unknown' ; my $Convert = '' ; my $DoMPTeX = 0 ; my $DoMPXTeX = 0 ; my $EnterBatchMode = 0 ; my $Environments = '' ; my $Modules = '' ; my $FastMode = 0 ; my $FinalMode = 0 ; my $Format = '' ; my $MpDoFormat = '' ; my $HelpAsked = 0 ; my $MainBodyFont = 'standard' ; my $MainLanguage = 'standard' ; my $MainResponse = 'standard' ; my $MakeFormats = 0 ; my $Markings = 0 ; my $Mode = '' ; my $NoArrange = 0 ; my $NoDuplex = 0 ; my $NOfRuns = 7 ; my $NoMPMode = 0 ; my $NoMPRun = 0 ; my $NoBanner = 0 ; my $AutoMPRun = 0 ; my $OutputFormat = 'standard' ; my $Pages = '' ; my $PageScale = '1000' ; # == 1.0 my $PaperFormat = 'standard' ; my $PaperOffset = '0pt' ; my $PassOn = '' ; my $PdfArrange = 0 ; my $PdfSelect = 0 ; my $PdfCombine = 0 ; my $PrintFormat = 'standard' ; my $ProducePdfT = 0 ; my $ProducePdfM = 0 ; my $ProducePdfX = 0 ; my $Input = "" ; my $Result = 0 ; my $Suffix = '' ; my $RunOnce = 0 ; my $Selection = '' ; my $Combination = '2*4' ; my $SilentMode = 0 ; my $TeXProgram = '' ; my $TeXTranslation = '' ; my $TextWidth = '0pt' ; my $TopSpace = '0pt' ; my $TypesetFigures = 0 ; my $TypesetListing = 0 ; my $TypesetModule = 0 ; my $UseColor = 0 ; my $Verbose = 0 ; my $PdfCopy = 0 ; my $LogFile = "" ; my $MpyForce = 0 ; my $RunPath = "" ; my $Arguments = "" ; my $Pretty = 0 ; my $SetFile = "" ; my $TeXTree = "" ; my $TeXRoot = "" ; my $Purge = 0 ; my $Separation = "" ; my $ModeFile = "" ; my $GlobalFile = 0 ; my $AllPatterns = 0 ; my $ForceXML = 0 ; &GetOptions ( "arrange" => \$Arrange , "batch" => \$EnterBatchMode , "color" => \$UseColor , "centerpage" => \$CenterPage , "convert=s" => \$Convert , "environments=s"=> \$Environments , "usemodules=s" => \$Modules , "xml" => \$ForceXML , "xmlfilters=s" => \$Filters , "fast" => \$FastMode , "final" => \$FinalMode , "format=s" => \$Format , "mpformat=s" => \$MpDoFormat , "help" => \$HelpAsked , "interface=s" => \$ConTeXtInterface , "language=s" => \$MainLanguage , "bodyfont=s" => \$MainBodyFont , "results=s" => \$Result , "response=s" => \$MainResponse , "make" => \$MakeFormats , "mode=s" => \$Mode , "module" => \$TypesetModule , "figures=s" => \$TypesetFigures , "listing" => \$TypesetListing , "mptex" => \$DoMPTeX , "mpxtex" => \$DoMPXTeX , "noarrange" => \$NoArrange , "nomp" => \$NoMPMode , "nomprun" => \$NoMPRun , "nobanner" => \$NoBanner , "automprun" => \$AutoMPRun , "once" => \$RunOnce , "output=s" => \$OutputFormat , "pages=s" => \$Pages , "paper=s" => \$PaperFormat , "passon=s" => \$PassOn , "path=s" => \$RunPath , "pdf" => \$ProducePdfT , "pdm" => \$ProducePdfM , "pdx" => \$ProducePdfX , "pdfarrange" => \$PdfArrange , "pdfselect" => \$PdfSelect , "pdfcombine" => \$PdfCombine , "pdfcopy" => \$PdfCopy , "scale=s" => \$PageScale , "selection=s" => \$Selection , "combination=s" => \$Combination , "noduplex" => \$NoDuplex , "paperoffset=s" => \$PaperOffset , "backspace=s" => \$BackSpace , "topspace=s" => \$TopSpace , "markings" => \$Markings , "textwidth=s" => \$TextWidth , "addempty=s" => \$AddEmpty , "background=s" => \$Background , "logfile=s" => \$LogFile , "print=s" => \$PrintFormat , "suffix=s" => \$Suffix , "runs=s" => \$NOfRuns , "silent" => \$SilentMode , "tex=s" => \$TeXProgram , "verbose" => \$Verbose , "alone" => \$Alone , "optimize" => \$Optimize , "texutil" => \$ForceTeXutil , "mpyforce" => \$MpyForce , "input=s" => \$Input , "arguments=s" => \$Arguments , "pretty" => \$Pretty , "setfile=s" => \$SetFile , "purge" => \$Purge , #### yet undocumented ################# "allpatterns" => \$AllPatterns , "separation=s" => \$Separation , "textree=s" => \$TeXTree , "texroot=s" => \$TeXRoot , "translate=s" => \$TeXTranslation , "modefile=s" => \$ModeFile , # additional modes file "globalfile" => \$GlobalFile ) ; # don't check name # a set file (like blabla.bat) can set paths now if ($SetFile ne "") { load_set_file ($SetFile,$Verbose) ; $SetFile = "" } # later we will do a second attempt. $SIG{INT} = "IGNORE" ; if ($ARGV[0] =~ /\.mpx$/io) # catch -tex=.... bug in mpost { $TeXProgram = '' ; $DoMPXTeX = 1 ; $NoMPMode = 1 } if ($DoMPTeX||$DoMPXTeX) { $RunOnce = 1 ; $ProducePdfT = 0 ; $ProducePdfX = 0 ; $ProducePdfM = 0 } if ($PdfArrange||$PdfSelect||$PdfCopy||$PdfCombine) { $ProducePdfT = 1 ; $RunOnce = 1 } if ($ProducePdfT) { $OutputFormat = "pdftex" } elsif ($ProducePdfM) { $OutputFormat = "dvipdfm" } elsif ($ProducePdfX) { $OutputFormat = "dvipdfmx" } if ($RunOnce||$Pages||$TypesetFigures||$TypesetListing) { $NOfRuns = 1 } if (($LogFile ne '')&&($LogFile =~ /\w+\.log$/io)) { open (LOGFILE,">$LogFile") ; *STDOUT = *LOGFILE ; *STDERR = *LOGFILE } my $Program = " TeXExec 3.1 - ConTeXt / PRAGMA ADE 1997-2002" ; print "\n$Program\n\n" ; if ($Verbose) { print " current path : " . cwd . "\n" } my $pathslash = '/' ; if ($0 =~ /\\/) { $pathslash = "\\" } my $cur_path = ".$pathslash" ; my $own_path = $0 ; $own_path =~ s/texexec(\.pl|\.bat|)//io ; my $own_type = $1 ; my $own_stub = "" ; if ($own_type =~ /pl/oi) { $own_stub = "perl " } sub checked_path { my $path = shift ; if ((defined($path))&&($path ne '')) { $path =~ s/[\/\\]/$pathslash/go ; $path =~ s/[\/\\]*$//go ; $path .= $pathslash } else { $path = '' } return $path } sub checked_file { my $path = shift ; if ((defined($path))&&($path ne '')) { $path =~ s/[\/\\]/$pathslash/go } else { $path = '' } return $path } sub CheckPath { my ($Key, $Value) = @_ ; if (($Value =~ /\//)&&($Value !~ /\;/)) # no multipath test yet { $Value = checked_path($Value) ; unless (-d $Value) { print " error : $Key set to unknown path $Value\n" } } } # set to # for