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/>.
24 BEGIN { push @INC, $ENV{SOURCEPATH}; }
27 chdir $ENV{BUILDPATH};
31 my $verbose = ($type =~ s/-v$//);
33 ## BEGIN HACK: REMOVE IN 2.2!
34 sub read_config_cache {
36 open(CACHE, '../.config.cache') or return %cfg;
37 while (my $line = <CACHE>) {
38 next if $line =~ /^\s*($|\#)/;
39 my ($key, $value) = ($line =~ /^(\S+)="(.*)"$/);
46 our %config = read_config_cache();
49 if ($type eq 'gen-ld') {
50 do_static_find(@ARGV);
51 } elsif ($type eq 'static-ld') {
52 do_static_link(@ARGV);
53 } elsif ($type eq 'core-ld') {
55 } elsif ($type eq 'link-dir') {
57 } elsif ($type eq 'gen-o') {
58 do_compile(1, 0, @ARGV);
59 } elsif ($type eq 'gen-so') {
60 do_compile(1, 1, @ARGV);
61 } elsif ($type eq 'link-so') {
62 do_compile(0, 1, @ARGV);
64 print STDERR "Unknown unit-cc subcommand $type!\n";
70 for my $file (@ARGV) {
71 push @flags, get_property($file, 'LinkerFlags');
74 print F join ' ', @flags;
80 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS}";
86 $execstr .= ' '.$libs;
92 $execstr .= ' '.$ENV{LDLIBS};
93 print "$execstr\n" if $verbose;
98 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}";
99 print "$execstr\n" if $verbose;
104 my $execstr = "$ENV{RUNLD} -o $out $ENV{PICLDFLAGS} @_";
105 print "$execstr\n" if $verbose;
110 my ($do_compile, $do_link, $file) = @_;
114 my $binary = $ENV{RUNCC};
116 $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
118 if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
119 $flags .= ' -DMODNAME=\\"'.$1.'\\"';
122 $binary = $ENV{RUNLD};
126 $flags = join ' ', $flags, $ENV{PICLDFLAGS};
127 $libs = get_property($file, 'LinkerFlags');
132 my $execstr = "$binary -o $out $flags $file $libs";
133 print "$execstr\n" if $verbose;