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.");
}
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}"
;
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}'
;
|;
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
=
'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'
=>
'DBTarpit.pm'
,
'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'
],
'DEFINE'
=>
''
,
'INC'
=>
""
,
'OBJECT'
=>
"CTest.o $libtest"
,
'clean'
=> {
FILES
=>
"$daemon *.bs *.o *.lo *.la *~ .libs tmp* bin"
},
'depend'
=> {
'CTest.o'
=>
$lib_a
,},
);
sub
MY::post_constants {
my
$post_constants
=
q|
LDTool = ./libtool --mode=link $(LD) -g -s
|
.
$configtxt
.
q|
|
;
}
sub
MY::postamble {
my
$postamble
=
q|
README : DBTarpit.pm
pod2text DBTarpit.pm > README
.PHONY: clean_CTest relink_subdirs $(DBTP_DAEMON_DIR)/|
.
$daemon_real
.
q|
install_|
.
$library
.
q| : |
.
$library
.
q|.la
./libtool --mode=install ./install-sh -c -s |
.
$library
.
q|.la $(DBTP_LIBRARY_DIR)/|
.
$library
.
q|.la
@$(MKPATH) $(DBTP_INCLUDE_DIR)
$(CP) bdbtarpit.h $(DBTP_INCLUDE_DIR)
install_daemon : |
.
$daemon
.
q| $(DBTP_DAEMON_DIR)/|
.
$daemon_real
.
q|
@$(NOOP)
# make the BDB environment/home directory while we're at it
$(DBTP_DAEMON_DIR)/|
.
$daemon_real
.
q| :
@$(MKPATH) $(DBTP_ENVHOME_DIR)
@$(MKPATH) $(DBTP_DAEMON_DIR)
$(CP) bin/|
.
$daemon_real
.
q| $(DBTP_DAEMON_DIR)/|
.
$daemon_real
.
q|
# Since these are only used for testing and are large, remove them
# from the install image as they will be rebuilt as needed.
clean_CTest :
@$(RM_RF) $(INST_AUTODIR)
@$(RM_RF) $(INST_ARCHAUTODIR)
relink_subdirs :
@cd Tools && $(MAKE) relink4_$(LINKTYPE)_install $(PASTHRU)
SiteConfig.pm : config.db
$(PERL) inst/make_Config.pl
|
;
}
sub
MY::top_targets {
my
$inherited
=
shift
->SUPER::top_targets(
@_
);
$inherited
=~ s/(\npure_all\s+::.+)/$1
$daemon
README/;
$inherited
=~ s|(\npure_all\s+::.+)config(.+)|$1./libtool SiteConfig.pm config$2|;
$inherited
.=
q|
# Added for for '|
.
$daemon
.
q|'
libtool :
$(SHELL) ltconfig ./ltmain.sh
|
.
$daemon
.
q| : |
.
$libobjs
.
q|
$(LDTool) $(LDFLAGS) |
.
$libobjs
.
q| -o |
.
$daemon
.
q| $(LDLOADLIBS)
$(CP) ./bin/|
.
$daemon
.
' ./bin/'
.
$daemon_real
.
q|
bdbtarpit.o : bdbtarpit.c bdbtarpit.h
./libtool --mode=compile $(CC) -g $(INC) $(CCFLAGS) $(OPTIMIZE) -c bdbtarpit.c
fifo.o : fifo.c
$(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) fifo.c
main.o : main.c data.c godaemon.c misc.c check.c tarpit.h supported_os.h\
defines.h bdbtarpit.h util_pid_func.h fifo.c fifo_func.h DBTarpit.pm
$(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) main.c
tarpit.o : tarpit.c endian.h defines.h misc_func.h
$(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) tarpit.c
util_pid.o : util_pid.c
$(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) util_pid.c
|
.
qq|
$lib_a : bdbtarpit.o
|
.
q| $(LDTool) -version-info |
.
$bdbtarpit_version
.
q| \
$(LDFLAGS) -o |
.
$lib_la
.
q| \
bdbtarpit.lo -rpath $(DBTP_LIBRARY_DIR) -lm
|
.
qq|
$lib_la : bdbtarpit.o
|
.
q| $(LDTool) -version-info |
.
$bdbtarpit_version
.
q| \
$(LDFLAGS) -o |
.
$lib_la
.
q| \
bdbtarpit.lo -rpath $(DBTP_LIBRARY_DIR) -lm
|
.
$daemon_real
.
q|.pod : DBTarpit.pm
$(CP) DBTarpit.pm |
.
$daemon_real
.
q|.pod
|
;
}
sub
MY::makefile {
my
$inherited
=
shift
->SUPER::makefile(
@_
);
$inherited
=~ s/(Makefile\s+:.+)/$1 config.db/;
$inherited
.=
q|
config.db :
@$(NOOP);
|
;
}
sub
MY::install {
my
$inherited
=
shift
->SUPER::install(
@_
);
$inherited
=~ s/(\ninstall\s+::)/$1 libtool install_${library} install_daemon/;
$inherited
=~ s/(\ninstall_perl\s+::)/$1 libtool install_${library} install_daemon/;
$inherited
=~ s/(\ninstall_site\s+::)/$1 libtool install_${library} install_daemon/;
$inherited
=~ s/\s+all\s+/ all clean_CTest relink_subdirs /g;
$inherited
;
}
sub
MY::realclean {
my
$inherited
=
shift
->SUPER::realclean(
@_
) .
q|
rm -f config.db
rm -f config.log
rm -f SiteConfig.pm
rm -f dbtarpit.pod
rm -f libtool
rm -f supported_os.h
|
;
}
sub
MY::dynamic_lib {
my
$inherited
=
shift
->SUPER::dynamic_lib(
@_
);
$inherited
=~ s/(LD_RUN_PATH=([^\s]+))/$1 LD_LIBRARY_PATH=$2/;
$inherited
;
}