Debian Codegraph @

maint/run-before_build.pl

raw
1 use strict;
2 use warnings;
3 use lib 'inc';
4 use My::Config;
5 use File::Spec;
6 use File::Spec ();
7 use File::Find ();
8
9 if(@ARGV > 0)
10 {
11 if(-e 'Makefile')
12 {
13 if($^O eq 'MSWin32')
14 {
15 print "> gmake realclean\n";
16 system 'gmake', 'realclean';
17 }
18 else
19 {
20 print "% make realclean\n";
21 system 'make', 'realclean';
22 }
23 }
24
25 My::Config->new->clean;
26 }
27
28 foreach my $bits (qw( 16 32 64 ))
29 {
30 foreach my $orig (qw( t/ffi/uint8.c t/ffi/sint8.c t/type_uint8.t t/type_sint8.t ))
31 {
32 my $new = $orig;
33 $new =~ s/8/$bits/;
34
35 open my $in, '<', $orig or die "unable to read $orig";
36 open my $out, '>', $new or die "unable to write $new";
37
38 if($orig =~ /\.c$/)
39 {
40 print $out join "\n", "/*",
41 " * DO NOT MODIFY THIS FILE.",
42 " * This file generated from similar file $orig",
43 " * all instances of \"int8\" have been changed to \"int$bits\"",
44 " */",
45 "";
46 }
47 else
48 {
49 print $out join "\n", "#",
50 "# DO NOT MODIFY THIS FILE.",
51 "# This file generated from similar file $orig",
52 "# all instances of \"int8\" have been changed to \"int$bits\"",
53 "#",
54 "";
55 }
56
57 while(<$in>)
58 {
59 s/int8/"int$bits"/eg;
60 print $out $_;
61 }
62
63 close $out;
64 close $in;
65 }
66 }
67
68 foreach my $type (qw( double ))
69 {
70 foreach my $orig (qw( t/ffi/float.c t/type_float.t t/type_complex_float.t t/ffi/complex_float.c ))
71 {
72 my $new = $orig;
73 $new =~ s/float/$type/;
74
75 open my $in, '<', $orig or die "unable to read $orig $!";
76 open my $out, '>', $new or die "unable to write $new $!";
77
78 if($orig =~ /\.c$/)
79 {
80 print $out join "\n", "/*",
81 " * DO NOT MODIFY THIS FILE.",
82 " * This file generated from similar file $orig",
83 " * all instances of \"float\" have been changed to \"$type\"",
84 " */",
85 "";
86 }
87 else
88 {
89 print $out join "\n", "#",
90 "# DO NOT MODIFY THIS FILE.",
91 "# This file generated from similar file $orig",
92 "# all instances of \"float\" have been changed to \"$type\"",
93 "#",
94 "";
95 }
96
97 while(<$in>)
98 {
99 s/float/$type/eg;
100 s/SIZEOF_FLOAT_COMPLEX/"SIZEOF_@{[ uc $type ]}_COMPLEX"/eg;
101 if($type eq 'double')
102 {
103 s/crealf/creal/g;
104 s/cimagf/cimag/g;
105 }
106 else
107 {
108 die 'todo';
109 }
110 print $out $_;
111 }
112
113 close $out;
114 close $in;
115 }
116 }