Skip to content
Snippets Groups Projects
Commit c52fbe34 authored by Danny Auble's avatar Danny Auble
Browse files

Alter perl api Makefiles for the libslurmdb to include the tests when

installing
parent 72ed21f3
No related branches found
No related tags found
No related merge requests found
......@@ -10,12 +10,23 @@ perl_sources = \
$(perl_dir)/Slurmdb.xs \
$(perl_dir)/slurmdb-perl.h \
$(perl_dir)/cluster.c
test_sources = \
$(perl_dir)/t/00-use.t \
$(perl_dir)/t/01-clusters_get.t \
$(perl_dir)/t/02-report_cluster_account_by_user.t \
$(perl_dir)/t/03-report_cluster_user_by_account.t \
$(perl_dir)/t/04-report_job_sizes_grouped_by_top_account.t \
$(perl_dir)/t/05-report_user_top_usage.t
$(perl_dir)/Makefile: $(perl_dir)/Makefile.PL
@if test "x${top_srcdir}" != "x${top_builddir}"; then \
for f in ${perl_sources}; do \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
for f in ${test_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
fi
@cd $(perl_dir) && $(perlpath) Makefile.PL $(PERL_MM_PARAMS) prefix=${prefix} INSTALL_BASE= PERL_MM_OPT=
......@@ -62,8 +73,21 @@ uninstall-local:
clean-generic:
@cd $(perl_dir); \
$(MAKE) clean; \
cd ..; \
rm -f *.so
if test "x${top_srcdir}" != "x${top_builddir}"; then \
rm -fr lib t *c *h *xs typemap classmap; \
fi; \
cd ..;
@if test "x${top_srcdir}" != "x${top_builddir}"; then \
for f in ${perl_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
for f in ${test_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
fi
distclean-generic:
@cd $(perl_dir); \
......@@ -79,6 +103,10 @@ distclean-generic:
for f in ${perl_sources}; do \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
for f in ${test_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
fi
AM_CPPFLAGS = \
......
......@@ -397,6 +397,14 @@ perl_sources = \
$(perl_dir)/slurmdb-perl.h \
$(perl_dir)/cluster.c
test_sources = \
$(perl_dir)/t/00-use.t \
$(perl_dir)/t/01-clusters_get.t \
$(perl_dir)/t/02-report_cluster_account_by_user.t \
$(perl_dir)/t/03-report_cluster_user_by_account.t \
$(perl_dir)/t/04-report_job_sizes_grouped_by_top_account.t \
$(perl_dir)/t/05-report_user_top_usage.t
AM_CPPFLAGS = \
-DVERSION=\"$(VERSION)\" \
-I$(top_srcdir) \
......@@ -595,6 +603,10 @@ $(perl_dir)/Makefile: $(perl_dir)/Makefile.PL
for f in ${perl_sources}; do \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
for f in ${test_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
fi
@cd $(perl_dir) && $(perlpath) Makefile.PL $(PERL_MM_PARAMS) prefix=${prefix} INSTALL_BASE= PERL_MM_OPT=
......@@ -638,8 +650,21 @@ uninstall-local:
clean-generic:
@cd $(perl_dir); \
$(MAKE) clean; \
cd ..; \
rm -f *.so
if test "x${top_srcdir}" != "x${top_builddir}"; then \
rm -fr lib t *c *h *xs typemap classmap; \
fi; \
cd ..;
@if test "x${top_srcdir}" != "x${top_builddir}"; then \
for f in ${perl_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
for f in ${test_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
fi
distclean-generic:
@cd $(perl_dir); \
......@@ -655,6 +680,10 @@ distclean-generic:
for f in ${perl_sources}; do \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
for f in ${test_sources}; do \
$(mkdir_p) `dirname $$f`; \
${LN_S} -f ${abs_srcdir}/$$f $$f; \
done; \
fi
# Tell versions [3.59,3.63) of GNU make to not export all variables.
......
......@@ -93,27 +93,223 @@ WriteMakefile(
# Un-comment this if you add C files to link with later:
OBJECT => '$(O_FILES)', # link all the C files too
CCFLAGS => '-g',
PM => {'Slurmdb.pm' => '$(INST_LIBDIR)/Slurmdb.pm'},
dynamic_lib => {'OTHERLDFLAGS' => $other_ld_flags},
);
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(SLURMDB_CLASSIFIED_FLAG
# 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(SLURMDB_CLASSIFIED_FLAG
SLURMDB_CLASS_BASE SLURMDB_PURGE_ARCHIVE SLURMDB_PURGE_BASE
SLURMDB_PURGE_DAYS SLURMDB_PURGE_FLAGS SLURMDB_PURGE_HOURS
SLURMDB_PURGE_MONTHS),
);
ExtUtils::Constant::WriteConstants(
NAME => 'Slurmdb',
NAMES => \@names,
C_FILE => 'const-c.inc',
XS_FILE => 'const-xs.inc',
);
);
ExtUtils::Constant::WriteConstants(
NAME => 'Slurmdb',
NAMES => \@names,
C_FILE => 'const-c.inc',
XS_FILE => 'const-xs.inc',
);
}
# Override the install routine to add our additional install dirs and
# hack DESTDIR support into old EU::MMs.
sub MY::install {
package MY;
my $self = shift;
my @code = split(/\n/, $self->SUPER::install(@_));
init_MY_globals($self);
foreach (@code) {
# Write the correct path to perllocal.pod
next if /installed into/;
# Replace all other $(INSTALL*) vars (except $(INSTALLDIRS) of course)
# with their $(DESTINSTALL*) counterparts
s/\Q$(\E(INSTALL(?!DIRS)${MACRO_RE})\Q)\E/\$(DEST$1)/g;
}
clean_MY_globals($self);
return join("\n", @code);
}
# Now override the constants routine to add our own macros.
sub MY::constants {
package MY;
my $self = shift;
my @code = split(/\n/, $self->SUPER::constants(@_));
init_MY_globals($self);
foreach my $line (@code) {
# Skip comments
next if $line =~ /^\s*\#/;
# Skip everything which isn't a var assignment.
next unless line_has_macro_def($line);
#tore the assignment string if necessary.
set_EQ_from_line($line);
# Add some "dummy" (PERL|SITE|VENDOR)PREFIX macros for later use (only if
# necessary for old EU::MMs of course)
if (line_has_macro_def($line, 'PREFIX')) {
foreach my $r (@REPOSITORIES) {
my $rprefix = "${r}PREFIX";
if (!defined(get_macro($rprefix))) {
set_macro($rprefix, macro_ref('PREFIX'));
$line .= "\n" . macro_def($rprefix);
}
}
}
# fix problem with /usr(/local) being used as a prefix
# instead of the real thing.
if ($line =~ 'INSTALL') {
$line =~ s/= \/usr\/local/= \$(PREFIX)/;
$line =~ s/= \/usr/= \$(PREFIX)/;
}
# Add DESTDIR support if necessary
if (line_has_macro_def($line, 'INSTALLDIRS')) {
if(!get_macro('DESTDIR')) {
$line .= "\n" . macro_def('DESTDIR');
}
} elsif (line_has_macro_def($line,
qr/INSTALL${MACRO_RE}/)) {
my $macro = get_macro_name_from_line($line);
if(!get_macro('DEST' . $macro,
macro_ref('DESTDIR')
. macro_ref($macro))) {
$line .= "\n"
. macro_def('DEST' . $macro,
macro_ref('DESTDIR')
. macro_ref($macro));
}
}
}
push(@code, qq{});
clean_MY_globals($self);
return join("\n", @code);
}
else {
die "Error creating constant files: $!";
package MY;
use vars qw(
@REPOSITORIES
$MY_GLOBALS_ARE_SANE
$MACRO_RE
$EQ_RE
$EQ
$SELF
);
sub line_has_macro_def {
my($line, $name) = (@_, undef);
$name = $MACRO_RE unless defined $name;
return $line =~ /^($name)${EQ_RE}/;
}
sub macro_def {
my($name, $val) = (@_, undef);
my $error_message = "Problems building report error.";
die $error_message unless defined $name;
die $error_message unless defined $EQ;
$val = $SELF->{$name} unless defined $val;
return $name . $EQ . $val;
}
sub set_EQ_from_line {
my($line) = (@_);
return if defined($EQ);
$line =~ /\S(${EQ_RE})/;
$EQ = $1;
}
# Reads the name of the macro defined on the given line.
#
# The first parameter must be the line to be expected. If the line doesn't
# contain a macro definition, weird things may happen. So check with
# line_has_macro_def() before!
sub get_macro_name_from_line {
my($line) = (@_);
$line =~ /^(${MACRO_RE})${EQ_RE}/;
return $1;
}
sub macro_ref {
my($name) = (@_);
return sprintf('$(%s)', $name);
}
# Reads the value of the given macro from the current instance of EU::MM.
#
# The first parameter must be the name of a macro.
sub get_macro {
my($name) = (@_);
return $SELF->{$name};
}
# Sets the value of the macro with the given name to the given value in the
# current instance of EU::MM. Just sets, doesn't write to the Makefile!
#
# The first parameter must be the macro's name, the second the value.
sub set_macro {
my($name, $val) = (@_);
$SELF->{$name} = $val;
}
# For some reason initializing the vars on the global scope doesn't work;
# guess its some weird Perl behaviour in combination with bless().
sub init_MY_globals {
my $self = shift;
# Keep a reference to ourselves so we don't have to feed it to the helper
# scripts.
$SELF = $self;
return if $MY_GLOBALS_ARE_SANE;
$MY_GLOBALS_ARE_SANE = 1;
@REPOSITORIES = qw(
PERL
SITE
VENDOR
);
# Macro names follow this RE -- at least stricly enough for our purposes.
$MACRO_RE = qr/[A-Z0-9_]+/;
# Normally macros are assigned via FOO = bar. But the part with the equal
# sign might differ from platform to platform. So we use this RE:
$EQ_RE = qr/\s*:?=\s*/;
# To assign or own macros we'll follow the first assignment string we find;
# normally " = ".
$EQ = undef;
}
# Unset $SELF to avoid any leaking memory.
sub clean_MY_globals {
my $self = shift;
$SELF = undef;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment