X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Funit-cc.pl;h=f4fa5a650a6fddfc513fe8348d6c679062d5da45;hb=c05f81cac83e80c7727594e3929e0709eccca689;hp=55c491e0d9fa7732a1ebc8ead82ea2a778bb0d4d;hpb=abc57eddfb56462ac3e433601d010abf1942e611;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/unit-cc.pl b/make/unit-cc.pl index 55c491e0d..f4fa5a650 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -1,8 +1,11 @@ #!/usr/bin/env perl - # # InspIRCd -- Internet Relay Chat Daemon # +# Copyright (C) 2019 iwalkalone +# Copyright (C) 2014 Attila Molnar +# Copyright (C) 2013, 2015-2016, 2018, 2021 Sadie Powell +# Copyright (C) 2012 Robby # Copyright (C) 2009-2010 Daniel De Graaf # # This file is part of InspIRCd. InspIRCd is free software: you can @@ -19,22 +22,24 @@ # +use v5.10.0; use strict; -use warnings; -BEGIN { push @INC, $ENV{SOURCEPATH}; } -use make::configure; +use warnings FATAL => qw(all); + +use File::Basename qw(dirname); +use File::Spec::Functions qw(abs2rel); +use FindBin qw($RealDir); + +use lib dirname $RealDir; +use make::console; +use make::directive; chdir $ENV{BUILDPATH}; my $type = shift; my $out = shift; -my $verbose = ($type =~ s/-v$//); -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); @@ -49,44 +54,34 @@ if ($type eq 'gen-ld') { } exit 1; -sub do_static_find { - my @flags; - for my $file (@ARGV) { - push @flags, getlinkerflags($file); +sub message($$$) { + my ($type, $file, $command) = @_; + if ($ENV{INSPIRCD_VERBOSE}) { + say $command; + } else { + 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{RUNLD} -o $out $ENV{CORELDFLAGS}"; - for (@ARGV) { - if (/\.cmd$/) { - open F, '<', $_; - my $libs = ; - chomp $libs; - $execstr .= ' '.$libs; - close F; - } else { - $execstr .= ' '.$_; - } - } - $execstr .= ' '.$ENV{LDLIBS}; - print "$execstr\n" if $verbose; - 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 { - my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}"; - print "$execstr\n" if $verbose; + my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}"; + message 'LINK', $out, $execstr; exec $execstr; } sub do_link_dir { - my $execstr = "$ENV{RUNLD} -o $out $ENV{PICLDFLAGS} @_"; - print "$execstr\n" if $verbose; + 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; } @@ -95,27 +90,22 @@ sub do_compile { my $flags = ''; my $libs = ''; - my $binary = $ENV{RUNCC}; if ($do_compile) { - $flags = $ENV{CORECXXFLAGS}; - $flags =~ s/ -pedantic// if nopedantic($file); - $flags .= ' ' . getcompilerflags($file); + $flags = $ENV{CORECXXFLAGS} . ' ' . get_directive($file, 'CompilerFlags', ''); - if ($file =~ m#(?:^|/)((?:m|cmd)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) { + if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) { $flags .= ' -DMODNAME=\\"'.$1.'\\"'; } - } else { - $binary = $ENV{RUNLD}; } if ($do_link) { $flags = join ' ', $flags, $ENV{PICLDFLAGS}; - $libs = join ' ', getlinkerflags($file); + $libs = rpath(get_directive($file, 'LinkerFlags', '')); } else { $flags .= ' -c'; } - my $execstr = "$binary -o $out $flags $file $libs"; - print "$execstr\n" if $verbose; + my $execstr = "$ENV{CXX} -o $out $flags $file $libs"; + message 'BUILD', abs2rel($file, "$ENV{SOURCEPATH}/src"), $execstr; exec $execstr; }