X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Funit-cc.pl;h=18e60d7597ad31a4b0d1fa12a0a20b68c615390a;hb=1f6b27d64ee917cd4df18fb21cc9af680939448d;hp=f04423ce3cf20920223bc14d5fc5634dc2c8c846;hpb=2a419c75253ff9b566888ffcda031f25414201f9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/unit-cc.pl b/make/unit-cc.pl index f04423ce3..18e60d759 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -29,21 +29,15 @@ use warnings FATAL => qw(all); use File::Spec::Functions qw(abs2rel); -use make::configure; use make::console; +use make::directive; chdir $ENV{BUILDPATH}; my $type = shift; my $out = shift; -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); @@ -67,34 +61,10 @@ sub message($$$) { } } -sub do_static_find { - my @flags; - for my $file (@ARGV) { - push @flags, get_property($file, 'LinkerFlags'); - } - open F, '>', $out; - print F join ' ', @flags; - close F; - exit 0; -} - -sub do_static_link { - my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS}"; - my $link_flags = ''; - for (@ARGV) { - if (/\.cmd$/) { - open F, '<', $_; - my $libs = ; - chomp $libs; - $link_flags .= ' '.$libs; - close F; - } else { - $execstr .= ' '.$_; - } - } - $execstr .= ' '.$ENV{LDLIBS}.' '.$link_flags; - 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 { @@ -106,9 +76,9 @@ sub do_core_link { sub do_link_dir { my ($dir, $link_flags) = (shift, ''); for my $file (<$dir/*.cpp>) { - $link_flags .= get_property($file, 'LinkerFlags') . ' '; + $link_flags .= rpath(get_directive($file, 'LinkerFlags', '')) . ' '; } - my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} $link_flags @_"; + my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} @_ $link_flags"; message 'LINK', $out, $execstr; exec $execstr; } @@ -119,7 +89,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.'\\"'; @@ -128,7 +98,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'; }