summaryrefslogtreecommitdiff
path: root/djgpp/fixpmain
blob: 6db6555ecf1fd2ec6be04235f37d0e9bfe06ce56 (plain)
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
#!perl -w
# Fix perlmain.c under DOS (short & case insensitive filenames).
# Called from Makefile.aperl when needed.
# You don't need this when LFN=y.

use Config;

open (PERLM,"<perlmain.c") or die "Can't load perlmain.c: $!";
open (MAKEFILE,"<makefile.pl") or die "Can't load makefile.pl: $!";
undef $/;
$perlmain=<PERLM>;
$makefile=<MAKEFILE>;

($_) = $makefile =~ /\bNAME\b.*=>\W*([\w\:]+)/; # extract module name
$badname=join ("__",map {lc substr ($_,0,8)} split /:+/); # dosify
$perlmain =~ s/^.*boot_$badname.*$//gm if $badname; # delete bad lines

@exts=split (" ",$Config{known_extensions});
for $realname (@exts,'DynaLoader')
{
    $dosname=substr (lc $realname,0,8);
    $perlmain =~ s/boot_$dosname/boot_$realname/gm;
    $perlmain =~ s/$dosname(::bootstrap)/$realname$1/gm;
}

#DynaLoader is special
$perlmain =~ s/(DynaLoader:\:boot)strap/$1_DynaLoader/gm;

open (PERLM,">perlmain.c") or die "Can't write perlmain.c: $!";
print PERLM $perlmain;