Integrated the perl module into the pspp build system.
[pspp-builds.git] / perl-module / Makefile.PL
diff --git a/perl-module/Makefile.PL b/perl-module/Makefile.PL
new file mode 100644 (file)
index 0000000..40b14ef
--- /dev/null
@@ -0,0 +1,50 @@
+use 5.008008;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+
+
+do 'pspp-module-config' || do {
+    my $src = prompt ("Enter the location of the full pspp source","../pspp");
+    my $build = prompt ("Enter the location of the pspp build directory", "$src" );
+
+    %Locations = (SourceDir => "$src", BuildDir => "$build");
+};
+
+WriteMakefile(
+    NAME              => 'PSPP',
+    VERSION_FROM      => "$Locations{BuildDir}/src/libpspp/version.c", 
+    PREREQ_PM         => {POSIX=>0}, 
+    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
+      (ABSTRACT_FROM  => 'lib/PSPP.pm', # retrieve abstract from module
+       AUTHOR         => 'John Darrington <john@darrington.wattle.id.au>') : ()),
+    INC       => "-I $Locations{SourceDir}  -I $Locations{SourceDir}/src -I $Locations{SourceDir}/gl -I $Locations{BuildDir}/gl -I $Locations{BuildDir}", 
+
+    MYEXTLIB  => "$Locations{BuildDir}/src/.libs/libpspp-core\$(LIB_EXT)",
+    MAN3PODS  => {"lib/PSPP.pm", "\$(INST_MAN3DIR)/PSPP.3pm",
+           "Examples.pod", "\$(INST_MAN3DIR)/PSPP::Examples.3pm"}
+);
+
+if  (eval {require ExtUtils::Constant; 1}) {
+  # If you edit these definitions to change the constants used by this module,
+  # you will need to use the generated const-c.inc and const-xs.inc
+  # files to replace their "fallback" counterparts before distributing your
+  # changes.
+  my @names = (qw());
+  ExtUtils::Constant::WriteConstants(
+                                     NAME         => 'PSPP',
+                                     NAMES        => \@names,
+                                     DEFAULT_TYPE => 'IV',
+                                     C_FILE       => 'const-c.inc',
+                                     XS_FILE      => 'const-xs.inc',
+                                  );
+
+}
+else {
+  use File::Copy;
+  use File::Spec;
+  foreach my $file ('const-c.inc', 'const-xs.inc') {
+    my $fallback = File::Spec->catfile('fallback', $file);
+    copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
+  }
+}