]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/unit-cc.pl
Use IsCTCP in blockcolor for ignoring CTCPs.
[user/henk/code/inspircd.git] / make / unit-cc.pl
index 0a20738db0232dd22c720773924e347b3ac7aaff..f4fa5a650a6fddfc513fe8348d6c679062d5da45 100755 (executable)
@@ -1,8 +1,11 @@
 #!/usr/bin/env perl
-
 #
 # InspIRCd -- Internet Relay Chat Daemon
 #
+#   Copyright (C) 2019 iwalkalone <iwalkalone69@gmail.com>
+#   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+#   Copyright (C) 2013, 2015-2016, 2018, 2021 Sadie Powell <sadie@witchery.services>
+#   Copyright (C) 2012 Robby <robby@chatbelgie.be>
 #   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
 #
 # This file is part of InspIRCd.  InspIRCd is free software: you can
 #
 
 
-BEGIN {
-       push @INC, $ENV{SOURCEPATH};
-       require 5.10.0;
-}
-
+use v5.10.0;
 use strict;
 use warnings FATAL => qw(all);
 
+use File::Basename        qw(dirname);
 use File::Spec::Functions qw(abs2rel);
+use FindBin               qw($RealDir);
 
-use make::configure;
+use lib dirname $RealDir;
 use make::console;
+use make::directive;
 
 chdir $ENV{BUILDPATH};
 
 my $type = shift;
 my $out = shift;
-my $verbose = ($type =~ s/-v$//);
 
-our %config = read_configure_cache();
-
-if ($type eq 'gen-ld') {
-       do_static_find(@ARGV);
-} elsif ($type eq 'static-ld') {
-       do_static_link(@ARGV);
-} elsif ($type eq 'core-ld') {
+if ($type eq 'core-ld') {
        do_core_link(@ARGV);
 } elsif ($type eq 'link-dir') {
        do_link_dir(@ARGV);
@@ -61,40 +56,17 @@ exit 1;
 
 sub message($$$) {
        my ($type, $file, $command) = @_;
-       if ($verbose) {
-               print "$command\n";
+       if ($ENV{INSPIRCD_VERBOSE}) {
+               say $command;
        } else {
-               print_format "\t<|GREEN $type:|>\t\t$file\n";
-       }
-}
-
-sub do_static_find {
-       my @flags;
-       for my $file (@ARGV) {
-               push @flags, get_property($file, 'LinkerFlags');
+               say console_format "\t<|GREEN $type:|>\t\t$file";
        }
-       open F, '>', $out;
-       print F join ' ', @flags;
-       close F;
-       exit 0;
 }
 
-sub do_static_link {
-       my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS}";
-       for (@ARGV) {
-               if (/\.cmd$/) {
-                       open F, '<', $_;
-                       my $libs = <F>;
-                       chomp $libs;
-                       $execstr .= ' '.$libs;
-                       close F;
-               } else {
-                       $execstr .= ' '.$_;
-               }
-       }
-       $execstr .= ' '.$ENV{LDLIBS};
-       message 'LINK', $out, $execstr;
-       exec $execstr;
+sub rpath($) {
+       my $message = shift;
+       $message =~ s/-L(\S+)/-Wl,-rpath,$1 -L$1/g unless defined $ENV{INSPIRCD_DISABLE_RPATH};
+       return $message;
 }
 
 sub do_core_link {
@@ -104,7 +76,11 @@ sub do_core_link {
 }
 
 sub do_link_dir {
-       my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} @_";
+       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;
 }
@@ -115,7 +91,7 @@ sub do_compile {
        my $flags = '';
        my $libs = '';
        if ($do_compile) {
-               $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
+               $flags = $ENV{CORECXXFLAGS} . ' ' . get_directive($file, 'CompilerFlags', '');
 
                if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
                        $flags .= ' -DMODNAME=\\"'.$1.'\\"';
@@ -124,7 +100,7 @@ sub do_compile {
 
        if ($do_link) {
                $flags = join ' ', $flags, $ENV{PICLDFLAGS};
-               $libs = get_property($file, 'LinkerFlags');
+               $libs = rpath(get_directive($file, 'LinkerFlags', ''));
        } else {
                $flags .= ' -c';
        }