summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/BSDPAN/BSDPAN.pm
blob: 33e786c00430124f2024fc45eeeb5cabac487b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42)
# <tobez@tobez.org> wrote this file.  As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.   Anton Berezin
# ----------------------------------------------------------------------------
#
# $FreeBSD$
#
package BSDPAN;
#
# The pod documentation for this module is at the end of this file.
#

my $bsdpan_path;	# Directory pathname of BSDPAN itself

BEGIN {
	# Find this module's own path.  Do this before anything else
	# happens, even before the rest of the module compiles.  Do this
	# by looking into undocumented entries in the main (::) symbol
	# table.
	for (keys %::) {
		$bsdpan_path = $1 if /^_<(.*\/|)BSDPAN.pm$/;
	}
	# deduce the BSDPAN's directory pathname
	$bsdpan_path = '.' if $bsdpan_path eq '';
	$bsdpan_path =~ tr|/|/|s;
	$bsdpan_path =~ s|/$||;
}

sub path {
	return $bsdpan_path;
}

sub perl_version {
	require Config;
	return $Config::Config{version};
}

sub perl_ver {
	require Config;
	# pre-5.6.1 perls
	return $Config::Config{apiversion} if exists $Config::Config{apiversion};
	# post-5.6.1 perls
	return $Config::Config{version};
}

sub perl_arch {
	require Config;
	# pre-5.6.1 perls
	return $Config::Config{archname} if exists $Config::Config{apiversion};
	# post-5.6.1 perls
	return 'mach';
}

sub builds_port {
	# Are we building a p5 port at the moment?
	# XXX There must be a more reliable way to check this.
	if (defined $ENV{ARCH}		||
	    defined $ENV{OPSYS}		||
	    defined $ENV{OSREL}		||
	    defined $ENV{OSVERSION}	||
	    defined $ENV{PORTOBJFORMAT}	||
	    defined $ENV{SYSTEMVERSION}) {
		return 1;
	} else {
		return 0;
	}
}

sub builds_standalone {
	return !BSDPAN->builds_port;
}

1;
__END__
=head1 NAME

BSDPAN - Symbiogenetic tool for Perl & BSD

=head1 SYNOPSIS

  use BSDPAN;
  $path = BSDPAN->path;
  $ver = BSDPAN->perl_version;
  $ver = BSDPAN->perl_ver;
  $arch = BSDPAN->perl_arch;
  $port = BSDPAN->builds_port;
  $noport = BSDPAN->builds_standalone;

=head1 DESCRIPTION

BSDPAN is the collection of modules that provides tighter than ever
integration of Perl into BSD Unix.

Currently, BSDPAN does the following:

=over 4

=item o makes p5- FreeBSD ports PREFIX-clean;

=item o registers Perl modules with FreeBSD package database.

=back

BSDPAN achieves this by overriding certain functionality of the core
Perl modules, ExtUtils::MM_Unix, and ExtUtils::Packlist.

BSDPAN B<module> itself just provides useful helper functions for the
rest of the modules in BSDPAN collection.

=head1 AUTHOR

Anton Berezin, tobez@tobez.org

=head1 SEE ALSO

perl(1), ExtUtils::MakeMaker(3), L<BSDPAN::Override(3)>,
L<BSDPAN::ExtUtils::MM_Unix(3)>, L<BSDPAN::ExtUtils::Packlist(3)>.

=cut
OpenPOWER on IntegriCloud