From 4f0e6377e80d61ba633588568640881f6ddca9ec Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 13 Jan 2007 23:53:08 +0000 Subject: Extra stuff to improve buildsystem, calculate lib and include dirs at configure time rather than at build time. This means that we can also throw errors at configure time if we cant find the libraries, rather than erroring at buildtime like we used to. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6306 e03df62e-2008-0410-955e-edbf42e46eb7 --- make/utilities.pm | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'make') diff --git a/make/utilities.pm b/make/utilities.pm index a7e0eb794..a227be3a4 100644 --- a/make/utilities.pm +++ b/make/utilities.pm @@ -1,6 +1,6 @@ package make::utilities; use Exporter 'import'; -@EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs); +@EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs translate_functions); # Parse the output of a *_config program, # such as pcre_config, take out the -L @@ -9,10 +9,10 @@ use Exporter 'import'; sub make_rpath($) { my ($executable) = @_; - $data = `$executable`; + chomp($data = `$executable`); $data =~ /-L(\S+)\s/; $libpath = $1; - return "-Wl,--rpath -Wl,$libpath"; + return "-Wl,--rpath -Wl,$libpath -L$libpath"; } sub extend_pkg_path() @@ -51,6 +51,7 @@ sub pkgconfig_get_include_dirs($$$) { $ret = "$foo " . $defaults; } + chomp($ret); return $ret; } @@ -79,8 +80,42 @@ sub pkgconfig_get_lib_dirs($$$) { $ret = "$foo " . $defaults; } + chomp($ret); return $ret; } +# Translate a $CompileFlags etc line and parse out function calls +# to functions within these modules at configure time. +sub translate_functions($) +{ + my ($line) = @_; + while ($line =~ /pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/) + { + my $replace = pkgconfig_get_lib_dirs($1, $2, $3); + $line =~ s/pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/$replace/; + } + while ($line =~ /pkgconflibs\("(.+?)","(.+?)",""\)/) + { + my $replace = pkgconfig_get_lib_dirs($1, $2, ""); + $line =~ s/pkgconflibs\("(.+?)","(.+?)",""\)/$replace/; + } + while ($line =~ /pkgconfincludes\("(.+?)","(.+?)",""\)/) + { + my $replace = pkgconfig_get_include_dirs($1, $2, ""); + $line =~ s/pkgconfincludes\("(.+?)","(.+?)",""\)/$replace/; + } + while ($line =~ /pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/) + { + my $replace = pkgconfig_get_include_dirs($1, $2, $3); + $line =~ s/pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/$replace/; + } + while ($line =~ /rpath\("(.+?)"\)/) + { + my $replace = make_rpath($1); + $line =~ s/rpath\("(.+?)"\)/$replace/; + } + return $line; +} + 1; -- cgit v1.2.3