-
Notifications
You must be signed in to change notification settings - Fork 40
/
config.pl
executable file
·2673 lines (2395 loc) · 76.2 KB
/
config.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/perl -w
###############################################################################
# $Id: config.pl,v 1.49 2002/09/27 09:26:56 RRM Exp $
#
# config.pl
#
# Accompanies LaTeX2HTML
#
# Finds local configuration. Does a lot of checks to find external
# programs. See the manual and the INSTALL file for further
# documentation.
#
# Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
#
# This software is part of Latex2HTML, originally by Nikos Drakos
# It is published under the GNU Public License and comes without any
# warranty.
#
# You aren't supposed to edit this script. You can specify command line
# options to customize it to your local setup.
###############################################################################
# Changes History
#
# $Log: config.pl,v $
# Revision 1.49 2002/09/27 09:26:56 RRM
# -- increased version number to 2002-2-1 (from 2002-2)
# else automatic package software complains about checksum mismatch
# whenever there is a change to *any* file in the distribution
#
# Revision 1.48 2002/08/20 11:33:54 RRM
# -- increase version to 2002-2, due to changes in latex2html.pin
#
# Revision 1.47 2002/08/17 00:15:42 RRM
# -- fixed the order of the pnmcrop test: ($vers >= 10 || $sub_vers > 10)
# Thanks to Shigeharu TAKENO for this fix. <shige@iee.niit.ac.jp>
#
# Revision 1.46 2002/07/10 12:18:00 RRM
# -- support netpbm version 10.x
# thanks to Shigeharu TAKENO for the patch
#
# Revision 1.45 2002/04/28 12:32:02 RRM
# -- handle $DVPSOPT and $ICONSERVER as variables configurable via prefs.pm
#
# Revision 1.44 2002/04/27 23:14:56 RRM
# -- forgot to uncomment the test for ppmtojpeg after testing
# now it will be found, for converting exotic formats to jpeg
#
# Revision 1.43 2002/04/27 11:31:23 RRM
# new release version: 2002-1
#
# -- implements $LATEX2HTMLDIR (shared) and $LATEX2HTMLPLATDIR (unshared)
# puts unshared l2hconf.pm into $LATEX2HTMLPLATDIR (platform-specific)
# other modules into $LATEX2HTMLDIR (shareable across platforms)
#
# -- checks for more graphics conversion utilities, for use with revised
# graphics.perl and graphicx.perl
#
# Revision 1.42 2002/04/10 00:32:40 RRM
# -- added directories starting /usr/share to the search path for GS
# -- default for library installation is now /usr/share/lib/latex2html
# (thanks to Nelson Beebe, Utah) for this improvement.
#
# Revision 1.41 2002/03/20 04:32:02 RRM
# -- change version number to '2002'
#
# Revision 1.40 2002/02/28 19:25:21 RRM
# -- fixed bug in gs version, introduced with previous edit
#
# Revision 1.39 2002/02/23 23:56:57 RRM
# -- recognise Ghostscript PRE-RELEASE versions;
# thanks to David R. Morrison <drm@math.duke.edu>.
#
# Revision 1.38 2001/10/25 10:39:27 RRM
# -- pnmcrop -verbose option only with versions 9.11+
#
# Revision 1.37 2001/10/18 10:37:53 RRM
# -- initialise $PNMCROPOPT, for *all* versions of pnmcrop
#
# Revision 1.36 2001/08/21 10:39:15 RRM
# -- use $PNMCROPOPT with versions v9.12+ of pnmcrop
#
# Revision 1.35 2001/03/25 02:54:36 RRM
# -- fixed the pnmcrop version test: >11 instead of >12
# -- added the -sides switch for these latest versions.
#
# Revision 1.34 2001/03/25 02:13:00 RRM
# This detects the new Netpbm utilities, versions 8.x --> v9.11 and later
# available from sourceforge.org.
# For versions up to 9.11, a variable $PNMBLACK is set to ' -black ',
# to allow correct cropping of black cropping-bars.
# With versions v9.12 and later, we use: pnmcrop -sides -verbose
# which make the -black redundant, and works also with colored bars.
#
# Revision 1.33 2000/12/21 08:16:46 RRM
# -- increased the version number to 2K.1beta
#
# Revision 1.32 2000/07/13 14:22:44 MRO
#
# -- fixed bug in Ghostscript detection. Enhanced it to work with 6.x
#
# Revision 1.31 2000/07/11 17:38:59 MRO
#
#
# added support for Ghostscript tester releases
#
# Revision 1.30 1999/11/09 00:43:42 MRO
#
#
# -- added some changes suggested on the mail list recently: mainly cleanup
# of -dir option
# -- added installation support for latex2html styles
#
# Revision 1.29 1999/11/04 08:23:52 RRM
# -- recognise: Aladdin Ghostscript <num>.<num>
#
# Revision 1.28 1999/11/03 12:45:30 RRM
# -- recognise 'BETA RELEASE' versions of Ghostscript
#
# Revision 1.27 1999/10/26 22:32:56 MRO
#
# -- added a credit
# -- reworked parts of the INSTALL documentation
# -- installation now tries to install styles
#
# Revision 1.26 1999/10/25 21:18:22 MRO
#
# -- added more configure options (Jens' suggestions)
# -- fixed bug in regexp range reported by Achim Haertel
# -- fixed old references in documentation (related to mail list/archive)
#
# Revision 1.25 1999/10/17 09:18:00 MRO
#
# -- Makefile now supports building of a *.zip container, too
# -- enhanced config.pl to add drive letter on DOSish platforms
#
# Revision 1.24 1999/10/06 22:04:13 MRO
#
# -- texexpand: latex2html calls texexpand with the -out option instead of
# output redirection: this is safer on non-UNIX platforms
# -- pstoimg: now there's no default cropping (useful for standalone
# conversions). latex2html was changes appropriately
# -- minor cleanups in latex2html script and documentation
#
# Revision 1.23 1999/10/03 18:40:42 MRO
#
# -- some cleanups for beta2
# -- "make check" now checks all Perl code
#
# Revision 1.22 1999/10/03 11:09:38 RRM
# v99.2 beta the alpha has been stable for a long time now
# only minor errors have been reported recently
#
# Revision 1.21 1999/09/23 08:56:58 RRM
# -- this version should be "thread-safe" now
# --- there are no more *-globs . References are used throughout.
# -- UTF8 implemented completely, as an output encoding
# -- use of full entitity names is implemented as an output encoding
# -- mechanism available to choose whether to allow 8-bit chars in the
# output, or UTF8 or entity names or images
# -- implemented post-processing search for ,, << >> ligatures
#
# Revision 1.20 1999/09/14 22:02:02 MRO
#
# -- numerous cleanups, no new features
#
# Revision 1.19 1999/09/13 21:58:41 MRO
#
# -- replaces open_tags by reference open_tags_R, should now be transparent
# -- added some more test stuff, enhanced Makefile
# -- cleaned up README and INSTALL
#
# Revision 1.18 1999/09/09 00:30:58 MRO
#
#
# -- removed all *_ where possible
#
# Revision 1.17 1999/08/31 23:04:22 MRO
#
# -- started to get rid of *_ etc, some parts are still open
#
# Revision 1.16 1999/08/30 22:45:09 MRO
#
# -- perl now reports line numbers respective to .pin file - eases
# code development!
# -- l2hcfg.pm is installed, too for furtjer reference
# -- some minor bugs (hopefully) fixed.
#
# Revision 1.15 1999/08/26 23:33:42 MRO
#
# -- added option to load l2hcfg.pm from previous installation
# -- fixed a bunch of bugs reported by Stefan Klupsch (thanks!)
#
# Revision 1.14 1999/07/11 08:37:08 RRM
# -- advanced the alpha-number
# -- much better support for non-latin1 charsets and unicode entities
# -- added techexpl.pl extension for using IBM TechExplorer plug-in
#
# Revision 1.13 1999/07/10 10:14:02 RRM
# -- Revision 1.13 has some bug-fixes and implements file-markers,
# so that plug-ins may get the original LaTeX source inputs
#
# Revision 1.12 1999/06/24 07:30:45 MRO
#
#
# -- remove DMBtest.db after config procedure (Linux)
#
# Revision 1.11 1999/06/24 07:28:59 MRO
#
#
# -- removed L2HMODULE
# -- fixed processing of -info switch
# -- changed option order for dvips on win32 (thanks JCL)
# -- bumped version to 99.2a8
#
# Revision 1.10 1999/06/10 23:00:01 MRO
#
#
# -- fixed an artifact in the *ball icons
# -- cleanups
# -- option documentation added
# -- fixed bug in color perl (determining path to rgb/crayola)
#
# Revision 1.9 1999/06/06 14:24:57 MRO
#
#
# -- many cleanups wrt. to TeXlive
# -- changed $* to /m as far as possible. $* is deprecated in perl5, all
# occurrences should be removed.
#
# Revision 1.8 1999/06/04 15:30:19 MRO
#
#
# -- fixed errors introduced by cleaning up TMP*
# -- made pstoimg -quiet really quiet
# -- pstoimg -debug now saves intermediate result files
# -- several fixes for OS/2
#
# Revision 1.7 1999/06/03 13:02:44 RRM
# -- merged fixes to latex2html collected over the past months
# -- new features include resizable images (in MSIE only, Netscape fails)
# -- allows customised treatment of theorem-like environments
# -- some fixes/improvements to styles/{alltt,amsmath,amstex,makeidx}.perl
# and minor edits to versions/{html3_1,math,frame}.pl and others
#
# Revision 1.6 1999/06/03 12:15:49 MRO
#
#
# - cleaned up the TMP / TMPDIR / TMP_ mechansim. Should work much the
# same now, but the code should be easier to understand.
#
# - cleaned up L2hos, added an INSTALLation FAQ, beautified the test
# document a little bit
#
# Revision 1.5 1999/06/01 06:55:41 MRO
#
#
# - fixed small bug in L2hos/*
# - added some test_mode related output to latex2html
# - improved documentation
# - fixed small bug in pstoimg wrt. OS2
#
# Revision 1.4 1999/05/31 07:49:13 MRO
#
#
# - a lot of cleanups wrt. OS/2
# - make test now available (TEST.BAT on Win32, TEST.CMD on OS/2)
# - re-inserted L2HCONFIG environment
# - added some new subs to L2hos (path2os, path2URL, Cwd)
#
# Revision 1.3 1999/05/21 06:49:06 MRO
#
#
# -- first attempt to make things work out of the box on Win32. There
# are still problems with the directory/path separators
#
# Revision 1.2 1999/05/19 23:54:06 MRO
#
#
# -- uniquified icons - some of them look a little bit strange, might
# need to be fixed.
# -- got rid of unlink errors, cleaned up some cosmetics
#
# Revision 1.1 1999/05/11 06:10:03 MRO
#
#
# - merged config stuff, did first tries on Linux. Simple document
# passes! More test required, have to ger rid of Warnings in texexpand
#
# Revision 1.27 1999/05/05 19:47:11 MRO
#
#
# - many cosmetic changes
# - final backup before merge
#
# Revision 1.26 1999/03/15 23:00:54 MRO
#
#
# - moved L2hos modules to top level directory, so that no dir-
# delimiter is necessary in the @INC-statement.
# - changed strategy for "shave": Do not rely on STDERR redirection any
# more (caused problems on at least Win32)
#
# Revision 1.25 1999/02/23 23:32:33 MRO
#
#
# -- few changes for Win32
#
# Revision 1.24 1999/02/14 23:44:36 MRO
#
#
# -- first attempt to fix Win32 problems
#
# Revision 1.23 1999/02/11 00:18:31 MRO
#
#
# -- cleaned up warppers, TeXlive stuff and Makefile
#
# Revision 1.22 1999/02/10 01:37:14 MRO
#
#
# -- changed os-dependency structure again - now neat OO modules are
# used: portable, extensible, neat!
# -- some minor cleanups and bugfixes
#
# Revision 1.21 1998/12/12 16:39:16 MRO
#
#
# -- cosmetic changes, reworked catching of STDERR in config.pl (Win32)
# -- new configure opt --disable-paths
# -- major cleanups
#
# Revision 1.20 1998/12/08 23:50:35 MRO
#
#
# -- small change for Solaris
# -- added new target test_pstoimg in Makefile
# -- fixed bug in latex2html
#
# Revision 1.19 1998/12/07 23:19:59 MRO
#
#
# -- added POD documentation to pstoimg and did a general cleanup
# -- some finetuning of config procedure and modules
#
# Revision 1.18 1998/10/31 14:13:08 MRO
# -- changed OS-dependent module loading strategy: Modules are now located in
# different (OS-specific) directories nut have the same name: Easier to
# maintain and cleaner code
# -- Cleaned up config procedure
# -- Extended makefile functionality
#
# Revision 1.17 1998/08/09 17:58:19 MRO
# -- save update
#
# Revision 1.16 1998/07/01 19:35:00 MRO
# -- added more wrapper templates, updated config.pl and pertially build.pl
#
# Revision 1.15 1998/06/30 23:12:14 MRO
# -- Reworked os dependency setup, mainly for TeXlive integration.
# Started wrapper coding.
#
# Revision 1.14 1998/06/14 14:10:41 latex2html
# -- Started to implement TeXlive configuration and better OS specific
# handling (Batch files) (Marek)
#
# Revision 1.13 1998/06/07 22:35:26 latex2html
# -- included things I learned from the Win95 port to config procedure:
# GS_LIB, Win32 module calls, directory separator stuff, ... (Marek)
#
# Revision 1.12 1998/06/01 12:58:05 latex2html
# -- Cleanup and cosmetics.
#
# Revision 1.11 1998/05/14 22:27:42 latex2html
# -- more work on config procedure (Makefile, GS_LIB)
# -- tested pstoimg in 98.1 environment successfully on Linux
#
# Revision 1.10 1998/05/06 22:31:20 latex2html
# -- Enhancements to the config procedure: Added a "generic" target
# in the Makefile for the TeXlive CD (not perfect yet)
# -- included test for kpsewhich / Web2C
# -- included latest stuff from Override.pm into os_*.pm
#
# Revision 1.9 1998/03/23 23:42:31 latex2html
# -- fixed bug in configure.in ($PERL)
# -- fixed bug in config.pl (correct version numbering for dvips 5.58f)
# -- removed obsolete install-sh (also from configure.in)
#
# Revision 1.8 1998/03/19 23:38:10 latex2html
# -- made pstoimg plug-in compatible with old one (touchwood!)
# -- cleaned up, added some comments
# -- inserted version information output
# -- incorporated patches to make OS/2 run better (thanks Uli)
# -- updated Makefile: make, make test, make install should work now
#
# Revision 1.7 1998/03/17 23:26:44 latex2html
# -- fixed some bugs in config.pl
# -- first version of install.pl finished
#
# Revision 1.6 1998/03/16 23:33:08 latex2html
# -- small quirk fixed (removal of DBM test files)
#
# Revision 1.5 1998/03/16 23:31:58 latex2html
# -- lots of cosmetic changes and bugfixes, thanks to Uli Wortmann
# for OS/2 testing
# -- start of install procedure; checks for installation paths implemented
#
# Revision 1.4 1998/03/12 23:04:15 latex2html
# -- small change in DBM check (no more dot in database name)
#
# Revision 1.3 1998/03/11 23:44:06 latex2html
# -- cleaned up config.pl and reworked dvips checks
# -- got pstoimg.pin up to par with the regular pstoimg
# -- cosmetic changes
# -- runs now under Win95 with Fabrice Popineau's Win32 tools (gs, TeX,...)
#
# Revision 1.2 1998/03/02 23:38:44 latex2html
# Reworked configuration procedure substantially. Fixed some killing bugs.
# Should now run on Win32, too.
# The file prefs.pm contains user-configurable stuff for DOS platforms.
# UNIX users can override the settings with the configure utility (preferred).
#
# Revision 1.1 1998/02/14 19:31:57 latex2html
# Preliminary checkin of configuration procedure
#
###############################################################################
package main;
use strict;
require 5.00305;
use Cwd;
use IO::File;
use FindBin;
use lib "$FindBin::Bin/..";
use L2hos;
#use diagnostics;
use vars qw(%prefs %cfg %newcfg);
# This is the central place to modify the release name and date!!!
my $RELEASE = '2018.3';
my $VERSION = 'Released July 19, 2018';
# --------------------------------------------------------------------------
# Open log
# --------------------------------------------------------------------------
# Use the same logfile as configure
my $LOGFILE = 'config.log';
my $LOG = new IO::File ">>$LOGFILE";
logit("Cannot append to $LOGFILE: $!\n") unless(defined $LOG);
# --------------------------------------------------------------------------
# Parse command line
# --------------------------------------------------------------------------
my %opt;
foreach (@ARGV) {
# allow for two delimiting characters; DOS ignores '='!!!
if(/^(\w+)[=+](.*)/) {
$opt{$1} = $2 || '';
# logit("Debug: $1 = +$2+\n");
}
}
# --------------------------------------------------------------------------
# Initialize
# --------------------------------------------------------------------------
# The name of the configuration file to create
my $CFGFILE = 'cfgcache.pm';
logit("\nconfig.pl, Release $RELEASE ($VERSION)\n");
logit("Accompanies LaTeX2HTML, (C) 1999 GNU Public License.\n\n");
# This hash contains the final configuration
%newcfg = ('distver' => $RELEASE,
'release_date' => $VERSION);
# Try to read old config file; will be loaded to %cfg
my $oldconfig = $opt{'OLDCONFIG'} || $CFGFILE;
&checking("for old config file ($oldconfig)");
if(eval "require '$oldconfig';" && %cfgcache::cfg) {
&result('loaded');
%cfg = %cfgcache::cfg;
undef %cfgcache::cfg;
} else {
&result('not found (ok)');
%cfg = ();
}
# --------------------------------------------------------------------------
# Determine platform we are running on
# --------------------------------------------------------------------------
# Platform types are currently: unix dos win32 os2 macos
&checking('for platform');
my @paths = (); # Paths where executables are located
my $dd = L2hos->dd; # The directory delimiter character (e.g. UNIX: "/")
my $pathd = L2hos->pathd; # The path delimiter character (e.g. UNIX: ":")
$newcfg{'plat'} = L2hos->plat;
$newcfg{'NULLFILE'} = L2hos->nulldev;
my $cwd = L2hos->Cwd(); # get the current directory
#$cwd =~ s:/:$dd:g; # beautify the path delimiter(s)
$cwd = cwd() unless(-d $cwd); # test if it still works :-)
$newcfg{'srcdir'} = $cwd;
# ----------------------------------------------------------------------------
# win32: Windows 95, Windows NT
# ----------------------------------------------------------------------------
if(L2hos->plat eq 'win32') {
&result("$^O (Windows 32 bit)");
if($ENV{'PATH'}) {
@paths = split(/\Q$pathd/,$ENV{'PATH'});
} else {
@paths = qw(.);
}
}
# ----------------------------------------------------------------------------
# dos: DOS, Windows 3.x
# ----------------------------------------------------------------------------
elsif(L2hos->plat eq 'dos') {
&result("$^O (DOS/Windows 3.x)");
if($ENV{'PATH'}) {
@paths = split(/\Q$pathd/,$ENV{'PATH'});
} else {
@paths = qw(.);
}
}
# ----------------------------------------------------------------------------
# os2: OS/2
# ----------------------------------------------------------------------------
elsif(L2hos->plat eq 'os2') {
&result("$^O (OS/2)");
if($ENV{'PATH'}) {
@paths = split(/\Q$pathd/,$ENV{'PATH'});
} else {
@paths = qw(.);
}
}
# ----------------------------------------------------------------------------
# macos: MacOS
# ----------------------------------------------------------------------------
# MRO: This is probably screwed, someone needs to test this
elsif(L2hos->plat eq 'macOS') {
&result("$^O (MacOS)");
if($ENV{'PATH'}) {
@paths = split(/\Q$pathd/,$ENV{'PATH'});
} else {
@paths = qw(.);
}
}
# ----------------------------------------------------------------------------
# unix: all UNIXes and clones
# ----------------------------------------------------------------------------
else { # unix
&result("$^O (assuming $newcfg{plat})");
if($ENV{'PATH'}) {
@paths = split(/\Q$pathd/,$ENV{'PATH'});
} else {
@paths = qw(.);
}
}
# --------------------------------------------------------------------------
# Read preferences file
#
# This step is postponed to this point in order to allow platform dependent
# configuration defaults in the preferences file.
# --------------------------------------------------------------------------
unless(require 'prefs.pm') {
logit("Error: Preferences file not found.\n");
cleanup(1);
exit 1;
}
import prefs;
# --------------------------------------------------------------------------
# If we're running in TeXlive-Mode, copy the predefined cfgcache.pm and stop
# --------------------------------------------------------------------------
if(&is_true(&get_name('TEXLIVE'))) {
&Copy('texlive.pm',$CFGFILE);
logit("Writing predefined configuration file for TeXlive\n");
exit 0;
}
# --------------------------------------------------------------------------
# Add extra executable search path(s)
# --------------------------------------------------------------------------
my $extrapath = $opt{EXTRAPATH} || $prefs{EXTRAPATH} || '';
@paths = grep(-d, uniquify(@paths, split(/[:;]/,$extrapath)));
#logit("DEBUG: EXTRAPATH=$extrapath\n");
#logit("DEBUG: PATH=" . join(':',@paths) . "\n");
# --------------------------------------------------------------------------
# Perl Version
#
# The perl version is checked by the require command above; the following is
# added for cosmetical reasons
# --------------------------------------------------------------------------
# only perl gets an absolute pathname
my $abs_path_names = 1;
$newcfg{'PERL'} = &find_prog($^X); # take the perl internal executable name
&checking('perl version');
&result($]);
# Read perl's own Config module
# used to get path for perldoc
use Config qw(%Config);
$newcfg{PERLSCRIPTDIR} = $Config{scriptdir};
# the other programs can live without
$abs_path_names = &get_name('ABSPATHS');
# --------------------------------------------------------------------------
# DBM check
# --------------------------------------------------------------------------
&checking('if perl supports some dbm');
my %array;
unless(dbmopen(%array,'DBMtest',0755)) {
my $err = $@ || 'dbmopen failed';
&result('no');
logit("Error: Perl reported DBM error: $err\nLaTeX2HTML needs some DBM.\n");
cleanup(1);
exit 1;
}
else {
#JCL: we do not need to write sth into it, if Perl lacks DBM we
# detected it with dbmopen before...
dbmclose(%array);
&result('yes');
}
unlink qw(DBMtest DBMtest.dir DBMtest.pag DBMtest.db); # ignore any errors
# --------------------------------------------------------------------------
# Globbing Check
# --------------------------------------------------------------------------
&checking('if perl globbing works');
open(TMP,">TEST1.TMP"); close TMP; # create temporary test files
open(TMP,">TEST2.TMP"); close TMP;
my @list = (<TEST*.TMP>); # glob test
unlink qw(TEST1.TMP TEST2.TMP); # remove temporary test files
unless(grep(/^TEST[12]\.TMP$/i,@list) == 2) {
&result('no');
logit(" Cannot live without globbing\n");
# Try to find out what is going wrong
# Perl uses full_csh to perform globbing, this may change of course
my $csh = eval {require 'Config.pm'; &Config::FETCH('','full_csh')};
if($csh) {
unless(-f $csh) {
logit("Error: $csh does not exist\n");
}
elsif(!-x $csh) {
logit("Error: $csh is not executable\n");
}
else {
logit("Error: unknown globbing problem, check perl installation\n");
}
}
else {
logit("Error: perl globbing failed. Couldn't determine csh info.\n");
}
cleanup(1);
exit 1;
}
else {
&result('yes');
}
# --------------------------------------------------------------------------
# Hashbang script starts
# --------------------------------------------------------------------------
$newcfg{'texlive'} = &is_true(&get_name('TEXLIVE'));
$newcfg{'wrapper'} = &is_true(&get_name('WRAPPER'));
$newcfg{'HASHBANG'} = 0;
$newcfg{'exec_extension'} = '';
$newcfg{'perl_starter'} = '';
$newcfg{'PERLHEADER'} = '';
$newcfg{'PERLFOOTER'} = '';
# Unix: Use #! mechanism, if it works
if($newcfg{'plat'} =~ /unix/i) {
if(&is_true(&get_name('HASHBANG'))) {
$newcfg{'PERLHEADER'} = "#! $newcfg{'PERL'} -w\n";
$newcfg{'HASHBANG'} = 1;
}
else {
# Hashbang script starts are not allowed; use this "killer" to
# start the script on (almost) all sorts of shells...
$newcfg{'PERLHEADER'} = <<"EOF";
# -*- perl -*- -w
eval '(exit \$?0)' && eval 'exec $newcfg{'PERL'} -S \$0 \${1+"\$\@"}'
& eval 'exec $newcfg{'PERL'} -S \$0 \$argv:q'
if 0; # suppress this stuff in perl
EOF
$newcfg{'perl_starter'} = $newcfg{'PERL'};
}
}
# OS/2: Use the "extproc" mechanism
elsif($newcfg{'plat'} =~ /os2/i) {
$newcfg{'PERLHEADER'} = "extproc $newcfg{'PERL'} -S -w\n";
$newcfg{'exec_extension'} = '.cmd';
$newcfg{'perl_starter'} = $newcfg{'PERL'};
}
# DOS/Windows: Create BATch files
elsif($newcfg{'plat'} =~ /dos|win32/i) {
$newcfg{'PERLHEADER'} = <<"EOF";
\@rem = '--*-Perl-*--
\@echo off
set arg=
set prog=%0
:one
set arg=%*
:two
if exist %prog%.bat goto indot
$newcfg{'PERL'} -x -S %prog% %arg%
goto endofperl
:indot
$newcfg{'PERL'} -x %prog%.bat %arg%
set arg=
set prog=
goto endofperl
\@rem ';
#! perl -w
# line 21
EOF
$newcfg{'PERLFOOTER'} = <<"EOF";
__END__
:endofperl
EOF
$newcfg{'exec_extension'} = '.bat';
$newcfg{'perl_starter'} = "$newcfg{'PERL'} -x";
}
# other OSes have no means for starting up scripts
else {
$newcfg{'PERLHEADER'} = "# -*- perl -*- -w\n";
$newcfg{'perl_starter'} = $newcfg{'PERL'};
}
# --------------------------------------------------------------------------
# Images
#
# Supported image output formats: GIF and PNG
#
# Note that the GIF format has some legal restrictions: Due to the usage
# of LZW compression in the GIF format, that is licensed by Unisys, every
# program creating GIFs has to have a license from Unisys when run for
# commercial purposes.
# --------------------------------------------------------------------------
$opt{'have_pstoimg'} = 1; # be optimistic that pstoimg can be built
$opt{'IMAGES'} = &is_true(&get_name('IMAGES'));
$opt{'GIF'} = &is_true(&get_name('GIF'));
$opt{'PNG'} = &is_true(&get_name('PNG'));
$opt{'SVG'} = &is_true(&get_name('SVG'));
unless($opt{'GIF'} || $opt{'PNG'}) {
$opt{'IMAGES'} = 0;
$opt{'have_pstoimg'} = 0;
logit("Warning: Both GIF and PNG support disabled. LaTeX2HTML won't generate any images.\n");
}
# --------------------------------------------------------------------------
# TeX, LaTeX, IniTeX, Web2C
# --------------------------------------------------------------------------
$newcfg{'TEX'} = '';
if($opt{'IMAGES'}) {
my $tex = &find_prog(&get_name('TEX',1));
if($tex) {
$newcfg{'TEX'} = $tex;
}
}
$newcfg{'LATEX'} = '';
if($opt{'IMAGES'}) {
my $latex = &find_prog(&get_name('LATEX',1));
if($latex) {
$newcfg{'LATEX'} = $latex;
}
else {
$opt{'IMAGES'} = 0;
&warn_no_images();
}
}
$newcfg{'PDFLATEX'} = '';
if($opt{'IMAGES'}) {
my $pdflatex = &find_prog(&get_name('PDFLATEX',1));
if($pdflatex) {
$newcfg{'PDFLATEX'} = $pdflatex;
}
else {
$opt{'IMAGES'} = 0;
&warn_no_images();
}
}
$newcfg{'LUALATEX'} = '';
if($opt{'IMAGES'}) {
my $lualatex = &find_prog(&get_name('LUALATEX',1));
if($lualatex) {
$newcfg{'LUALATEX'} = $lualatex;
}
else {
$opt{'IMAGES'} = 0;
&warn_no_images();
}
}
$newcfg{'DVILUALATEX'} = '';
if($opt{'IMAGES'}) {
my $dvilualatex = &find_prog(&get_name('DVILUALATEX',1));
if($dvilualatex) {
$newcfg{'DVILUALATEX'} = $dvilualatex;
}
else {
$opt{'IMAGES'} = 0;
&warn_no_images();
}
}
$newcfg{'INITEX'} = '';
if($opt{'IMAGES'}) {
my $initex = &find_prog(&get_name('INITEX',1));
if($initex) {
$newcfg{'INITEX'} = $initex;
}
}
$newcfg{'KPSEWHICH'} = '';
$newcfg{'WEB2C'} = 0;
my $kpath = '';
my $kpsewhich = &find_prog(&get_name('KPSEWHICH',1));
if($kpsewhich) {
$newcfg{'KPSEWHICH'} = $kpsewhich;
&checking('for kpsewhich syntax');
my @try_opts = ('-show-path=tex', '-p tex');
my $try;
my $num = 1;
foreach $try (@try_opts) {
my ($stat,$out,$err) = &get_out_err("$kpsewhich $try");
if($stat == 0) { # ok
$newcfg{'WEB2C'} = $num;
&result("ok (style=$num)");
$kpath = $out;
last;
}
$num++;
}
if(--$num > $#try_opts) {
&result("no, from which planet is your kpsewhich?");
$newcfg{'KPSEWHICH'} = '';
}
}
&checking('for TeX include path');
my $texpath = $opt{TEXPATH} || $prefs{TEXPATH} || '';
if($texpath eq 'no') {
$texpath = '';
}
elsif(!$texpath && $kpath) {
my @texpaths = ();
chomp($kpath);
foreach(split(/[:;]/,$kpath)) {
s/^!+//; # strip leading !'s
s:[/\\]+$::; # strip trailing path delims
if(!/^[\.\w]/ && -d) {
push(@texpaths,$_);
}
}
if(@texpaths > 1) {
($texpath) = grep(-d $_.$dd.'latex', @texpaths);
$texpath = $texpaths[0] unless($texpath);
} else {
$texpath = $texpaths[0] || '';
}
if(-d $texpath.$dd.'latex') {
$texpath .= $dd . 'latex';
}
if(-d $texpath.$dd.'latex2html') {
$texpath .= $dd . 'latex2html';
} else {
$texpath .= $dd . 'html';
}
}
unless($texpath) {
logit("NONE\nWarning: Will not automatically install LaTeX2HTML style files.\n");
} else {
&result($texpath);
# find the ls-R update tool
$newcfg{'MKTEXLSR'} = &find_prog(&get_name('MKTEXLSR',1));
}
$newcfg{'TEXPATH'} = $texpath;
# --------------------------------------------------------------------------
# dvips
#
# This (and gs) is the most complicated setup feature. It is advisable to
# get the latest version of dvips for best results, i.e. currently(?)
# 5.76
# --------------------------------------------------------------------------
$newcfg{'DVIPS'} = '';
$newcfg{'DVIPSOPT'} = $prefs{'DVIPSOPT'}||'';
$newcfg{'PK_GENERATION'} = 0;
$newcfg{'have_dvipsmode'} = '';
$newcfg{'METAMODE'} = '';
$newcfg{'METADPI'} = 0;
if($opt{'IMAGES'}) {
my $dvips = &find_prog(&get_name('DVIPS',1));
if($dvips) {
my @switches = '';
&checking('dvips version');
my $veropt;
my $version = '';
# Try to determine the version. Obstacles: output goes to STDOUT or
# STDERR and can have different formats
my @tryopts;
if($newcfg{'plat'} eq 'os2') {
# --version requires pressing \n on OS/2
@tryopts = ('','--version','-?','-v');
} elsif($newcfg{'plat'} eq 'win32') {
# --version requires pressing \n on MikTeX
@tryopts = ('','--version','-?','-v');
} else {
@tryopts = ('--version','','-?','-v');
}
foreach $veropt (@tryopts) {
my ($stat,$msg,$err) = &get_out_err("$dvips $veropt");
$msg .= $err || '';
if(!$stat && $msg =~ /(?:^| )dvips(?:\(k\)|k|)\s*(\d+[.]?\d*[A-Z]?)/is) {
$version = $1;
last;
}
}
unless($version) {
$opt{'IMAGES'} = 0;
&result('no');
logit(qq{Error: could not determine dvips version\n});
&warn_no_images();
}
else {
&result($version);
my $numeric = $version;
# convert letter minor number to decimal
if($numeric =~ /(\d+[.]?\d*)([A-Z])/i) {
my ($primary,$secondary) = ($1,$2);
if($secondary) {
$secondary = unpack('C',uc($2))-unpack('C','A')+1;
$secondary = "0$secondary" if($secondary < 10);
}
else {
$secondary = '00';
}
$numeric = "$primary$secondary";
}