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);
30 use File::Spec::Functions qw(abs2rel);
35 chdir $ENV{BUILDPATH};
39 my $verbose = ($type =~ s/-v$//);
41 our %config = read_configure_cache();
43 if ($type eq 'gen-ld') {
44 do_static_find(@ARGV);
45 } elsif ($type eq 'static-ld') {
46 do_static_link(@ARGV);
47 } elsif ($type eq 'core-ld') {
49 } elsif ($type eq 'link-dir') {
51 } elsif ($type eq 'gen-o') {
52 do_compile(1, 0, @ARGV);
53 } elsif ($type eq 'gen-so') {
54 do_compile(1, 1, @ARGV);
55 } elsif ($type eq 'link-so') {
56 do_compile(0, 1, @ARGV);
58 print STDERR "Unknown unit-cc subcommand $type!\n";
63 my ($type, $file, $command) = @_;
67 print_format "\t<|GREEN $type:|>\t\t$file\n";
73 for my $file (@ARGV) {
74 push @flags, get_property($file, 'LinkerFlags');
77 print F join ' ', @flags;
83 my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS}";
89 $execstr .= ' '.$libs;
95 $execstr .= ' '.$ENV{LDLIBS};
96 message 'LINK', $out, $execstr;
101 my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}";
102 message 'LINK', $out, $execstr;
107 my ($dir, $link_flags) = (shift, '');
108 for my $file (<$dir/*.cpp>) {
109 $link_flags .= get_property($file, 'LinkerFlags') . ' ';
111 my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} $link_flags @_";
112 message 'LINK', $out, $execstr;
117 my ($do_compile, $do_link, $file) = @_;
122 $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
124 if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
125 $flags .= ' -DMODNAME=\\"'.$1.'\\"';
130 $flags = join ' ', $flags, $ENV{PICLDFLAGS};
131 $libs = get_property($file, 'LinkerFlags');
136 my $execstr = "$ENV{CXX} -o $out $flags $file $libs";
137 message 'BUILD', abs2rel($file, "$ENV{SOURCEPATH}/src"), $execstr;