|
Packit |
972a07 |
use 5.005;
|
|
Packit |
972a07 |
use strict;
|
|
Packit |
972a07 |
use ExtUtils::MakeMaker;
|
|
Packit |
972a07 |
use File::Copy;
|
|
Packit |
972a07 |
use File::Spec;
|
|
Packit |
972a07 |
use Config;
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# create a typemap for Perl 5.6
|
|
Packit |
972a07 |
if ($] < 5.008) {
|
|
Packit |
972a07 |
open(TYPEMAP, ">typemap") or die "fatal: can't write typemap: $!";
|
|
Packit |
972a07 |
print TYPEMAP "const char *\t\tT_PV\n";
|
|
Packit |
972a07 |
close(TYPEMAP);
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# create a lib/ dir in order to avoid warnings in Test::Distribution
|
|
Packit |
972a07 |
mkdir "lib", 0755;
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# virtual paths given to EU::MM
|
|
Packit |
972a07 |
my %virtual_path = ( 'Syslog.pm' => '$(INST_LIBDIR)/Syslog.pm' );
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# detect when to use Win32::EvenLog
|
|
Packit |
972a07 |
my (@extra_params, @extra_prereqs);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
if ($^O =~ /Win32/) {
|
|
Packit |
972a07 |
print " * Win32::EventLog detected.\n";
|
|
Packit |
972a07 |
my $name = "PerlLog";
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
push @extra_prereqs,
|
|
Packit |
972a07 |
"Win32::EventLog" => 0,
|
|
Packit |
972a07 |
"Win32::TieRegistry" => 0,
|
|
Packit |
972a07 |
"Win32::EventLog" => 0;
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
$virtual_path{'win32/Win32.pm' } = '$(INST_LIBDIR)/Syslog/Win32.pm';
|
|
Packit |
972a07 |
$virtual_path{'win32/PerlLog.dll'} = '$(INST_ARCHAUTODIR)/PerlLog.dll';
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
push @extra_params, CCFLAGS => "$Config{ccflags} -Ifallback";
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# recreate the DLL from its uuencoded form if it's not here
|
|
Packit |
972a07 |
if (! -f File::Spec->catfile("win32", "$name.dll")) {
|
|
Packit |
972a07 |
# read the uuencoded data
|
|
Packit |
972a07 |
open(UU, '<' . File::Spec->catfile("win32", "$name\_dll.uu"))
|
|
Packit |
972a07 |
or die "fatal: Can't read file '$name\_dll.uu': $!";
|
|
Packit |
972a07 |
my $uudata = do { local $/; <UU> };
|
|
Packit |
972a07 |
close(UU);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# write the DLL
|
|
Packit |
972a07 |
open(DLL, '>' . File::Spec->catfile("win32", "$name.dll"))
|
|
Packit |
972a07 |
or die "fatal: Can't write DLL '$name.dll': $!";
|
|
Packit |
972a07 |
binmode(DLL);
|
|
Packit |
972a07 |
print DLL unpack "u", $uudata;
|
|
Packit |
972a07 |
close(DLL);
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# detect when being built in Perl core
|
|
Packit |
972a07 |
if (not grep { $_ eq 'PERL_CORE=1' } @ARGV) {
|
|
Packit |
972a07 |
push @extra_params,
|
|
Packit |
972a07 |
DEFINE => '-DUSE_PPPORT_H';
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# on pre-5.6 Perls, add warnings::compat to the prereq modules
|
|
Packit |
972a07 |
push @extra_prereqs, "warnings::compat" => "0.06" if $] < 5.006;
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# starting with Perl 5.11, "site" and "vendor" directories finally are
|
|
Packit |
972a07 |
# before "perl" (core) in @INC, thus allowing dual-life modules to be
|
|
Packit |
972a07 |
# updated without the need to overwrite the old version
|
|
Packit |
972a07 |
my $installdirs = $] < 5.011 ? "perl" : "site";
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
WriteMakefile(
|
|
Packit |
972a07 |
NAME => 'Sys::Syslog',
|
|
Packit |
972a07 |
LICENSE => 'perl',
|
|
Packit |
972a07 |
AUTHOR => 'Sebastien Aperghis-Tramoni <sebastien@aperghis.net>',
|
|
Packit |
972a07 |
VERSION_FROM => 'Syslog.pm',
|
|
Packit |
972a07 |
ABSTRACT_FROM => 'Syslog.pm',
|
|
Packit |
972a07 |
INSTALLDIRS => $installdirs,
|
|
Packit |
972a07 |
XSPROTOARG => '-noprototypes',
|
|
Packit |
972a07 |
PM => \%virtual_path,
|
|
Packit |
972a07 |
PREREQ_PM => {
|
|
Packit |
972a07 |
# run prereqs
|
|
Packit |
972a07 |
'Carp' => 0,
|
|
Packit |
972a07 |
'Fcntl' => 0,
|
|
Packit |
972a07 |
'File::Basename' => 0,
|
|
Packit |
972a07 |
'File::Spec' => 0,
|
|
Packit |
972a07 |
'POSIX' => 0,
|
|
Packit |
972a07 |
'Socket' => 0,
|
|
Packit |
972a07 |
'XSLoader' => 0,
|
|
Packit |
972a07 |
@extra_prereqs,
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# build/test prereqs
|
|
Packit |
972a07 |
'Test::More' => 0,
|
|
Packit |
972a07 |
},
|
|
Packit |
972a07 |
META_MERGE => {
|
|
Packit |
972a07 |
resources => {
|
|
Packit |
972a07 |
repository => "https://github.com/maddingue/Sys-Syslog.git",
|
|
Packit |
972a07 |
},
|
|
Packit |
972a07 |
},
|
|
Packit |
972a07 |
PL_FILES => {},
|
|
Packit |
972a07 |
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
|
Packit |
972a07 |
clean => { FILES => 'Sys-Syslog-*' },
|
|
Packit |
972a07 |
realclean => { FILES => 'lib const-c.inc const-xs.inc macros.all '
|
|
Packit |
972a07 |
.'PerlLog.h typemap *.bak *.bin *.rc win32/PerlLog_dll' },
|
|
Packit |
972a07 |
@extra_params
|
|
Packit |
972a07 |
);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# find a default value for _PATH_LOG
|
|
Packit |
972a07 |
my $_PATH_LOG;
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
if (-c "/dev/conslog" and -w _) {
|
|
Packit |
972a07 |
# SunOS 5.8 has a worldwritable /dev/conslog STREAMS log driver.
|
|
Packit |
972a07 |
# The /dev/log STREAMS log driver on this platform has permissions
|
|
Packit |
972a07 |
# and ownership `crw-r----- root sys'. /dev/conslog has more liberal
|
|
Packit |
972a07 |
# permissions.
|
|
Packit |
972a07 |
$_PATH_LOG = "/dev/conslog";
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
elsif (-S "/var/run/syslog" and -w _) {
|
|
Packit |
972a07 |
# Mac OS X puts it at a different path.
|
|
Packit |
972a07 |
$_PATH_LOG = "/var/run/syslog";
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
elsif (-p "/dev/log" and -w _) {
|
|
Packit |
972a07 |
# On HP-UX, /dev/log isn't a unix domain socket but a named pipe.
|
|
Packit |
972a07 |
$_PATH_LOG = "/dev/log";
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
elsif ((-S "/dev/log" or -c _) and -w _) {
|
|
Packit |
972a07 |
# Most unixes have a unix domain socket /dev/log.
|
|
Packit |
972a07 |
$_PATH_LOG = "/dev/log";
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
else {
|
|
Packit |
972a07 |
$_PATH_LOG = "";
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
# if possible, generate the code that handles the constants with
|
|
Packit |
972a07 |
# ExtUtils::Constant, otherwise use cached copy in fallback/
|
|
Packit |
972a07 |
if(eval {require ExtUtils::Constant; 1}) {
|
|
Packit |
972a07 |
my @levels = qw(
|
|
Packit |
972a07 |
LOG_ALERT LOG_CRIT LOG_DEBUG LOG_EMERG LOG_ERR
|
|
Packit |
972a07 |
LOG_INFO LOG_NOTICE LOG_WARNING
|
|
Packit |
972a07 |
);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
my @facilities = (
|
|
Packit |
972a07 |
# standard facilities
|
|
Packit |
972a07 |
qw(
|
|
Packit |
972a07 |
LOG_AUTH LOG_AUTHPRIV LOG_CRON LOG_DAEMON LOG_FTP LOG_KERN
|
|
Packit |
972a07 |
LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4
|
|
Packit |
972a07 |
LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_LPR LOG_MAIL LOG_NEWS
|
|
Packit |
972a07 |
LOG_SYSLOG LOG_USER LOG_UUCP
|
|
Packit |
972a07 |
),
|
|
Packit |
972a07 |
# Mac OS X specific facilities
|
|
Packit |
972a07 |
{ name => "LOG_INSTALL", type => "IV", default => [ "IV", "LOG_USER" ] },
|
|
Packit |
972a07 |
{ name => "LOG_LAUNCHD", type => "IV", default => [ "IV", "LOG_DAEMON"] },
|
|
Packit |
972a07 |
{ name => "LOG_NETINFO", type => "IV", default => [ "IV", "LOG_DAEMON"] },
|
|
Packit |
972a07 |
{ name => "LOG_RAS", type => "IV", default => [ "IV", "LOG_AUTH" ] },
|
|
Packit |
972a07 |
{ name => "LOG_REMOTEAUTH", type => "IV", default => [ "IV", "LOG_AUTH" ] },
|
|
Packit |
972a07 |
# modern BSD specific facilities
|
|
Packit |
972a07 |
{ name => "LOG_CONSOLE", type => "IV", default => [ "IV", "LOG_USER" ] },
|
|
Packit |
972a07 |
{ name => "LOG_NTP", type => "IV", default => [ "IV", "LOG_DAEMON"] },
|
|
Packit |
972a07 |
{ name => "LOG_SECURITY", type => "IV", default => [ "IV", "LOG_AUTH" ] },
|
|
Packit |
972a07 |
# IRIX specific facilities
|
|
Packit |
972a07 |
{ name => "LOG_AUDIT", type => "IV", default => [ "IV", "LOG_AUTH" ] },
|
|
Packit |
972a07 |
{ name => "LOG_LFMT", type => "IV", default => [ "IV", "LOG_USER" ] },
|
|
Packit |
972a07 |
);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
my @options = qw(
|
|
Packit |
972a07 |
LOG_CONS LOG_PID LOG_NDELAY LOG_NOWAIT LOG_ODELAY LOG_PERROR
|
|
Packit |
972a07 |
);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
my @others_macros = (
|
|
Packit |
972a07 |
qw(LOG_FACMASK),
|
|
Packit |
972a07 |
{ name => "_PATH_LOG", type => "PV", default => [ "PV", qq("$_PATH_LOG") ] },
|
|
Packit |
972a07 |
{ name => "LOG_PRIMASK", type => "IV", default => [ "IV", 7] },
|
|
Packit |
972a07 |
{ name => "LOG_NFACILITIES", type => "IV", default => [ "IV", scalar @facilities] },
|
|
Packit |
972a07 |
);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
ExtUtils::Constant::WriteConstants(
|
|
Packit |
972a07 |
NAME => 'Sys::Syslog',
|
|
Packit |
972a07 |
NAMES => [ @levels, @facilities, @options, @others_macros ],
|
|
Packit |
972a07 |
($] > 5.009002 ? (PROXYSUBS => 1) : ()),
|
|
Packit |
972a07 |
);
|
|
Packit |
972a07 |
|
|
Packit |
972a07 |
my @names = map { ref $_ ? $_->{name} : $_ } @levels, @facilities, @options;
|
|
Packit |
972a07 |
open(MACROS, '>macros.all') or warn "warning: Can't write 'macros.all': $!\n";
|
|
Packit |
972a07 |
print MACROS join $/, @names;
|
|
Packit |
972a07 |
close(MACROS);
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
else {
|
|
Packit |
972a07 |
foreach my $file ('const-c.inc', 'const-xs.inc') {
|
|
Packit |
972a07 |
my $fallback = File::Spec->catfile('fallback', $file);
|
|
Packit |
972a07 |
copy($fallback, $file) or die "fatal: Can't copy $fallback to $file: $!";
|
|
Packit |
972a07 |
}
|
|
Packit |
972a07 |
}
|