diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-13 23:29:40 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-13 23:29:40 +0000 |
commit | ad4d207905fa3ae5cec09163d7ac462e3120ad4b (patch) | |
tree | e2ddaebfa397f2581c081ec25fefcbd0308b978e | |
parent | 568018bdbd1f35f494c3cbf5194bbb40394dcb4d (diff) |
Tidy up the buildsystem a lot by encapsulating repeated detection routines for lib dirs and header dirs in make/utilities.pm.
See the pl files in src/modules/extra for how to use the functions.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6305 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | make/utilities.pm | 86 | ||||
-rw-r--r-- | src/modules/extra/mysql_rpath.pl | 9 | ||||
-rw-r--r-- | src/modules/extra/openssl_config.pl | 44 | ||||
-rw-r--r-- | src/modules/extra/pcre_rpath.pl | 10 | ||||
-rw-r--r-- | src/modules/extra/sqlite3_config.pl | 39 |
5 files changed, 112 insertions, 76 deletions
diff --git a/make/utilities.pm b/make/utilities.pm new file mode 100644 index 000000000..a7e0eb794 --- /dev/null +++ b/make/utilities.pm @@ -0,0 +1,86 @@ +package make::utilities; +use Exporter 'import'; +@EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs); + +# Parse the output of a *_config program, +# such as pcre_config, take out the -L +# directive and return an rpath for it. + +sub make_rpath($) +{ + my ($executable) = @_; + $data = `$executable`; + $data =~ /-L(\S+)\s/; + $libpath = $1; + return "-Wl,--rpath -Wl,$libpath"; +} + +sub extend_pkg_path() +{ + if (!exists $ENV{PKG_CONFIG_PATH}) + { + $ENV{PKG_CONFIG_PATH} = "/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/X11R6/libdata/pkgconfig"; + } + else + { + $ENV{PKG_CONFIG_PATH} .= ":/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/X11R6/libdata/pkgconfig"; + } +} + +sub pkgconfig_get_include_dirs($$$) +{ + my ($packagename, $headername, $defaults) = @_; + extend_pkg_path(); + + $ret = `pkg-config --cflags $packagename 2>/dev/null`; + if ((!defined $ret) || ($ret eq "")) + { + $foo = `locate "$headername" | head -n 1`; + $foo =~ /(.+)\Q$headername\E/; + if (defined $1) + { + $foo = "-I$1"; + } + else + { + $foo = ""; + } + $ret = "$foo"; + } + if (($defaults ne "") && (($ret eq "") || (!defined $ret))) + { + $ret = "$foo " . $defaults; + } + return $ret; +} + +sub pkgconfig_get_lib_dirs($$$) +{ + my ($packagename, $libname, $defaults) = @_; + extend_pkg_path(); + + $ret = `pkg-config --libs $packagename 2>/dev/null`; + if ((!defined $ret) || ($ret eq "")) + { + $foo = `locate "$libname" | head -n 1`; + $foo =~ /(.+)\Q$libname\E/; + if (defined $1) + { + $foo = "-L$1"; + } + else + { + $foo = ""; + } + $ret = "$foo"; + } + + if (($defaults ne "") && (($ret eq "") || (!defined $ret))) + { + $ret = "$foo " . $defaults; + } + return $ret; +} + +1; + diff --git a/src/modules/extra/mysql_rpath.pl b/src/modules/extra/mysql_rpath.pl index befa45a82..b1ac57b5a 100644 --- a/src/modules/extra/mysql_rpath.pl +++ b/src/modules/extra/mysql_rpath.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl -$data = `mysql_config --libs_r`; -$data =~ /-L(\S+)\s/; -$libpath = $1; -print "-Wl,--rpath -Wl,$libpath"; + +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 index 61d8f2902..7fa03dc89 100644 --- a/src/modules/extra/openssl_config.pl +++ b/src/modules/extra/openssl_config.pl @@ -1,48 +1,14 @@ #!/usr/bin/perl -if (!exists $ENV{PKG_CONFIG_PATH}) -{ - $ENV{PKG_CONFIG_PATH} = "/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/X11R6/libdata/pkgconfig"; -} -else -{ - $ENV{PKG_CONFIG_PATH} .= ":/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/X11R6/libdata/pkgconfig"; -} +use lib "../.."; +use make::utilities; if ($ARGV[0] eq "compile") { - $ret = `pkg-config --cflags openssl 2>/dev/null`; - if ((!defined $ret) || ($ret eq "")) - { - $foo = `locate "/openssl/ssl.h" | head -n 1`; - $foo =~ /(.+)\/openssl\/ssl\.h/; - if (defined $1) - { - $foo = "-I$1"; - } - else - { - $foo = ""; - } - $ret = "$foo\n"; - } + print pkgconfig_get_include_dirs("openssl", "/openssl/ssl.h", ""); } else { - $ret = `pkg-config --libs openssl 2>/dev/null`; - if ((!defined $ret) || ($ret eq "")) - { - $foo = `locate "/libssl.so" | head -n 1`; - $foo =~ /(.+)\/libssl\.so/; - if (defined $1) - { - $foo = "-L$1"; - } - else - { - $foo = ""; - } - $ret = "$foo -lssl -lcrypto\n"; - } + print pkgconfig_get_lib_dirs("openssl", "/libssl.so", "-lssl -lcrypto"); } -print "$ret"; + diff --git a/src/modules/extra/pcre_rpath.pl b/src/modules/extra/pcre_rpath.pl index 4699b7f87..00677895e 100644 --- a/src/modules/extra/pcre_rpath.pl +++ b/src/modules/extra/pcre_rpath.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -# Usage: pcre-config [--prefix] [--exec-prefix] [--version] [--libs] [--libs-posix] [--cflags] [--cflags-posix] -$data = `pcre-config --libs`; -$data =~ /-L(\S+)\s/; -$libpath = $1; -print "-Wl,--rpath -Wl,$libpath"; + +use lib "../.."; +use make::utilities; + +print make_rpath("pcre-config --libs"); diff --git a/src/modules/extra/sqlite3_config.pl b/src/modules/extra/sqlite3_config.pl index 33f7594ee..ddede3a3c 100644 --- a/src/modules/extra/sqlite3_config.pl +++ b/src/modules/extra/sqlite3_config.pl @@ -1,30 +1,13 @@ #!/usr/bin/perl -if (!exists $ENV{PKG_CONFIG_PATH}) { - $ENV{PKG_CONFIG_PATH} = "/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/X11R6/libdata/pkgconfig"; + +use lib "../.."; +use make::utilities; + +if ($ARGV[0] eq "compile") +{ + print pkgconfig_get_include_dirs("sqlite", "/sqlite3.h", ""); +} +else +{ + print pkgconfig_get_lib_dirs("sqlite", "/libsqlite3.so", "-lsqlite3"); } -else { - $ENV{PKG_CONFIG_PATH} .= ":/usr/local/lib/pkgconfig:/usr/local/libdata/pkgconfig:/usr/X11R6/libdata/pkgconfig"; -} -if ($ARGV[0] eq "compile") { - $ret = `pkg-config --cflags sqlite 2>/dev/null`; if ((!defined $ret) || ($ret eq "")) { - $foo = `locate "/sqlite3.h" | head -n 1`; $foo =~ /(.+)\/sqlite3\.h/; if (defined $1) { - $foo = "-I$1"; - } - else { - $foo = ""; - } - $ret = "$foo\n"; - } -} -else { - $ret = `pkg-config --libs sqlite3 2>/dev/null`; if ((!defined $ret) || ($ret eq "")) { - $foo = `locate "/libsqlite3.so" | head -n 1`; $foo =~ /(.+)\/libsqlite3\.so/; if (defined $1) { - $foo = "-L$1"; - } - else { - $foo = ""; - } - $ret = "$foo -lsqlite3\n"; - } -} -print "$ret"; |