This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Remove per-thread section; move to real scns
[perl5.git] / djgpp / fixpmain
CommitLineData
39e571d4
ML
1#!perl -w
2# Fix perlmain.c under DOS (short & case insensitive filenames).
3# Called from Makefile.aperl when needed.
4# You don't need this when LFN=y.
5
6use Config;
7
1ae6ead9
JL
8open (PERLM, '<', 'perlmain.c') or die "Can't load perlmain.c: $!";
9open (MAKEFILE, '<', 'makefile.pl') or die "Can't load makefile.pl: $!";
39e571d4
ML
10undef $/;
11$perlmain=<PERLM>;
12$makefile=<MAKEFILE>;
13
14($_) = $makefile =~ /\bNAME\b.*=>\W*([\w\:]+)/; # extract module name
aded5122 15$badname=join ("__",map {lc substr ($_,0,8)} split /:+/); # DOSify
39e571d4
ML
16$perlmain =~ s/^.*boot_$badname.*$//gm if $badname; # delete bad lines
17
a7d17c96
LM
18@exts=('DynaLoader',split (" ",$Config{known_extensions}));
19for $realname (@exts)
39e571d4 20{
a7d17c96
LM
21 $dosname=join ("__",map {lc substr ($_,0,8)} split /\//,$realname);
22 $realname =~ s!/!__!g;
87dc812e
LM
23 $perlmain =~ s/\bboot_$dosname\b/boot_$realname/gm;
24 $dosname =~ s/__/::/;
25 $realname =~ s/__/::/;
17f71141 26 $perlmain =~ s/\b$dosname(::bootstrap)/$realname$1/gm;
39e571d4
ML
27}
28
29#DynaLoader is special
30$perlmain =~ s/(DynaLoader:\:boot)strap/$1_DynaLoader/gm;
31
1ae6ead9 32open (PERLM, '>', 'perlmain.c') or die "Can't write perlmain.c: $!";
39e571d4 33print PERLM $perlmain;