3 use ExtUtils::MakeMaker;
4 eval 'use ExtUtils::MakeMaker::Coverage';
11 # create a typemap for Perl 5.6
13 open(TYPEMAP, ">typemap") or die "fatal: can't write typemap: $!";
14 print TYPEMAP "const char *\t\tT_PV\n";
18 # create a lib/ dir in order to avoid warnings in Test::Distribution
21 # virtual paths given to EU::MM
22 my %virtual_path = ( 'Syslog.pm' => '$(INST_LIBDIR)/Syslog.pm' );
24 # detect when to use Win32::EvenLog
25 my (@extra_params, @extra_prereqs);
26 my $use_eventlog = eval "use Win32::EventLog; 1";
29 print " * Win32::EventLog detected.\n";
33 Win32 => 0, "Win32::TieRegistry" => 0, "Win32::EventLog" => 0;
35 $virtual_path{'win32/Win32.pm' } = '$(INST_LIBDIR)/Syslog/Win32.pm';
36 $virtual_path{'win32/PerlLog.dll'} = '$(INST_ARCHAUTODIR)/PerlLog.dll';
38 push @extra_params, CCFLAGS => "-Ifallback";
40 # recreate the DLL from its uuencoded form if it's not here
41 if (! -f File::Spec->catfile("win32", "$name.dll")) {
42 # read the uuencoded data
43 open(UU, '<' . File::Spec->catfile("win32", "$name\_dll.uu"))
44 or die "fatal: Can't read file '$name\_dll.uu': $!";
45 my $uudata = do { local $/; <UU> };
49 open(DLL, '>' . File::Spec->catfile("win32", "$name.dll"))
50 or die "fatal: Can't write DLL '$name.dll': $!";
52 print DLL unpack "u", $uudata;
56 elsif ($^O =~ /Win32/) {
58 *** You're running on a Win32 system, but you lack the Win32::EventLog\a
59 *** module, part of the libwin32 distribution. Although Sys::Syslog can
60 *** be used without Win32::EventLog, it won't be very useful except for
61 *** sending remote syslog messages. If you want to log messages on the
62 *** local host as well, please install libwin32 then Sys::Syslog again.
66 # detect when being built in Perl core
67 if (grep { $_ eq 'PERL_CORE=1' } @ARGV) {
69 MAN3PODS => {}; # Pods will be built by installman.
73 DEFINE => '-DUSE_PPPORT_H';
76 # on pre-5.6 Perls, add warnings::compat to the prereq modules
77 push @extra_prereqs, "warnings::compat" if $] < 5.006;
80 NAME => 'Sys::Syslog',
82 AUTHOR => 'Sebastien Aperghis-Tramoni <sebastien@aperghis.net>',
83 VERSION_FROM => 'Syslog.pm',
84 ABSTRACT_FROM => 'Syslog.pm',
85 INSTALLDIRS => 'perl',
86 XSPROTOARG => '-noprototypes',
92 'File::Basename' => 0,
103 dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
104 clean => { FILES => 'Sys-Syslog-*' },
105 realclean => { FILES => 'lib const-c.inc const-xs.inc macros.all '
106 .'PerlLog.h typemap *.bak *.bin *.rc win32/PerlLog_dll' },
112 # find a default value for _PATH_LOG
115 if (-c "/dev/conslog" and -w _) {
116 # SunOS 5.8 has a worldwritable /dev/conslog STREAMS log driver.
117 # The /dev/log STREAMS log driver on this platform has permissions
118 # and ownership `crw-r----- root sys'. /dev/conslog has more liberal
120 $_PATH_LOG = "/dev/conslog";
122 elsif (-S "/var/run/syslog" and -w _) {
123 # Mac OS X puts it at a different path.
124 $_PATH_LOG = "/var/run/syslog";
126 elsif (-p "/dev/log" and -w _) {
127 # On HP-UX, /dev/log isn't a unix domain socket but a named pipe.
128 $_PATH_LOG = "/dev/log";
130 elsif ((-S "/dev/log" or -c _) and -w _) {
131 # Most unixes have a unix domain socket /dev/log.
132 $_PATH_LOG = "/dev/log";
139 # if possible, generate the code that handles the constants with
140 # ExtUtils::Constant, otherwise use cached copy in fallback/
141 if(eval {require ExtUtils::Constant; 1}) {
143 LOG_ALERT LOG_CRIT LOG_DEBUG LOG_EMERG LOG_ERR
144 LOG_INFO LOG_NOTICE LOG_WARNING
148 # standard facilities
150 LOG_AUTH LOG_AUTHPRIV LOG_CRON LOG_DAEMON LOG_FTP LOG_KERN
151 LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4
152 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_LPR LOG_MAIL LOG_NEWS
153 LOG_SYSLOG LOG_USER LOG_UUCP
155 # Mac OS X specific facilities
156 { name => "LOG_INSTALL", type => "IV", default => [ "IV", "LOG_USER" ] },
157 { name => "LOG_LAUNCHD", type => "IV", default => [ "IV", "LOG_DAEMON"] },
158 { name => "LOG_NETINFO", type => "IV", default => [ "IV", "LOG_DAEMON"] },
159 { name => "LOG_RAS", type => "IV", default => [ "IV", "LOG_AUTH" ] },
160 { name => "LOG_REMOTEAUTH", type => "IV", default => [ "IV", "LOG_AUTH" ] },
161 # modern BSD specific facilities
162 { name => "LOG_CONSOLE", type => "IV", default => [ "IV", "LOG_USER" ] },
163 { name => "LOG_NTP", type => "IV", default => [ "IV", "LOG_DAEMON"] },
164 { name => "LOG_SECURITY", type => "IV", default => [ "IV", "LOG_AUTH" ] },
165 # IRIX specific facilities
166 { name => "LOG_AUDIT", type => "IV", default => [ "IV", "LOG_AUTH" ] },
167 { name => "LOG_LFMT", type => "IV", default => [ "IV", "LOG_USER" ] },
171 LOG_CONS LOG_PID LOG_NDELAY LOG_NOWAIT LOG_ODELAY LOG_PERROR
174 my @others_macros = (
176 { name => "_PATH_LOG", type => "PV", default => [ "PV", qq("$_PATH_LOG") ] },
177 { name => "LOG_PRIMASK", type => "IV", default => [ "IV", 7] },
178 { name => "LOG_NFACILITIES", type => "IV", default => [ "IV", scalar @facilities] },
181 ExtUtils::Constant::WriteConstants(
182 NAME => 'Sys::Syslog',
183 NAMES => [ @levels, @facilities, @options, @others_macros ],
184 ($] > 5.009002 ? (PROXYSUBS => 1) : ()),
187 my @names = map { ref $_ ? $_->{name} : $_ } @levels, @facilities, @options;
188 open(MACROS, '>macros.all') or warn "warning: Can't write 'macros.all': $!\n";
189 print MACROS join $/, @names;
193 foreach my $file ('const-c.inc', 'const-xs.inc') {
194 my $fallback = File::Spec->catfile('fallback', $file);
195 copy($fallback, $file) or die "fatal: Can't copy $fallback to $file: $!";