X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Funit-cc.pl;h=aba14a0bc461b5dd338d59ae91cf31e98abee6c0;hb=05e1fc8840dd783ffa65a22e0d537a1d8bdbad5c;hp=30b5363430ec190e7094a394f92119518f2e6bfc;hpb=df347edbdbb6d1d0f81795214674da8a4007850a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/unit-cc.pl b/make/unit-cc.pl index 30b536343..aba14a0bc 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -1,8 +1,36 @@ #!/usr/bin/env perl + +# +# InspIRCd -- Internet Relay Chat Daemon +# +# 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 warnings FATAL => qw(all); + +use File::Spec::Functions qw(abs2rel); + use make::configure; +use make::console; chdir $ENV{BUILDPATH}; @@ -10,6 +38,8 @@ 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') { @@ -29,10 +59,19 @@ if ($type eq 'gen-ld') { } exit 1; +sub message($$$) { + my ($type, $file, $command) = @_; + if ($verbose) { + print "$command\n"; + } else { + print_format "\t<|GREEN $type:|>\t\t$file\n"; + } +} + sub do_static_find { my @flags; for my $file (@ARGV) { - push @flags, getlinkerflags($file); + push @flags, get_property($file, 'LinkerFlags'); } open F, '>', $out; print F join ' ', @flags; @@ -41,7 +80,7 @@ sub do_static_find { } sub do_static_link { - my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS} $ENV{LDLIBS}"; + my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS}"; for (@ARGV) { if (/\.cmd$/) { open F, '<', $_; @@ -53,19 +92,24 @@ sub do_static_link { $execstr .= ' '.$_; } } - print "$execstr\n" if $verbose; + $execstr .= ' '.$ENV{LDLIBS}; + message 'LINK', $out, $execstr; exec $execstr; } 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 .= get_property($file, 'LinkerFlags') . ' '; + } + my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} $link_flags @_"; + message 'LINK', $out, $execstr; exec $execstr; } @@ -73,26 +117,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_property($file, 'CompileFlags'); - 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 = get_property($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; }