3 use ExtUtils::MakeMaker;
8 # create a typemap for Perl 5.6
10 open(TYPEMAP, ">typemap") or die "fatal: can't write typemap: $!";
11 print TYPEMAP "const char *\t\tT_PV\n";
15 # create a lib/ dir in order to avoid warnings in Test::Distribution
18 # virtual paths given to EU::MM
19 my %virtual_path = ( 'Syslog.pm' => '$(INST_LIBDIR)/Syslog.pm' );
21 # detect when to use Win32::EvenLog
22 my (@extra_params, @extra_prereqs);
25 print " * Win32::EventLog detected.\n";
29 "Win32::EventLog" => 0,
30 "Win32::TieRegistry" => 0,
31 "Win32::EventLog" => 0;
33 $virtual_path{'win32/Win32.pm' } = '$(INST_LIBDIR)/Syslog/Win32.pm';
34 $virtual_path{'win32/PerlLog.dll'} = '$(INST_ARCHAUTODIR)/PerlLog.dll';
36 push @extra_params, CCFLAGS => "-Ifallback";
38 # recreate the DLL from its uuencoded form if it's not here
39 if (! -f File::Spec->catfile("win32", "$name.dll")) {
40 # read the uuencoded data
41 open(UU, '<' . File::Spec->catfile("win32", "$name\_dll.uu"))
42 or die "fatal: Can't read file '$name\_dll.uu': $!";
43 my $uudata = do { local $/; <UU> };
47 open(DLL, '>' . File::Spec->catfile("win32", "$name.dll"))
48 or die "fatal: Can't write DLL '$name.dll': $!";
50 print DLL unpack "u", $uudata;
55 # detect when being built in Perl core
56 if (not grep { $_ eq 'PERL_CORE=1' } @ARGV) {
58 DEFINE => '-DUSE_PPPORT_H';
61 # on pre-5.6 Perls, add warnings::compat to the prereq modules
62 push @extra_prereqs, "warnings::compat" => "0.06" if $] < 5.006;
64 # starting with Perl 5.11, "site" and "vendor" directories finally are
65 # before "perl" (core) in @INC, thus allowing dual-life modules to be
66 # updated without the need to overwrite the old version
67 my $installdirs = $] < 5.011 ? "perl" : "site";
70 NAME => 'Sys::Syslog',
72 AUTHOR => 'Sebastien Aperghis-Tramoni <sebastien@aperghis.net>',
73 VERSION_FROM => 'Syslog.pm',
74 ABSTRACT_FROM => 'Syslog.pm',
75 INSTALLDIRS => $installdirs,
76 XSPROTOARG => '-noprototypes',
82 'File::Basename' => 0,
94 repository => "https://github.com/maddingue/Sys-Syslog.git",
98 dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
99 clean => { FILES => 'Sys-Syslog-*' },
100 realclean => { FILES => 'lib const-c.inc const-xs.inc macros.all '
101 .'PerlLog.h typemap *.bak *.bin *.rc win32/PerlLog_dll' },
106 # find a default value for _PATH_LOG
109 if (-c "/dev/conslog" and -w _) {
110 # SunOS 5.8 has a worldwritable /dev/conslog STREAMS log driver.
111 # The /dev/log STREAMS log driver on this platform has permissions
112 # and ownership `crw-r----- root sys'. /dev/conslog has more liberal
114 $_PATH_LOG = "/dev/conslog";
116 elsif (-S "/var/run/syslog" and -w _) {
117 # Mac OS X puts it at a different path.
118 $_PATH_LOG = "/var/run/syslog";
120 elsif (-p "/dev/log" and -w _) {
121 # On HP-UX, /dev/log isn't a unix domain socket but a named pipe.
122 $_PATH_LOG = "/dev/log";
124 elsif ((-S "/dev/log" or -c _) and -w _) {
125 # Most unixes have a unix domain socket /dev/log.
126 $_PATH_LOG = "/dev/log";
133 # if possible, generate the code that handles the constants with
134 # ExtUtils::Constant, otherwise use cached copy in fallback/
135 if(eval {require ExtUtils::Constant; 1}) {
137 LOG_ALERT LOG_CRIT LOG_DEBUG LOG_EMERG LOG_ERR
138 LOG_INFO LOG_NOTICE LOG_WARNING
142 # standard facilities
144 LOG_AUTH LOG_AUTHPRIV LOG_CRON LOG_DAEMON LOG_FTP LOG_KERN
145 LOG_LOCAL0 LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4
146 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_LPR LOG_MAIL LOG_NEWS
147 LOG_SYSLOG LOG_USER LOG_UUCP
149 # Mac OS X specific facilities
150 { name => "LOG_INSTALL", type => "IV", default => [ "IV", "LOG_USER" ] },
151 { name => "LOG_LAUNCHD", type => "IV", default => [ "IV", "LOG_DAEMON"] },
152 { name => "LOG_NETINFO", type => "IV", default => [ "IV", "LOG_DAEMON"] },
153 { name => "LOG_RAS", type => "IV", default => [ "IV", "LOG_AUTH" ] },
154 { name => "LOG_REMOTEAUTH", type => "IV", default => [ "IV", "LOG_AUTH" ] },
155 # modern BSD specific facilities
156 { name => "LOG_CONSOLE", type => "IV", default => [ "IV", "LOG_USER" ] },
157 { name => "LOG_NTP", type => "IV", default => [ "IV", "LOG_DAEMON"] },
158 { name => "LOG_SECURITY", type => "IV", default => [ "IV", "LOG_AUTH" ] },
159 # IRIX specific facilities
160 { name => "LOG_AUDIT", type => "IV", default => [ "IV", "LOG_AUTH" ] },
161 { name => "LOG_LFMT", type => "IV", default => [ "IV", "LOG_USER" ] },
165 LOG_CONS LOG_PID LOG_NDELAY LOG_NOWAIT LOG_ODELAY LOG_PERROR
168 my @others_macros = (
170 { name => "_PATH_LOG", type => "PV", default => [ "PV", qq("$_PATH_LOG") ] },
171 { name => "LOG_PRIMASK", type => "IV", default => [ "IV", 7] },
172 { name => "LOG_NFACILITIES", type => "IV", default => [ "IV", scalar @facilities] },
175 ExtUtils::Constant::WriteConstants(
176 NAME => 'Sys::Syslog',
177 NAMES => [ @levels, @facilities, @options, @others_macros ],
178 ($] > 5.009002 ? (PROXYSUBS => 1) : ()),
181 my @names = map { ref $_ ? $_->{name} : $_ } @levels, @facilities, @options;
182 open(MACROS, '>macros.all') or warn "warning: Can't write 'macros.all': $!\n";
183 print MACROS join $/, @names;
187 foreach my $file ('const-c.inc', 'const-xs.inc') {
188 my $fallback = File::Spec->catfile('fallback', $file);
189 copy($fallback, $file) or die "fatal: Can't copy $fallback to $file: $!";