X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Funit-cc.pl;h=aba14a0bc461b5dd338d59ae91cf31e98abee6c0;hb=05e1fc8840dd783ffa65a22e0d537a1d8bdbad5c;hp=7474365aae60cf25da23d9da52ad095a2f580d64;hpb=553a8da754c8cd308bad2008018849714e70f9b7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/unit-cc.pl b/make/unit-cc.pl index 7474365aa..aba14a0bc 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -19,10 +19,18 @@ # +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}; @@ -30,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') { @@ -49,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; @@ -61,7 +80,7 @@ sub do_static_find { } sub do_static_link { - my $execstr = "$ENV{RUNLD} -o $out $ENV{CORELDFLAGS}"; + my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS}"; for (@ARGV) { if (/\.cmd$/) { open F, '<', $_; @@ -74,19 +93,23 @@ sub do_static_link { } } $execstr .= ' '.$ENV{LDLIBS}; - print "$execstr\n" if $verbose; + 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; } @@ -95,27 +118,22 @@ sub do_compile { my $flags = ''; my $libs = ''; - my $binary = $ENV{RUNCC}; 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}; - $libs = join ' ', getlinkerflags($file); + $libs = get_property($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; }