+sub do_link_dir {
+ my ($dir, $link_flags) = (shift, '');
+ for my $file (<$dir/*.cpp>) {
+ $link_flags .= rpath(get_directive($file, 'LinkerFlags', '')) . ' ';
+ }
+ my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} @_ $link_flags";
+ message 'LINK', $out, $execstr;
+ exec $execstr;
+}
+
+sub do_compile {
+ my ($do_compile, $do_link, $file) = @_;
+
+ my $flags = '';
+ my $libs = '';
+ if ($do_compile) {
+ $flags = $ENV{CORECXXFLAGS} . ' ' . get_directive($file, 'CompilerFlags', '');
+
+ if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
+ $flags .= ' -DMODNAME=\\"'.$1.'\\"';
+ }
+ }
+
+ if ($do_link) {
+ $flags = join ' ', $flags, $ENV{PICLDFLAGS};
+ $libs = rpath(get_directive($file, 'LinkerFlags', ''));
+ } else {
+ $flags .= ' -c';
+ }
+
+ my $execstr = "$ENV{CXX} -o $out $flags $file $libs";
+ message 'BUILD', abs2rel($file, "$ENV{SOURCEPATH}/src"), $execstr;
+ exec $execstr;
+}