X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Funit-cc.pl;h=8006afe9b4072b1aa9a8ce7018bd11589fcdea43;hb=5f71fbdbffeecff18914fbe523e795a1d7680b47;hp=30b5363430ec190e7094a394f92119518f2e6bfc;hpb=df347edbdbb6d1d0f81795214674da8a4007850a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/unit-cc.pl b/make/unit-cc.pl index 30b536343..8006afe9b 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -1,20 +1,46 @@ #!/usr/bin/env perl +# +# InspIRCd -- Internet Relay Chat Daemon +# +# Copyright (C) 2019 iwalkalone +# Copyright (C) 2014 Attila Molnar +# Copyright (C) 2013, 2015-2016, 2018 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 +# redistribute it and/or modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation, version 2. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +BEGIN { + push @INC, $ENV{SOURCEPATH}; + require 5.10.0; +} + use strict; -use warnings; -BEGIN { push @INC, $ENV{SOURCEPATH}; } -use make::configure; +use warnings FATAL => qw(all); + +use File::Spec::Functions qw(abs2rel); + +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); @@ -29,43 +55,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}) { + print "$command\n"; + } else { + print_format "\t<|GREEN $type:|>\t\t$file\n"; } - open F, '>', $out; - print F join ' ', @flags; - close F; - exit 0; } -sub do_static_link { - my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} $ENV{LDLIBS}"; - for (@ARGV) { - if (/\.cmd$/) { - open F, '<', $_; - my $libs = ; - chomp $libs; - $execstr .= ' '.$libs; - close F; - } else { - $execstr .= ' '.$_; - } - } - 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; } @@ -73,26 +90,23 @@ sub do_compile { my ($do_compile, $do_link, $file) = @_; my $flags = ''; - my $binary = $ENV{RUNCC}; + my $libs = ''; if ($do_compile) { - $flags = $ENV{CXXFLAGS}; - $flags =~ s/ -pedantic// if nopedantic($file); - $flags .= ' ' . getcompilerflags($file); + $flags = $ENV{CORECXXFLAGS} . ' ' . get_directive($file, 'CompilerFlags', ''); - if ($file =~ m#(?:^|/)((?:m|cmd)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) { - $flags .= ' -DMODNAME='.$1.'.so'; + if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) { + $flags .= ' -DMODNAME=\\"'.$1.'\\"'; } - } else { - $binary = $ENV{RUNLD}; } if ($do_link) { - $flags = join ' ', $flags, $ENV{PICLDFLAGS}, getlinkerflags($file); + $flags = join ' ', $flags, $ENV{PICLDFLAGS}; + $libs = rpath(get_directive($file, 'LinkerFlags', '')); } else { $flags .= ' -c'; } - my $execstr = "$binary -o $out $flags $file"; - print "$execstr\n" if $verbose; + my $execstr = "$ENV{CXX} -o $out $flags $file $libs"; + message 'BUILD', abs2rel($file, "$ENV{SOURCEPATH}/src"), $execstr; exec $execstr; }