IPTables-IPv4-DBTarpit

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.

###########################################################
##         if built from a parent directory,              #
##     at install, the parent Makefile must execute       #
##                                                        #
##           as first step in install                     #
## @cd DBTarpit && $(MAKE) install_libdbtarpit $(PASTHRU) #
## @cd DBTarpit && $(MAKE) install_daemon $(PASTHRU)      #
##                                                        #
##        as step immediately after 'all'                 #
## @cd DBTarpit && $(MAKE) clean_CTest $(PASTHRU)         #
## @cd DBTarpit && $(MAKE) relink_subdirs $(PASTHRU)      #
##                                                        #
###########################################################

use vars qw($CONFIG);
use Config;
use Cwd qw(abs_path);
require 'lib/IPTables/IPv4/DBTarpit/Inst.pm';
import IPTables::IPv4::DBTarpit::Inst qw(:all);

if ((caller)[1]) {
  hard_fail("Do not MAKE __PACKAGE__ as a sibling process
it contains directory sensitive components.");
}

my $CC = $Config{ccname};
my $OS = $Config{osname};

unless ($OS =~ /linux/) {
  print STDERR "Only works on Linux with IPTABLES\n";
  exit 0;
}
# checkfor installed libnet 1.0 or greater
my $libnetstatus = system("./local_config $CC");
if ($libnetstatus) {
  print STDERR "YOUR MUST INSTALL libnet VERSION 1.0.0 or greater\n";
  exit 0;
}

my $pmname = 'DBTarpit.pm';
open(V,$pmname)
	or hard_fail("could not open $pmname to get version number");
my $c_version;
while (<V>) {
  next unless $_ =~ /\$VERSION.+(char[^;]+;)/;
  $c_version = $1;
  last;
}
close V;
hard_fail("could not find version number in $pmname")
	unless $c_version;
hard_fail("could not open 'c_version.h' for local write")
	unless open(H,'>./c_version.h');
print H qq|
/*	c_version.h
 *
 *	Do not edit this file. It was automatically created by
 *	Makefile.PL and contains the most recent version number
 */
$c_version
|;
close H;

open(V,'bdbtarpit.h') 
	or hard_fail("could not open bdbtarpit.h to get version number");
my ($major,$minor,$patch);
while(<V>) {
  if ($_ =~ /MAJOR\s+(\d+)/) {
    $major = $1;
  } elsif($_ =~ /MINOR\s+(\d+)/) {
    $minor = $1;
  } elsif($_ =~ /PATCH\s+(\d+)/) {
    $patch = $1;
    last;
  }
}
close V;

hard_fail("could not extract version information from bdbtarpit.h, bad format??")
	unless	defined $major && defined $minor && defined $patch;

my $bdbtarpit_version	= "${major}:${minor}:${patch}";

# create visible binary directory
symlink '.libs', 'bin';

my $supported_os = './supported_os.h';
hard_fail("could not open $supported_os for local write")
	unless open(H,'>'.$supported_os);

$supported_os = osname();
print H qq
|#define DBTARPIT_SUPPORTED_OS_$supported_os 1	/* 
#
# supported_os.h, |, scalar localtime(), qq|
#
# Do not edit this file. It was automatically created by 
# Makefile.Pl and is OS specific for this installation.
#
'${supported_os}';	# perl return
#			*/
|;
close H;

my $conf = 'config.db';
my $localconf = abs_path('./').'/'.$conf;
my $configtxt;

if ((caller)[0]) {
  my $master = abs_path('../').'/'.$conf;
  hard_fail("failed to access $_")
	if ($_ = cpfromto($master,$localconf));

  $CONFIG = do $localconf;
  $configtxt = make_text($CONFIG);
}
else {
  $configtxt = do 'inst/dialog.pl';
}

my $objects	= 'libipq_wrapper.o main.o tarpit.o util_pid.o fifo.o';
my $depend	= {'CTest.o'   => $lib_a,};
my $library	= 'libdbtarpit';
my $lib_a	= './.libs/'. $library .'.a';
my $lib_la	= $library .'.la';
my $libobjs	= $objects .' '. $lib_la;
my $libtest	= $objects .' '. $lib_a;


my $daemon	= 'dbtarpit_test_object';
my $daemon_real	= 'dbtarpit';

WriteMakefile(
    'NAME'		=> 'IPTables::IPv4::DBTarpit::CTest',
    'DISTNAME'		=> 'IPTables-IPv4-DBTarpit',
    'VERSION_FROM'	=> $pmname, # finds $VERSION
    'PM'		=> {'DBTarpit.pm' => '$(INST_LIB)/IPTables/IPv4/DBTarpit.pm',
			    'lib/IPTables/IPv4/DBTarpit/Inst.pm' =>
				'$(INST_LIB)/IPTables/IPv4/DBTarpit/Inst.pm',
			    'SiteConfig.pm' => '$(INST_LIB)/IPTables/IPv4/DBTarpit/SiteConfig.pm',
			},
    'MAN1PODS'		=> {$library .'.pod' => '$(INST_MAN1DIR)/'. $library . '.$(MAN1EXT)',
			    $daemon_real .'.pod' => '$(INST_MAN1DIR)/'. $daemon_real .'.$(MAN1EXT)',
			},
    'MAN3PODS'		=> {'DBTarpit.pm' => '$(INST_MAN3DIR)/IPTables::IPv4::DBTarpit.$(MAN3EXT)',
			    'lib/IPTables/IPv4/DBTarpit/Inst.pm' =>
				'$(INST_MAN3DIR)/IPTables::IPv4::DBTarpit::Inst.$(MAN3EXT)',
			    'SiteConfig.pm' => '$(INST_MAN3DIR)/IPTables::IPv4::DBTarpit::SiteConfig.$(MAN3EXT)',
			},
    'LIBS'		=> ['-ldb -lipq -lnet -lm'], # e.g., '-lm'
    'DEFINE'		=> '', # e.g., '-DHAVE_SOMETHING'
	# Insert -I. if you add *.h files later:
    'INC'		=> "", # e.g., '-I/usr/include/other'
	# Un-comment this if you add C files to link with later:
    'OBJECT'		=> "$libtest CTest.o", # link all the C files too
    'clean'		=> {FILES	=> "$daemon *.bs *.o *.lo *.la *~ .libs tmp* bin libipq.h libnet_version.h"},
    'depend'		=> {$depend,},
);

sub MY::post_constants {
  my $pod2text = $Config{scriptdirexp} .'/pod2text';
  my $post_constants;
  if (-e $pod2text) {
    $post_constants = q| 
MY_POD2TEXT = |. $pod2text .q|
LDTool = ./libtool --mode=link $(LD) -g -s
|. $configtxt .q|
|;
  } else {



( run in 1.062 second using v1.01-cache-2.11-cpan-6de40a662fe )