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 if ($type eq 'gen-ld') {
34 do_static_find(@ARGV);
35 } elsif ($type eq 'static-ld') {
36 do_static_link(@ARGV);
37 } elsif ($type eq 'core-ld') {
39 } elsif ($type eq 'link-dir') {
41 } elsif ($type eq 'gen-o') {
42 do_compile(1, 0, @ARGV);
43 } elsif ($type eq 'gen-so') {
44 do_compile(1, 1, @ARGV);
45 } elsif ($type eq 'link-so') {
46 do_compile(0, 1, @ARGV);
48 print STDERR "Unknown unit-cc subcommand $type!\n";
54 for my $file (@ARGV) {
55 push @flags, get_property($file, 'LinkerFlags');
58 print F join ' ', @flags;
64 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS}";
70 $execstr .= ' '.$libs;
76 $execstr .= ' '.$ENV{LDLIBS};
77 print "$execstr\n" if $verbose;
82 my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}";
83 print "$execstr\n" if $verbose;
88 my $execstr = "$ENV{RUNLD} -o $out $ENV{PICLDFLAGS} @_";
89 print "$execstr\n" if $verbose;
94 my ($do_compile, $do_link, $file) = @_;
98 my $binary = $ENV{RUNCC};
100 $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
102 if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
103 $flags .= ' -DMODNAME=\\"'.$1.'\\"';
106 $binary = $ENV{RUNLD};
110 $flags = join ' ', $flags, $ENV{PICLDFLAGS};
111 $libs = get_property($file, 'LinkerFlags');
116 my $execstr = "$binary -o $out $flags $file $libs";
117 print "$execstr\n" if $verbose;