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 our %config = read_configure_cache();
40 if ($type eq 'gen-ld') {
41 do_static_find(@ARGV);
42 } elsif ($type eq 'static-ld') {
43 do_static_link(@ARGV);
44 } elsif ($type eq 'core-ld') {
46 } elsif ($type eq 'link-dir') {
48 } elsif ($type eq 'gen-o') {
49 do_compile(1, 0, @ARGV);
50 } elsif ($type eq 'gen-so') {
51 do_compile(1, 1, @ARGV);
52 } elsif ($type eq 'link-so') {
53 do_compile(0, 1, @ARGV);
55 print STDERR "Unknown unit-cc subcommand $type!\n";
61 for my $file (@ARGV) {
62 push @flags, get_property($file, 'LinkerFlags');
65 print F join ' ', @flags;
71 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS}";
77 $execstr .= ' '.$libs;
83 $execstr .= ' '.$ENV{LDLIBS};
84 print "$execstr\n" if $verbose;
89 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}";
90 print "$execstr\n" if $verbose;
95 my $execstr = "$ENV{RUNLD} -o $out $ENV{PICLDFLAGS} @_";
96 print "$execstr\n" if $verbose;
101 my ($do_compile, $do_link, $file) = @_;
105 my $binary = $ENV{RUNCC};
107 $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
109 if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
110 $flags .= ' -DMODNAME=\\"'.$1.'\\"';
113 $binary = $ENV{RUNLD};
117 $flags = join ' ', $flags, $ENV{PICLDFLAGS};
118 $libs = get_property($file, 'LinkerFlags');
123 my $execstr = "$binary -o $out $flags $file $libs";
124 print "$execstr\n" if $verbose;