summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-13 23:53:08 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-13 23:53:08 +0000
commit4f0e6377e80d61ba633588568640881f6ddca9ec (patch)
tree8e7e214a27cd4de83f0b292d3442db7e96745406
parentad4d207905fa3ae5cec09163d7ac462e3120ad4b (diff)
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
-rwxr-xr-xconfigure13
-rw-r--r--make/utilities.pm41
-rw-r--r--src/modules/extra/gnutls_rpath.pl4
-rw-r--r--src/modules/extra/m_filter_pcre.cpp2
-rw-r--r--src/modules/extra/m_mysql.cpp2
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp2
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp4
-rw-r--r--src/modules/extra/mysql_rpath.pl7
-rw-r--r--src/modules/extra/openssl_config.pl14
-rw-r--r--src/modules/extra/pcre_rpath.pl7
10 files changed, 51 insertions, 45 deletions
diff --git a/configure b/configure
index 1a595d3fe..b76988fb3 100755
--- a/configure
+++ b/configure
@@ -18,6 +18,9 @@ use Socket;
use Cwd;
use Getopt::Long;
+# Utility functions for our buildsystem
+use make::utilities;
+
GetOptions (
'enable-gnutls' => \$opt_use_gnutls,
'enable-openssl' => \$opt_use_openssl,
@@ -264,7 +267,7 @@ if ($config{GCCVER} eq "") {
# Minihack! Convert Cygwin to 'Cyg-Static' so i can
# Keep my dynamic module experiments here for later
-# concideration!
+# consideration!
if ($config{OSNAME} =~ /CYGWIN/i)
{
@@ -1372,8 +1375,8 @@ sub getcompilerflags {
open(FLAGS, $file);
while (<FLAGS>) {
if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
- close(FLAGS);
- return $1;
+ close(FLAGS);
+ return translate_functions($1);
}
}
close(FLAGS);
@@ -1386,7 +1389,7 @@ sub getlinkerflags {
while (<FLAGS>) {
if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
close(FLAGS);
- return $1;
+ return translate_functions($1);
}
}
close(FLAGS);
@@ -1399,7 +1402,7 @@ sub getdependencies {
while (<FLAGS>) {
if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
close(FLAGS);
- return $1;
+ return translate_functions($1);
}
}
close(FLAGS);
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;
diff --git a/src/modules/extra/gnutls_rpath.pl b/src/modules/extra/gnutls_rpath.pl
deleted file mode 100644
index 3371d5c8a..000000000
--- a/src/modules/extra/gnutls_rpath.pl
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/perl
-$data = `libgnutls-config --libs`;
-$data =~ s/-L(\S+)\s/-Wl,--rpath -Wl,$1 -L$1 /g;
-print "$data";
diff --git a/src/modules/extra/m_filter_pcre.cpp b/src/modules/extra/m_filter_pcre.cpp
index 6d4964913..da0142317 100644
--- a/src/modules/extra/m_filter_pcre.cpp
+++ b/src/modules/extra/m_filter_pcre.cpp
@@ -22,7 +22,7 @@
/* $ModDesc: m_filter with regexps */
/* $CompileFlags: `pcre-config --cflags` */
-/* $LinkerFlags: `pcre-config --libs` `perl extra/pcre_rpath.pl` -lpcre */
+/* $LinkerFlags: `pcre-config --libs` rpath("pcre-config --libs") -lpcre */
/* $ModDep: m_filter.h */
class PCREFilter : public FilterResult
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index b0e6cfcc5..7b718b43a 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -25,7 +25,7 @@
/* $ModDesc: SQL Service Provider module for all other m_sql* modules */
/* $CompileFlags: `mysql_config --include` */
-/* $LinkerFlags: `mysql_config --libs_r` `perl extra/mysql_rpath.pl` */
+/* $LinkerFlags: `mysql_config --libs_r` rpath("mysql_config --libs_r") */
/* $ModDep: m_sqlv2.h */
/* THE NONBLOCKING MYSQL API!
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 808c748cc..bb76ec978 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -31,7 +31,7 @@
/* $ModDesc: Provides SSL support for clients */
/* $CompileFlags: `libgnutls-config --cflags` */
-/* $LinkerFlags: `perl extra/gnutls_rpath.pl` */
+/* $LinkerFlags: rpath("libgnutls-config --libs") */
/* $ModDep: transport.h */
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index f46f04988..3398af91f 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -30,8 +30,8 @@
#include "transport.h"
/* $ModDesc: Provides SSL support for clients */
-/* $CompileFlags: `perl extra/openssl_config.pl compile` */
-/* $LinkerFlags: `perl extra/openssl_config.pl link` */
+/* $CompileFlags: pkgconfincludes("openssl","/openssl/ssl.h","") */
+/* $LinkerFlags: pkgconflibs("openssl","/libssl.so","-lssl -lcrypto") */
/* $ModDep: transport.h */
enum issl_status { ISSL_NONE, ISSL_HANDSHAKING, ISSL_OPEN };
diff --git a/src/modules/extra/mysql_rpath.pl b/src/modules/extra/mysql_rpath.pl
deleted file mode 100644
index b1ac57b5a..000000000
--- a/src/modules/extra/mysql_rpath.pl
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/perl
-
-use lib "../..";
-use make::utilities;
-
-print make_rpath("mysql_config --libs_r");
-
diff --git a/src/modules/extra/openssl_config.pl b/src/modules/extra/openssl_config.pl
deleted file mode 100644
index 7fa03dc89..000000000
--- a/src/modules/extra/openssl_config.pl
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-
-use lib "../..";
-use make::utilities;
-
-if ($ARGV[0] eq "compile")
-{
- print pkgconfig_get_include_dirs("openssl", "/openssl/ssl.h", "");
-}
-else
-{
- print pkgconfig_get_lib_dirs("openssl", "/libssl.so", "-lssl -lcrypto");
-}
-
diff --git a/src/modules/extra/pcre_rpath.pl b/src/modules/extra/pcre_rpath.pl
deleted file mode 100644
index 00677895e..000000000
--- a/src/modules/extra/pcre_rpath.pl
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/perl
-
-use lib "../..";
-use make::utilities;
-
-print make_rpath("pcre-config --libs");
-