require 5.005; ############################################################################## # The following variables are recognized on the command line. They are useful # for building packages (RPM, deb, ...) or installing SpamAssassin in a # different location than the PREFIX Perl was built with. # # --- %YAML:1.0 # PREFIX: # description: > # Sets the prefix below which SpamAssassin is built. Please note the # exceptions for SYSCONFDIR. # defaults: # - The prefix Perl was built with (call 'perl -V:prefix' to see the # value). Normally something like '/usr' or '/usr/local'. # samples: # - This will install the spamassassin apps in /foo/bin, the libs in # /foo/lib/perl5, the shared stuff in /foo/share/spamassassin and make # SpamAssassin look for config files in /foo/etc/mail/spamassassin: # # perl Makefile.PL PREFIX=/foo # # scope: build-time # INST_PREFIX: # description: > # Sets the prefix below which SpamAssassin is installed; useful for # creating packages or building chroot jails. 'make install' will put # the files below PREFIX but the paths inside the apps will refer to # INST_PREFIX. Please note the exceptions for INST_SYSCONFDIR. # defaults: # - The value of PREFIX. # samples: # - The following installs the SpamAssassin stuff below /tmp/build/sa # but the apps will expect themselves to be in /usr when they're # used (so the files have to be relocated later): # # perl Makefile.PL PREFIX=/tmp/build/sa INST_PREFIX=/usr # # scope: run-time # INST_SITELIB: # description: > # Sets the full path to where the SpamAssassin libs are put. # defaults: # - Whatever Perl was compiled with. Call 'perl -V:sitelib' to see the # exact value. Normally something like '/usr/lib/perl5/site_perl/5.6.1'. # samples: # - Install SpamAssassin in '/usr/local' and force the libs to be put # there, too, even though Perl is installed in '/usr' (don't forget # to set PERL5LIB before you run spamassassin): # # perl Makefile.PL INST_PREFIX=/usr/local # INST_SITELIB=/usr/local/lib/perl5/site_perl/5.6.1 # # scope: run-time # SYSCONFDIR: # description: > # Sets the base dir for the config files (and where the sample local.cf # is created). See also LOCAL_RULES_DIR. # defaults: # - /etc if PREFIX is either '/usr' or '/usr/local'. # - Else PREFIX/etc. # samples: # - This will (on Windows) install below 'C:\Program Files\SA' but look # for the config files in 'C:\Program Files\Shared Files\SA' # # perl Makefile.PL PREFIX="C:/Program Files/SA" # SYSCONFDIR="C:/Program Files/Shared Files/SA" # # - To put the apps and libs below ~/.sa-bin but the config below # ~/.sa-etc try the following: # # perl Makefile.PL PREFIX=$HOME/.sa-bin SYSCONFDIR=$HOME/.sa-etc # # - And the following installs SpamAssassin in '/usr/local' and forces the # config files to be below '/usr/local', too: # # perl Makefile.PL PREFIX=/usr/local SYSCONFDIR=/usr/local/etc # # scope: build-time # INST_SYSCONFDIR: # description: > # Sets the base dir below which the config files are sought when any # SpamAssassin app runs. Cf. INST_PREFIX. # defaults: # - The value of SYSCONFDIR if that variable was set. # - Else '/etc' if INST_PREFIX is either '/usr' or '/usr/local'. # - Else INST_PREFIX/etc. # samples: # - Install SpamAssassin below '/usr/lib/mail-root/usr/local' and run it # below the chroot'ed '/usr/local' later. Make it also look for its # config in '/usr/local/etc': # # perl Makefile.PL PREFIX=/usr/lib/mail-root/usr/local # INST_PREFIX=/usr/local INST_SYSCONFDIR=/usr/local/etc # # scope: run-time # DEF_RULES_DIR: # description: > # Changes the full path to where SpamAssassin will later look for its # rules. Attention: All files in this dir will be purged! # defaults: # - INST_PREFIX/share/spamassassin # samples: # - Install the rules in '/tmp/sa-rules' (for whatever reason): # # perl Makefile.PL DEF_RULES_DIR=/tmp/sa-rules # # scope: run-time # PKG_DEF_RULES_DIR: # description: > # Sets the full path to the dir where the rules are copied to on 'make # install'. # defaults: # - The value of DEF_RULES_DIR if that variable is set. # - Else PREFIX/share/spamassassin # samples: # - I think you got the point with builddir != installdir. # scope: build-time # LOCAL_RULES_DIR: # description: > # Changes the full path to where SpamAssassin will look for its config # files later on. Makes (INST_)SYSCONFDIR obsolete. # defaults: # - INST_SYSCONFDIR/mail/spamassassin # samples: # - If you'd like to have the config files directly in '/etc/spamassassin' # try this: # # perl Makefile.PL LOCAL_RULES_DIR=/etc/spamassassin # # - This does effectively the same but might give some errors: # # perl Makefile.PL SYSCONFDIR=/dev/null # LOCAL_RULES_DIR=/etc/spamassassin # # Stupid example, eh? # scope: run-time # PKG_LOCAL_RULES_DIR: # description: > # This is the same for LOCAL_RULES_DIR what PKG_DEF_RULES_DIR is for # DEF_RULES_DIR. # defaults: # - The value of LOCAL_RULES_DIR if that variable is set. # - Else SYSCONFDIR/mail/spamassassin # samples: # - None. # scope: build-time # ENABLE_SSL: # description: > # Set to "yes" if you want the ability to use encrypted connections # between spamc and spamd. # defaults: # - "no". # samples: # - Obvious: # # perl Makefile.PL ENABLE_SSL=yes # # scope: build-time # RUN_RAZOR_TESTS: # description: > # Set to 'yes' or 'no' to disable the prompt. # defaults: # - Prompt if the Razor2 libs are available and the input isn't coming # from the null device. # - Else 'no'. # samples: # - Don't run Razor tests on 'make test': # # perl Makefile.PL RUN_RAZOR_TESTS=no # # - Has the same effects but suppresses all other prompts, too: # # perl Makefile.PL < /dev/null # # scope: Makefile-creation-time # CONTACT_ADDRESS: # description: > # The contact address which appears in the spam reports; should be set to # some internal mail address or url the confused user can contact when # he's got a mail marked as spam. # defaults: # - Prompt for an input if the input isn't coming from the null device. # - The string "the administrator of that system" # samples: # - Set the contact address and suppress all other prompts: # # perl Makefile.PL CONTACT_ADDRESS="helpdesk@example.com" < /dev/null # # scope: Makefile-creation-time # ... ############################################################################## use strict; use Config; use ExtUtils::MakeMaker; $ExtUtils::MakeMaker::Recognized_Att_Keys{'INST_PREFIX'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'SYSCONFDIR'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'INST_SYSCONFDIR'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'DEF_RULES_DIR'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'PKG_DEF_RULES_DIR'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'LOCAL_RULES_DIR'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'PKG_LOCAL_RULES_DIR'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'INST_SITELIB'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'RUN_RAZOR2_TESTS'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'ENABLE_SSL'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'CONTACT_ADDRESS'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'PERL_BIN'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'PERL_WARN'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'PERL_TAINT'} = 1; $ExtUtils::MakeMaker::Recognized_Att_Keys{'PERL_VERSION'} = 1; use constant RUNNING_ON_WINDOWS => ($^O =~ /^(?:mswin|dos|os2)/oi); # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. my $mm_version = $ExtUtils::MakeMaker::VERSION; # Gather the rules files in the range 00-69; we do this in perl because it's more portable my @rulesfiles = map { s,^rules/,,; $_ } (); my $rulesfiles = join(' ', (grep { /^[0-6][0-9]_/ } @rulesfiles), qw(user_prefs.template triplets.txt languages)); # Only build spamd and spamc on non-Windows platforms my @SPAMD_EXE_FILES = (); if (!RUNNING_ON_WINDOWS) { @SPAMD_EXE_FILES = ('spamd/spamc$(EXE_EXT)', 'spamd/spamd'); } my %makefile = ( 'NAME' => 'Mail::SpamAssassin', 'VERSION_FROM' => 'lib/Mail/SpamAssassin.pm', # finds $VERSION 'EXE_FILES' => [ 'spamassassin', 'sa-learn', @SPAMD_EXE_FILES ], 'MAN1PODS' => { 'spamassassin' => '$(INST_MAN1DIR)/spamassassin.$(MAN1EXT)', 'sa-learn' => '$(INST_MAN1DIR)/sa-learn.$(MAN1EXT)', 'spamd/spamc.pod' => '$(INST_MAN1DIR)/spamc.$(MAN1EXT)', 'spamd/spamd' => '$(INST_MAN1DIR)/spamd.$(MAN1EXT)', }, 'PL_FILES' => { }, 'PMLIBDIRS' => [ 'lib' ], 'PM_FILTER' => '$(PERL) build/preprocessor -Mconditional $(FIXBYTES) -Mvars -DVERSION="$(VERSION)" -DPREFIX="$(INST_PREFIX)"', 'macro' => { RULES => $rulesfiles, }, # be quite explicit about this; afaik CPAN.pm is sensible using this 'PREREQ_PM' => { 'ExtUtils::MakeMaker' => 5.45 *0, # we have compatibility code in build/preprocessor.pm 'File::Spec' => 0.8, # older versions lack some routines we need 'File::Copy' => 2.02, # this version is shipped with 5.005_03, the oldest version known to work 'Pod::Usage' => 1.10, # all versions prior to this do seem to be buggy 'HTML::Parser' => 3.0, # the HTML code is based on this parser 'Text::Wrap' => 98.112902, # this version is shipped with 5.005_03, the oldest version known to work 'Sys::Hostname' => 0, 'Time::Local' => 0, 'Errno' => 0, }, 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', DIST_DEFAULT => 'tardist' }, 'clean' => { FILES => 'pod2htm* spamassassin sa-learn '. 'spamd/spamc$(EXE_EXT) spamd/libspamc.so spamd/spamd doc '. 'spamd/libsslspamc.so '. 'spamd/binaries.mk spamd/config.h spamd/config.status '. 'spamd/config.cache spamd/config.log '. 'spamd/autom4te.cache qmail/qmail-spamc'. 't/do_razor2 t/log' }, 'AUTHOR' => 'Justin Mason ', 'ABSTRACT' => 'identify spam mail using text analysis', # We have only this Makefile.PL and this option keeps MakeMaker from # asking all questions twice after a 'make dist*'. 'NORECURS' => 1, ); # MakeMaker prior to 5.46 doesn't support PM_FILTER, so we have to # implement it ourselves. Also bear in mind that MakeMaker (5.45) from # Perl 5.6.1 supports that option while the one from 5.6.0 doesn't; they # do have the same version though! See bug 1652. my $pm_filter = $mm_version > 5.45 || ($mm_version == 5.45 && $] > 5.006); if(!$pm_filter) { warn <. Hint: Perl 5.6.1 and later ship good versions of ExtUtils::MakeMaker by default. If anything breaks while building Mail::SpamAssassin, please file a bug at . *********************************************************************** ITSALLSOSTUPID $makefile{SKIP} = [ 'pm_to_blib' ]; $makefile{macro}{PM_FILTER} = $makefile{PM_FILTER}; delete $makefile{PM_FILTER}; } # All the $(*MAN1*) stuff is empty/zero if Perl was Configured with -Dman1dir=none unless($Config{installman1dir}) { delete $makefile{MAN1PODS}; } ####################################################################### # what a PITA. we can't get at MakeMaker's parsed args. do it ourselves, # again.... my $contactaddr; my $runrazor; for my $arg (@ARGV) { if ($arg =~ /^CONTACT_ADDRESS=(.*)/) { $contactaddr = $1; } elsif ($arg =~ /^RUN_RAZOR2?_TESTS?=(.)/) { $runrazor = $1; } } if (!defined $contactaddr) { $contactaddr = prompt( "What email address or URL should be used in the suspected-spam report\n". "text for users who want more information on your filter installation?\n". "(In particular, ISPs should change this to a local Postmaster contact)\n". "default text:", "the administrator of that system" ); print "\n"; } if (!defined $runrazor) { $runrazor = eval { require Razor2::Client::Agent }; if ($runrazor) { $runrazor = prompt( "Run Razor v2 tests (these may fail due to network problems)? (y/n)", 'n' ); print "\n"; } } $runrazor = substr($runrazor, 0, 1); $runrazor =~ tr/y1/0/c; if ($runrazor) { open(FLAG, "> t/do_razor2"); close(FLAG); } else { unlink("t/do_razor2"); } # Now dump the Makefile WriteMakefile(%makefile); ####################################################################### package MY; sub MY::libscan { my($self,$path) = @_; return '' if ($path =~ /windows_install/ || $path =~ /\.(orig|diff|patch|bak|backup|my)$/i); return $path; } sub MY::install { my $self = shift; my $inherited = $self->SUPER::install (@_); $inherited =~ s/^(install :: .*)$/$1 inst_cfs/gm; $inherited; } sub MY::postamble { # import some C-linkage stuff from %Config. We can't seem to # do this with MakeMaker without it trying to build the perl # modules as .so's :( my $self = shift; my $prefix = $self->{PREFIX} || ''; my $instprefix = $self->{INST_PREFIX} || $prefix; my $is_sys_build = ($prefix =~ m{^(/usr(/local)?/?)?$}); my $is_sys_inst = ($instprefix =~ m{^(/usr(/local)?/?)?$}); my $sysconfdir = $self->{SYSCONFDIR} || ($is_sys_build ? '' : '$(PREFIX)') . '/etc'; my $instsysconfdir = $self->{INST_SYSCONFDIR} || $self->{SYSCONFDIR} || ($is_sys_inst ? '' : '$(INST_PREFIX)') . '/etc'; my $pkgdefrulesdir = $self->{PKG_DEF_RULES_DIR} || $self->{DEF_RULES_DIR} || '$(PREFIX)/share/spamassassin'; my $defrulesdir = $self->{DEF_RULES_DIR} || '$(INST_PREFIX)/share/spamassassin'; my $pkglocalrulesdir = $self->{PKG_LOCAL_RULES_DIR} || $self->{LOCAL_RULES_DIR} || '$(SYSCONFDIR)/mail/spamassassin'; my $localrulesdir = $self->{LOCAL_RULES_DIR} || '$(INST_SYSCONFDIR)/mail/spamassassin'; my $instsitelib = $self->{INST_SITELIB} || '$(INSTALLSITELIB)'; my $enablessl = $self->{ENABLE_SSL} || 'no'; my $perl_bin = $self->{PERL_BIN} || 'this'; my $perl_warn = $self->{PERL_WARN} || 'auto'; my $perl_taint = $self->{PERL_TAINT} || 'auto'; my $perl_version = $self->{PERL_VERSION} || 'this'; my $gotpods = keys(%{$self->{MAN1PODS}}) || keys(%{$self->{MAN3PODS}}) || keys(%{$self->{EXTRAPODS}}) || 0; qq( #PREFIX = $prefix # just for reference INST_PREFIX = $instprefix SYSCONFDIR = $sysconfdir INST_SYSCONFDIR = $instsysconfdir PKG_DEF_RULES_DIR = $pkgdefrulesdir DEF_RULES_DIR = $defrulesdir PKG_LOCAL_RULES_DIR = $pkglocalrulesdir LOCAL_RULES_DIR = $localrulesdir INST_SITELIB = $instsitelib ENABLE_SSL = $enablessl CONTACT_ADDRESS = $contactaddr PERL_BIN = $perl_bin PERL_WARN = $perl_warn PERL_TAINT = $perl_taint PERL_VERSION = $perl_version ) . q# FIXVARS = -Mvars \ -DVERSION="$(VERSION)" \ -DPREFIX="$(INST_PREFIX)" \ -DDEF_RULES_DIR="$(DEF_RULES_DIR)" \ -DLOCAL_RULES_DIR="$(LOCAL_RULES_DIR)" \ -DINSTALLSITELIB="$(INST_SITELIB)" \ -DCONTACT_ADDRESS="$(CONTACT_ADDRESS)" FIXBYTES = -Mbytes \ -DPERL_VERSION="$(PERL_VERSION)" FIXBANG = -Msharpbang \ -DPERL_BIN="$(PERL_BIN)" \ -DPERL_WARN="$(PERL_WARN)" SPAMC_SOURCES = spamd/spamc.c qmail/qmail-spamc.c spamd/libspamc.c spamd/utils.c # . (!$pm_filter ? q# pm_to_blib: $(TO_INST_PM) @ $(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \ "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -Ibuild \ -MExtUtils::Install -Mpreprocessor \ -e "ExtUtils::Install::Post545::pm_to_blib({qw{$(PM_TO_BLIB)}}, '$(INST_LIB)/auto', '$(PM_FILTER)')"# : '') . q# spamassassin: spamassassin.raw $(PERL) build/preprocessor $(FIXBYTES) $(FIXVARS) $(FIXBANG) -i$? -o$@ $(CHMOD) $(PERM_RWX) $@ sa-learn: sa-learn.raw $(PERL) build/preprocessor $(FIXBYTES) $(FIXVARS) $(FIXBANG) -i$? -o$@ $(CHMOD) $(PERM_RWX) $@ spamd/spamd: spamd/spamd.raw $(PERL) build/preprocessor $(FIXBYTES) $(FIXVARS) $(FIXBANG) -i$? -o$@ $(CHMOD) $(PERM_RWX) $@ spamd/libspamc.so: spamd/binaries.mk $(SPAMC_SOURCES) $(MAKE) -f spamd/binaries.mk $@ spamd/libspamc.dll: spamd/binaries.mk $(SPAMC_SOURCES) $(MAKE) -f spamd/binaries.mk $@ spamd/spamc$(EXE_EXT): spamd/binaries.mk $(SPAMC_SOURCES) $(MAKE) -f spamd/binaries.mk $@ spamd/libsslspamc.so: spamd/binaries.mk $(SPAMC_SOURCES) $(MAKE) -f spamd/binaries.mk $@ spamd/libsslspamc.dll: spamd/binaries.mk $(SPAMC_SOURCES) $(MAKE) -f spamd/binaries.mk $@ qmail/qmail-spamc: spamd/binaries.mk $(SPAMC_SOURCES) $(MAKE) -f spamd/binaries.mk $@ spamd/binaries.mk: spamd/configure cd spamd; ./configure --enable-ssl=$(ENABLE_SSL) inst_cfs: -$(MKPATH) $(PKG_LOCAL_RULES_DIR) $(PERL) -e "use File::Copy; (-f '$(PKG_LOCAL_RULES_DIR)/local.cf') or copy ('rules/local.cf', '$(PKG_LOCAL_RULES_DIR)/local.cf');" $(MKPATH) $(PKG_DEF_RULES_DIR) $(RM_RF) $(PKG_DEF_RULES_DIR)/* $(PERL) build/preprocessor $(FIXVARS) -m$(PERM_RW) -Irules -O$(PKG_DEF_RULES_DIR) $(RULES) $(CHMOD) $(PERM_RWX) $(PKG_DEF_RULES_DIR) text_html_doc: made-doc-stamp $(NOOP) doc: $(MKPATH) $@ made-doc-stamp: doc#. ($gotpods ? q# $(MAN1PODS) $(MAN3PODS) $(EXTRAPODS) $(PERL) build/convert_pods_to_doc $(MAN1PODS) $(MAN3PODS) $(EXTRAPODS) # : '') . q# $(TOUCH) made-doc-stamp $(RM_F) pod2htm* #; }