Skip to content

Commit

Permalink
Big update of modperl module.
Browse files Browse the repository at this point in the history
Old modperl had several flaws and was very outdated.
New modperl makes the whole ZNC API accessible from inside perl.
Modperl API was changed, so old perl modules are not supported,
but they weren't used much anyway.

Modperl needs --enable-perl option to ./configure.

This introduces new dependence on SWIG, which is needed only while
compiling ZNC. So to use modperl, you need to install SWIG or
to download several files and use --disable-swig option of configure.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2120 726aef4b-f618-498e-8847-2d620e286838
  • Loading branch information
darthgandalf committed Sep 7, 2010
1 parent ffcd422 commit a44e6ea
Show file tree
Hide file tree
Showing 13 changed files with 2,500 additions and 1,624 deletions.
84 changes: 81 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ MODLINK
LIBZNCDIR
LIBZNC
MODFLAGS
SWIG_BINARY
PERL_BINARY
openssl_LIBS
openssl_CFLAGS
Expand Down Expand Up @@ -642,6 +643,7 @@ enable_debug
enable_ipv6
enable_openssl
enable_perl
enable_swig
enable_sasl
enable_optimization
enable_c_ares
Expand Down Expand Up @@ -1288,7 +1290,13 @@ Optional Features:
--enable-debug enable debugging
--disable-ipv6 disable ipv6 support
--disable-openssl disable openssl
--disable-perl disable perl
--enable-perl enable perl
--disable-swig Disable automatic generation of source files needed
for modperl. This value is ignored if perl is
disabled or not found. If you disable swig, but
still want to use modperl, please download the
necessary files to modules/modperl. Check
http://en.znc.in/wiki/Modperl for details.
--enable-sasl enable sasl
--disable-optimization Disable some compiler optimizations to decrease
memory usage while compiling
Expand Down Expand Up @@ -2913,7 +2921,14 @@ fi
if test "${enable_perl+set}" = set; then :
enableval=$enable_perl; PERL="$enableval"
else
PERL="auto"
PERL="no"
fi
# Check whether --enable-swig was given.
if test "${enable_swig+set}" = set; then :
enableval=$enable_swig; SWIG="$enableval"
else
SWIG="auto"
fi
# Check whether --enable-sasl was given.
Expand Down Expand Up @@ -3649,6 +3664,7 @@ fi
if test "x$PERL" != "xno"; then
old_PERL="$PERL"
old_SWIG="$SWIG"
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
Expand Down Expand Up @@ -3734,6 +3750,53 @@ else
PERL="no"
fi
if test "x$PERL" != "xno"; then
if test "x$SWIG" != "xno"; then
# Extract the first word of "swig", so it can be a program name with args.
set dummy swig; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_SWIG_BINARY+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $SWIG_BINARY in
[\\/]* | ?:[\\/]*)
ac_cv_path_SWIG_BINARY="$SWIG_BINARY" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_SWIG_BINARY="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
SWIG_BINARY=$ac_cv_path_SWIG_BINARY
if test -n "$SWIG_BINARY"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SWIG_BINARY" >&5
$as_echo "$SWIG_BINARY" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test -z "$SWIG_BINARY"; then
SWIG="no"
fi
fi
fi
LDFLAGS="$my_saved_LDFLAGS"
else
PERL="no"
Expand All @@ -3751,7 +3814,22 @@ $as_echo "$as_me: WARNING: perl was not found and thus disabled" >&2;}
PERL_BINARY=""
else
PERL=yes
if test "x$SWIG" = "xno"; then
SWIG_BINARY=""
if test "x$old_SWIG" = "xno"; then
PERL="yes, but with manual download"
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: swig was disabled, so you should put needed sources for modperl to modules/modperl.
Please check http://en.znc.in/wiki/Modperl for details." >&5
$as_echo "$as_me: WARNING: swig was disabled, so you should put needed sources for modperl to modules/modperl.
Please check http://en.znc.in/wiki/Modperl for details." >&2;}
else
as_fn_error $? "swig was not found. Try --disable-perl, or download the necessary sources and use --disable-swig.
Please check http://en.znc.in/wiki/Modperl for details." "$LINENO" 5
fi
else
PERL="yes"
SWIG="yes"
fi
fi
fi
Expand Down
35 changes: 32 additions & 3 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,16 @@ AC_ARG_ENABLE( [openssl],
[SSL="$enableval"],
[SSL="auto"])
AC_ARG_ENABLE( [perl],
AS_HELP_STRING([--disable-perl], [disable perl]),
AS_HELP_STRING([--enable-perl], [enable perl]),
[PERL="$enableval"],
[PERL="auto"])
[PERL="no"])
AC_ARG_ENABLE( [swig],
AS_HELP_STRING([--disable-swig], [Disable automatic generation of source files needed for modperl.
This value is ignored if perl is disabled or not found. If you disable swig,
but still want to use modperl, please download the necessary files to modules/modperl.
Check http://en.znc.in/wiki/Modperl for details.]),
[SWIG="$enableval"],
[SWIG="auto"])
AC_ARG_ENABLE( [sasl],
AS_HELP_STRING([--enable-sasl], [enable sasl]),
[if test "$enableval" = "yes" ; then SASL=1; fi],)
Expand Down Expand Up @@ -257,13 +264,22 @@ fi

if test "x$PERL" != "xno"; then
old_PERL="$PERL"
old_SWIG="$SWIG"
AC_PATH_PROG([PERL_BINARY], [perl], [])
if test -n "$PERL_BINARY"; then
my_saved_LDFLAGS="$LDFLAGS"
appendLD `$PERL_BINARY -MExtUtils::Embed -e ccopts -e ldopts`
AC_CHECK_LIB(perl, perl_alloc,
[: No, we do not want autoconf to do sth automatically],
PERL="no")
if test "x$PERL" != "xno"; then
if test "x$SWIG" != "xno"; then
AC_PATH_PROG([SWIG_BINARY], [swig], [])
if test -z "$SWIG_BINARY"; then
SWIG="no"
fi
fi
fi
LDFLAGS="$my_saved_LDFLAGS"
else
PERL="no"
Expand All @@ -274,7 +290,20 @@ if test "x$PERL" != "xno"; then
[perl was not found and thus disabled])
PERL_BINARY=""
else
PERL=yes
if test "x$SWIG" = "xno"; then
SWIG_BINARY=""
if test "x$old_SWIG" = "xno"; then
PERL="yes, but with manual download"
AC_MSG_WARN([swig was disabled, so you should put needed sources for modperl to modules/modperl.
Please check http://en.znc.in/wiki/Modperl for details.])
else
AC_MSG_ERROR([swig was not found. Try --disable-perl, or download the necessary sources and use --disable-swig.
Please check http://en.znc.in/wiki/Modperl for details.])
fi
else
PERL="yes"
SWIG="yes"
fi
fi
fi

Expand Down
33 changes: 31 additions & 2 deletions modules/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LDFLAGS := @LDFLAGS@
# The znc binary links already against those.
# LIBS := @LIBS@
PERL := @PERL_BINARY@
SWIG := @SWIG_BINARY@
MODDIR := @MODDIR@
DATADIR := @DATADIR@
LIBZNC := @LIBZNC@
Expand Down Expand Up @@ -69,6 +70,10 @@ ifneq "$(PERL)" ""
modperlFLAGS := $(shell $(PERL) -MExtUtils::Embed -e perl_inc -e ldopts)
# Perl API is ugly, casting string literals to char* and redeclaring functions :(
modperlFLAGS += -Wno-write-strings -Wno-redundant-decls -Wno-missing-declarations
# This is for SWIG
modperlFLAGS += -DSWIG_TYPE_TABLE=znc
# Find additional headers for out-of-tree build
modperlFLAGS += -I.
PERLHOOK := modperl_install
else
FILES := $(shell echo $(FILES) | sed -e "s/modperl//")
Expand All @@ -94,7 +99,7 @@ modtclFLAGS := $(TCL_FLAGS)

TARGETS := $(addsuffix .so, $(FILES))

CLEAN := *.so extra/*.so
CLEAN := *.so extra/*.so modperl/ZNC.so modperl/modperl_wrap.cxx modperl/ZNC.pm

.PHONY: all clean install modperl_install

Expand Down Expand Up @@ -125,10 +130,34 @@ clean:
$(E) Building $(if $(filter %extra/,$(dir $<)),extra )module $(notdir $(basename $@))...
$(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -o $@ $< $($(notdir $(basename $@))FLAGS) -MMD -MF .depend/$(notdir $@).dep

modperl_install: create_install_dir
modperl.so: modperl/ZNC.so
modperl/ZNC.so: modperl/modperl_wrap.cxx Makefile
$(E) Building ZNC perl bindings library...
$(Q)$(CXX) $(MODFLAGS) $(LDFLAGS) $(MODLINK) -I$(srcdir) -DSWIG_TYPE_TABLE=znc $(shell $(PERL) -MExtUtils::Embed -e perl_inc -e ldopts) -o $@ $<
ifneq "$(SWIG)" ""
modperl/modperl_wrap.cxx: modperl/modperl.i Makefile modperl/module.h modperl/CString.i
$(E) Generating ZNC API for perl...
@mkdir -p modperl
$(Q)$(SWIG) -perl5 -c++ -shadow -outdir modperl -I$(srcdir) -w362,315,401,402 -o $@.warn $<
$(Q)$(PERL) -pe '$$x==2 and print "items+=0;" and $$x=3;/^XS\(SWIG_init\)/ and $$x=1;$$x==1 and /dXSARGS/ and $$x=2' $@.warn > $@
$(Q)rm -rf $@.warn
$(Q)$(SWIG) -perl5 -c++ -shadow -external-runtime modperl/swigperlrun.h
endif

modperl_install: create_install_dir install_metadirs
for i in $(srcdir)/*.pm; do \
$(INSTALL_DATA) $$i $(DESTDIR)$(MODDIR); \
done
for a in $(srcdir)/*; do \
if [ -d $$a ] && [ -f $${a}.pm ]; then \
cp -Rp $$a $(DESTDIR)$(DATADIR); \
fi \
done
rm -rf $(DESTDIR)$(DATADIR)/modperl
mkdir -p $(DESTDIR)$(MODDIR)/modperl
$(INSTALL_PROGRAM) $(srcdir)/modperl/ZNC.so $(DESTDIR)$(MODDIR)/modperl
$(INSTALL_DATA) $(srcdir)/modperl/ZNC.pm $(DESTDIR)$(MODDIR)/modperl
$(INSTALL_DATA) $(srcdir)/modperl/startup.pl $(DESTDIR)$(MODDIR)/modperl

modtcl_install:
mkdir -p $(DESTDIR)$(DATADIR)/modtcl/
Expand Down
Loading

0 comments on commit a44e6ea

Please sign in to comment.