]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/unit-cc.pl
PURE_STATIC fixes to use normal <module> tags
[user/henk/code/inspircd.git] / make / unit-cc.pl
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 BEGIN { push @INC, $ENV{SOURCEPATH}; }
5 use make::configure;
6
7 chdir $ENV{BUILDPATH};
8
9 my $out = shift;
10 my $verbose;
11
12 if ($out =~ /^-/) {
13         $_ = $out;
14         $out = shift;
15         $verbose = /v/;
16         if (/f/) {
17                 do_static_find(@ARGV);
18                 exit;
19         }
20         if (/l/) {
21                 do_static_link(@ARGV);
22                 exit;
23         }
24 }
25
26 my $file = shift;
27
28 my $cflags = $ENV{CXXFLAGS};
29 $cflags =~ s/ -pedantic// if nopedantic($file);
30 $cflags .= ' ' . getcompilerflags($file);
31
32 if ($file =~ m#(?:^|/)((?:m|cmd)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
33         $cflags .= ' -DMODNAME='.$1.'.so';
34 }
35
36 my $flags;
37 if ($out =~ /\.so$/) {
38         $flags = join ' ', $cflags, $ENV{PICLDFLAGS}, getlinkerflags($file);
39 } else {
40         $flags = "$cflags -c";
41 }
42
43 my $execstr = "$ENV{RUNCC} $flags -o $out $file";
44 print "$execstr\n" if $verbose;
45 exec $execstr;
46 exit 1;
47
48 sub do_static_find {
49         my @flags;
50         for my $file (@ARGV) {
51                 push @flags, getlinkerflags($file);
52         }
53         open F, '>', $out;
54         print F join ' ', @flags;
55         close F;
56 }
57
58 sub do_static_link {
59         my $execstr = "$ENV{RUNCC} -o $out $ENV{CORELDFLAGS} $ENV{LDLIBS}";
60         for (@ARGV) {
61                 if (/\.cmd$/) {
62                         open F, '<', $_;
63                         my $libs = <F>;
64                         chomp $libs;
65                         $execstr .= ' '.$libs;
66                         close F;
67                 } else {
68                         $execstr .= ' '.$_;
69                 }
70         }
71         print "$execstr\n" if $verbose;
72         exec $execstr;
73         exit 1;
74 }