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