]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/configure.pm
m_spanningtree Remove SpanningTreeUtilities* fields and parameters
[user/henk/code/inspircd.git] / make / configure.pm
index abb706ddd6ef5942310b0e84ead1ce17ad115e06..ba67545ac36eb2fe41ec87d0338668fa6de6f072 100644 (file)
@@ -31,9 +31,9 @@ use warnings FATAL => qw(all);
 use Exporter 'import';
 use POSIX;
 use make::utilities;
-our @EXPORT = qw(get_compiler_info find_compiler test_file test_header promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies nopedantic resolve_directory yesno showhelp promptstring_s module_installed);
+our @EXPORT = qw(get_compiler_info find_compiler run_test test_file test_header promptnumeric dumphash getmodules getrevision get_property yesno showhelp promptstring_s module_installed);
 
-my $no_git = 0;
+my $revision;
 
 sub get_compiler_info($) {
         my %info = (NAME => shift, VERSION => '0.0');
@@ -68,6 +68,13 @@ sub find_compiler {
        return "";
 }
 
+sub run_test($$) {
+       my ($what, $result) = @_;
+       print "Checking whether $what is available... ";
+       print $result ? "yes\n" : "no\n";
+       return $result;
+}
+
 sub test_file($$;$) {
        my ($cc, $file, $args) = @_;
        my $status = 0;
@@ -103,90 +110,26 @@ sub yesno {
        return;
 }
 
-sub resolve_directory
+sub get_property($$;$)
 {
-       my $ret = $_[0];
-       eval
-       {
-               use File::Spec;
-               $ret = File::Spec->rel2abs($_[0]);
-       };
-       return $ret;
-}
-
-sub getrevision {
-       if ($no_git)
-       {
-               return "0";
-       }
-       my $data = `git describe --tags 2>/dev/null`;
-       if ($data eq "")
-       {
-               $no_git = 1;
-               return '0';
-       }
-       chomp $data; # remove \n
-       return $data;
-}
-
-sub getcompilerflags {
-       my ($file) = @_;
-       open(FLAGS, $file) or return "";
-       while (<FLAGS>) {
-               if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) {
-                       my $x = translate_functions($1, $file);
-                       next if ($x eq "");
-                       close(FLAGS);
-                       return $x;
-               }
-       }
-       close(FLAGS);
-       return "";
-}
-
-sub getlinkerflags {
-       my ($file) = @_;
-       open(FLAGS, $file) or return "";
-       while (<FLAGS>) {
-               if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) {
-                       my $x = translate_functions($1, $file);
-                       next if ($x eq "");
-                       close(FLAGS);
-                       return $x;
-               }
-       }
-       close(FLAGS);
-       return "";
-}
-
-sub getdependencies {
-       my ($file) = @_;
-       open(FLAGS, $file) or return "";
-       while (<FLAGS>) {
-               if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
-                       my $x = translate_functions($1, $file);
-                       next if ($x eq "");
-                       close(FLAGS);
-                       return $x;
+       my ($file, $property, $default) = @_;
+       open(MODULE, $file) or return $default;
+       while (<MODULE>) {
+               if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/) {
+                       next unless $1 eq $property;
+                       close(MODULE);
+                       return translate_functions($2, $file);
                }
        }
-       close(FLAGS);
-       return "";
+       close(MODULE);
+       return defined $default ? $default : '';
 }
 
-sub nopedantic {
-       my ($file) = @_;
-       open(FLAGS, $file) or return "";
-       while (<FLAGS>) {
-               if ($_ =~ /^\/\* \$NoPedantic \*\/$/) {
-                       my $x = translate_functions($_, $file);
-                       next if ($x eq "");
-                       close(FLAGS);
-                       return 1;
-               }
-       }
-       close(FLAGS);
-       return 0;
+sub getrevision {
+       return $revision if defined $revision;
+       chomp(my $tags = `git describe --tags 2>/dev/null`);
+       $revision = $tags || 'release';
+       return $revision;
 }
 
 sub getmodules
@@ -269,6 +212,8 @@ sub dumphash()
        print "\n\e[1;32mPre-build configuration is complete!\e[0m\n\n";
        print "\e[0mBase install path:\e[1;32m\t\t$main::config{BASE_DIR}\e[0m\n";
        print "\e[0mConfig path:\e[1;32m\t\t\t$main::config{CONFIG_DIR}\e[0m\n";
+       print "\e[0mData path:\e[1;32m\t\t\t$main::config{DATA_DIR}\e[0m\n";
+       print "\e[0mLog path:\e[1;32m\t\t\t$main::config{LOG_DIR}\e[0m\n";
        print "\e[0mModule path:\e[1;32m\t\t\t$main::config{MODULE_DIR}\e[0m\n";
        print "\e[0mCompiler:\e[1;32m\t\t\t$main::cxx{NAME} $main::cxx{VERSION}\e[0m\n";
        print "\e[0mSocket engine:\e[1;32m\t\t\t$main::config{SOCKETENGINE}\e[0m\n";
@@ -276,22 +221,6 @@ sub dumphash()
        print "\e[0mOpenSSL support:\e[1;32m\t\t$main::config{USE_OPENSSL}\e[0m\n";
 }
 
-sub is_dir
-{
-       my ($path) = @_;
-       if (chdir($path))
-       {
-               chdir($main::this);
-               return 1;
-       }
-       else
-       {
-               # Just in case..
-               chdir($main::this);
-               return 0;
-       }
-}
-
 sub showhelp
 {
        chomp(my $PWD = `pwd`);
@@ -304,20 +233,13 @@ sub showhelp
        print <<EOH;
 Usage: configure [options]
 
-*** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE ***
-*** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING  ***
-***     NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC!    ***
-
-Options: [defaults in brackets after descriptions]
-
 When no options are specified, interactive
 configuration is started and you must specify
 any required values manually. If one or more
 options are specified, non-interactive configuration
 is started, and any omitted values are defaulted.
 
-Arguments with a single \"-\" symbol, as in
-InspIRCd 1.0.x, are also allowed.
+Arguments with a single \"-\" symbol are also allowed.
 
   --disable-interactive        Sets no options itself, but
                                will disable any interactive prompting.
@@ -328,8 +250,8 @@ InspIRCd 1.0.x, are also allowed.
   --socketengine=[name]        Sets the socket engine to be used. Possible values are
                                $SELIST.
   --prefix=[directory]         Base directory to install into (if defined,
-                               can automatically define config, module, bin
-                               and library dirs as subdirectories of prefix)
+                               can automatically define config, data, module,
+                               log and binary dirs as subdirectories of prefix)
                                [$PWD]
   --config-dir=[directory]     Config file directory for config and SSL certs
                                [$PWD/conf]
@@ -342,8 +264,6 @@ InspIRCd 1.0.x, are also allowed.
                                [$PWD/modules]
   --binary-dir=[directory]     Binaries directory for core binary
                                [$PWD/bin]
-  --library-dir=[directory]    Library directory for core libraries
-                               [$PWD/lib]
   --list-extras                Show current status of extra modules
   --enable-extras=[extras]     Enable the specified list of extras
   --disable-extras=[extras]    Disable the specified list of extras