1# PSPP - a program for statistical analysis.
2# Copyright (C) 2019 Free Software Foundation, Inc.
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17use 5.008008;
18use ExtUtils::MakeMaker;
19# See lib/ExtUtils/MakeMaker.pm for details of how to influence
20# the contents of the Makefile that is written.
21
22
23do './pspp-module-config' || do {
24    my $build = prompt ("Enter the location of the build directory of the configured pspp source:", "" );
25    my $src = $top_srcdir;
26
27    %Locations = (SourceDir => "$src", BuildDir => "$build");
28};
29
30WriteMakefile(
31    FULLPERL          => "PSPP_TEST_CMD=\"$Locations{BuildDir}/src/ui/terminal/pspp\" \$(PERL)",
32    NAME              => 'PSPP',
33    DISTNAME          => 'PSPP-Perl',
34    VERSION_FROM      => "$Locations{BuildDir}/src/libpspp/version.c",
35    PREREQ_PM         => {POSIX=>0},
36    PM                => {"lib/PSPP.pm", "\$(INST_LIBDIR)/PSPP.pm"},
37    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
38      (ABSTRACT       => 'Perl extension to PSPP',
39       AUTHOR         => 'John Darrington <john@darrington.wattle.id.au>') : ()),
40    INC       => "-I $Locations{SourceDir}  -I $Locations{SourceDir}/src -I $Locations{SourceDir}/gl -I $Locations{BuildDir}/gl -I $Locations{BuildDir}",
41    MYEXTLIB  => "$Locations{BuildDir}/src/.libs/libpspp-core.\$(SO)",
42    MAN3PODS  => {"lib/PSPP.pm", "\$(INST_MAN3DIR)/PSPP.3pm",
43	    "Examples.pod", "\$(INST_MAN3DIR)/PSPP::Examples.3pm"}
44);
45
46if  (eval {require ExtUtils::Constant; 1}) {
47  # If you edit these definitions to change the constants used by this module,
48  # you will need to use the generated const-c.inc and const-xs.inc
49  # files to replace their "fallback" counterparts before distributing your
50  # changes.
51  my @names = (qw());
52  ExtUtils::Constant::WriteConstants(
53                                     NAME         => 'PSPP',
54                                     NAMES        => \@names,
55                                     DEFAULT_TYPE => 'IV',
56                                     C_FILE       => 'const-c.inc',
57                                     XS_FILE      => 'const-xs.inc',
58                                  );
59
60}
61else {
62  use File::Copy;
63  use File::Spec;
64  foreach my $file ('const-c.inc', 'const-xs.inc') {
65    my $fallback = File::Spec->catfile('fallback', $file);
66    copy ($fallback, $file) or die "Can't copy $fallback to $file: $!";
67  }
68}
69