diff --git a/configure b/configure index 7d20fe0e..39f5bcca 100755 --- a/configure +++ b/configure @@ -271,7 +271,7 @@ PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS ac_ct_CC MODFLAGS INCLUDES MODULES MODTARGET VERSION NOSSL LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS ac_ct_CC MODFLAGS INCLUDES MODULES MODTARGET VERSION NOSSL PERL LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -813,6 +813,7 @@ Optional Features: --enable-debug enable debuging --disable-modules disable modules --disable-openssl disable openssl + --disable-perl disable perl Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1961,6 +1962,11 @@ if test "${enable_openssl+set}" = set; then enableval="$enable_openssl" NOSSL=1 fi; +# Check whether --enable-perl or --disable-perl was given. +if test "${enable_perl+set}" = set; then + enableval="$enable_perl" + NOPERL=1 +fi; ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3060,6 +3066,25 @@ fi fi fi +if test -z "$NOPERL"; then + echo -n "checking for perl... " + PERL=`which perl` + if test -n "$PERL"; then + echo "$PERL" + echo -n "checking embeded perl installation... " + PTEST=`$PERL -MExtUtils::Embed -e ccopts 2>&5` + if test -z "$PTEST"; then + echo "failed" + NOPERL=1 + else + echo "ok" + fi + else + echo "no" + NOPERL=1 + fi +fi + if test -z "$prefix" || test $prefix = "NONE"; then prefix="/usr/local" fi @@ -3169,6 +3194,7 @@ VERSION=`grep '#define VERSION' Modules.h | awk '{print $3}'` + ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files znc-config" @@ -3837,6 +3863,7 @@ s,@MODULES@,$MODULES,;t t s,@MODTARGET@,$MODTARGET,;t t s,@VERSION@,$VERSION,;t t s,@NOSSL@,$NOSSL,;t t +s,@PERL@,$PERL,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF diff --git a/configure.in b/configure.in index 5015faef..845de964 100644 --- a/configure.in +++ b/configure.in @@ -39,6 +39,7 @@ AC_ARG_WITH( openssl, [ --with-openssl=/path/to/openssl], OPENSSL=$withval,) AC_ARG_ENABLE( debug, [ --enable-debug enable debuging], appendCXX -Wall -ggdb -D_DEBUG, appendCXX -Wall -s -O2 -fomit-frame-pointer ) AC_ARG_ENABLE( modules, [ --disable-modules disable modules], MODULES="no", MODULES="yes") AC_ARG_ENABLE( openssl, [ --disable-openssl disable openssl], NOSSL=1,) +AC_ARG_ENABLE( perl, [ --disable-perl disable perl], NOPERL=1,) AC_CHECK_FUNCS( stat lstat chmod open, , echo "Missing Required libc feature" && exit 1) if test "$MODULES" = "yes"; then @@ -59,6 +60,25 @@ if test -z "$NOSSL"; then fi fi +if test -z "$NOPERL"; then + echo -n "checking for perl... " + PERL=`which perl` + if test -n "$PERL"; then + echo "$PERL" + echo -n "checking embeded perl installation... " + PTEST=`$PERL -MExtUtils::Embed -e ccopts 2>&5` + if test -z "$PTEST"; then + echo "failed" + NOPERL=1 + else + echo "ok" + fi + else + echo "no" + NOPERL=1 + fi +fi + if test -z "$prefix" || test $prefix = "NONE"; then prefix="/usr/local" fi @@ -99,6 +119,7 @@ AC_SUBST([MODULES]) AC_SUBST([MODTARGET]) AC_SUBST([VERSION]) AC_SUBST([NOSSL]) +AC_SUBST([PERL]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([znc-config]) if test "$MODULES" = "yes"; then diff --git a/modules/Makefile.in b/modules/Makefile.in index ea300c3a..55c69d18 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -3,6 +3,11 @@ CXX=g++ CXXFLAGS=@CXXFLAGS@ INCLUDES=@INCLUDES@ -I.. LIBS=@LIBS@ +PERL=@PERL@ +ifneq "$(PERL)" "" +PERLCC=`$(PERL) -MExtUtils::Embed -e ccopts` +PERLLD=`$(PERL) -MExtUtils::Embed -e ccopts -e ldopts` +endif VPATH=.:.. ifeq "@NOSSL@" "1" @@ -20,7 +25,7 @@ endif all: $(OBJS) $(TARGETS) depend:: - g++ -M $(CXXFLAGS) $(SRCS) $(INCLUDES) `perl -MExtUtils::Embed -e ccopts` >.depend + g++ -M $(CXXFLAGS) $(SRCS) $(INCLUDES) $(PERLCC) >.depend install: all create_install_dir $(INSTALL_TARGS) @echo -n "" @@ -42,9 +47,17 @@ clean: %.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< -########### modperl special TODO this is just so i don't forget, need to make configureable yet +ifneq "$(PERL)" "" modperl.so: modperl.o - $(CXX) $(CXXFLAGS) -shared -o $@ $< $(INCLUDES) $(LIBS) `perl -MExtUtils::Embed -e ccopts -e ldopts` + $(CXX) $(CXXFLAGS) -shared -o $@ $< $(INCLUDES) $(LIBS) $(PERLLD) modperl.o: modperl.cpp - $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ modperl.cpp `perl -MExtUtils::Embed -e ccopts` + $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ modperl.cpp $(PERLCC) +else +modperl.so: + @echo -n "" +modperl.o: + @echo -n "" +install_modperl.so: + @echo -n "" +endif diff --git a/modules/modperl.cpp b/modules/modperl.cpp index 6ae273c2..ae56c7cc 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -121,34 +121,29 @@ XS(XS_AddZNCHook) { if ( g_ModPerl ) g_ModPerl->AddZNCHook( (char *)SvPV(ST(0),PL_na) ); - + PUTBACK; return; } } -EXTERN_C void -xs_init(pTHX) -{ - char *file = __FILE__; - newXS( "AddZNCHook", XS_AddZNCHook, file ); -} - /////////// supporting functions from within module bool CModPerl::OnLoad( const CString & sArgs ) { const char *pArgv[] = { - "ZNCPerl", + sArgs.c_str(), sArgs.c_str(), NULL }; - perl_parse( m_pPerl, xs_init, 2, (char **)pArgv, (char **)NULL ); + perl_parse( m_pPerl, NULL, 2, (char **)pArgv, (char **)NULL ); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; + newXS( "AddZNCHook", XS_AddZNCHook, (char *)__FILE__ ); + ModPerlInit(); return( true ); }