4 # InspIRCd -- Internet Relay Chat Daemon
6 # Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 # This file is part of InspIRCd. InspIRCd is free software: you can
9 # redistribute it and/or modify it under the terms of the GNU General Public
10 # License as published by the Free Software Foundation, version 2.
12 # This program is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 push @INC, $ENV{SOURCEPATH};
28 use warnings FATAL => qw(all);
32 chdir $ENV{BUILDPATH};
36 my $verbose = ($type =~ s/-v$//);
38 ## BEGIN HACK: REMOVE IN 2.2!
39 sub read_config_cache {
41 open(CACHE, '../.config.cache') or return %cfg;
42 while (my $line = <CACHE>) {
43 next if $line =~ /^\s*($|\#)/;
44 my ($key, $value) = ($line =~ /^(\S+)="(.*)"$/);
51 our %config = read_config_cache();
54 if ($type eq 'gen-ld') {
55 do_static_find(@ARGV);
56 } elsif ($type eq 'static-ld') {
57 do_static_link(@ARGV);
58 } elsif ($type eq 'core-ld') {
60 } elsif ($type eq 'link-dir') {
62 } elsif ($type eq 'gen-o') {
63 do_compile(1, 0, @ARGV);
64 } elsif ($type eq 'gen-so') {
65 do_compile(1, 1, @ARGV);
66 } elsif ($type eq 'link-so') {
67 do_compile(0, 1, @ARGV);
69 print STDERR "Unknown unit-cc subcommand $type!\n";
75 for my $file (@ARGV) {
76 push @flags, get_property($file, 'LinkerFlags');
79 print F join ' ', @flags;
85 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS}";
91 $execstr .= ' '.$libs;
97 $execstr .= ' '.$ENV{LDLIBS};
98 print "$execstr\n" if $verbose;
103 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}";
104 print "$execstr\n" if $verbose;
109 my $execstr = "$ENV{RUNLD} -o $out $ENV{PICLDFLAGS} @_";
110 print "$execstr\n" if $verbose;
115 my ($do_compile, $do_link, $file) = @_;
119 my $binary = $ENV{RUNCC};
121 $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
123 if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
124 $flags .= ' -DMODNAME=\\"'.$1.'\\"';
127 $binary = $ENV{RUNLD};
131 $flags = join ' ', $flags, $ENV{PICLDFLAGS};
132 $libs = get_property($file, 'LinkerFlags');
137 my $execstr = "$binary -o $out $flags $file $libs";
138 print "$execstr\n" if $verbose;