STRING(REGEX REPLACE " +$" "" PERL_CFLAGS ${PERL_CFLAGS})
STRING(REGEX REPLACE "[\r\n]" " " PERL_LDFLAGS ${PERL_LDFLAGS})
STRING(REGEX REPLACE " +$" "" PERL_LDFLAGS ${PERL_LDFLAGS})
+# Handle DynaLoader
+STRING(REGEX MATCH "/[^ ]*/DynaLoader.a" PERL_DYNALOADER ${PERL_LDFLAGS})
+STRING(REGEX REPLACE "/[^ ]*/DynaLoader.a " "" PERL_LDFLAGS ${PERL_LDFLAGS})
+
+IF(PERL_DYNALOADER)
+ EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy ${PERL_DYNALOADER} ${rspamd_BINARY_DIR}/compat/libdynaloader.so)
+ LINK_DIRECTORIES(${rspamd_BINARY_DIR}/compat/)
+ENDIF(PERL_DYNALOADER)
# Lex and yacc
FIND_PROGRAM(LEX_EXECUTABLE lex)
pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.10)
pkg_check_modules(GMIME2 REQUIRED gmime-2.0)
+IF(NOT GLIB2_FOUND OR NOT GMIME2_FOUND)
+ MESSAGE(FATAL_ERROR "Error: gmime2 and glib2 are required for rspamd")
+ENDIF(NOT GLIB2_FOUND OR NOT GMIME2_FOUND)
+
# Make from ; separated list normal space separated list
# Glib2
FOREACH(arg ${GLIB2_CFLAGS})
CONFIGURE_FILE(config.h.in src/config.h)
CONFIGURE_FILE(perl/Makefile.PL.in perl/Makefile.PL)
-ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${CONTRIBSRC} ${TOKENIZERSSRC} ${CLASSIFIERSSRC} ${PLUGINSSRC} ${YACC_OUTPUT} ${LEX_OUTPUT})
+ADD_EXECUTABLE(rspamd ${RSPAMDSRC} ${CONTRIBSRC} ${TOKENIZERSSRC}
+ ${CLASSIFIERSSRC} ${PLUGINSSRC} ${YACC_OUTPUT}
+ ${LEX_OUTPUT})
SET_TARGET_PROPERTIES(rspamd PROPERTIES LINKER_LANGUAGE C)
SET_TARGET_PROPERTIES(rspamd PROPERTIES VERSION ${RSPAMD_VERSION})
SET_TARGET_PROPERTIES(rspamd PROPERTIES COMPILE_FLAGS ${PERL_CFLAGS}
LINK_FLAGS ${PERL_LDFLAGS})
TARGET_LINK_LIBRARIES(rspamd ${GLIB2_LIBRARIES})
TARGET_LINK_LIBRARIES(rspamd event)
+IF(PERL_DYNALOADER)
+ TARGET_LINK_LIBRARIES(rspamd dynaloader)
+ENDIF(PERL_DYNALOADER)
TARGET_LINK_LIBRARIES(rspamd ${GMIME2_LIBRARIES})
ADD_EXECUTABLE(test/rspamd-test ${TESTDEPENDS} ${CONTRIBSRC} ${TESTSRC})
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
/* DynaLoader is a special case */
newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, __FILE__);
- rspamd_task_stash = gv_stashpv("rspamd_task", TRUE);
- rspamd_cfg_stash = gv_stashpv("rspamd_config", TRUE);
+ rspamd_task_stash = gv_stashpv("rspamd_task", TRUE);
+ rspamd_cfg_stash = gv_stashpv("rspamd_config", TRUE);
}
void
init_perl_filters (struct config_file *cfg)
{
struct perl_module *module;
- char *init_func;
- size_t funclen;
+ char *init_func;
+ size_t funclen;
SV* sv;
-
+
dTHXa (perl_interpreter);
PERL_SET_CONTEXT (perl_interpreter);
- dSP;
+ dSP;
LIST_FOREACH (module, &cfg->perl_modules, next) {
if (module->path) {
require_pv (module->path);
- ENTER;
- SAVETMPS;
+ ENTER;
+ SAVETMPS;
- PUSHMARK (SP);
+ PUSHMARK (SP);
sv = sv_2mortal (sv_bless (newRV_noinc (newSViv (PTR2IV(cfg))), rspamd_cfg_stash));
- XPUSHs (sv);
- PUTBACK;
- /* Call module init function */
- funclen = strlen (module->path) + sizeof ("::") + sizeof (MODULE_INIT_FUNC) - 1;
- init_func = g_malloc (funclen);
- snprintf (init_func, funclen, "%s::%s", module->path, MODULE_INIT_FUNC);
- call_pv (init_func, G_DISCARD);
-
- FREETMPS;
- LEAVE;
+ XPUSHs (sv);
+ PUTBACK;
+ /* Call module init function */
+ funclen = strlen (module->path) + sizeof ("::") + sizeof (MODULE_INIT_FUNC) - 1;
+ init_func = g_malloc (funclen);
+ snprintf (init_func, funclen, "%s::%s", module->path, MODULE_INIT_FUNC);
+ call_pv (init_func, G_DISCARD);
+
+ FREETMPS;
+ LEAVE;
}
}
}
void perl_call_memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data)
{
struct {
- SV *callback;
- struct worker_task *task;
- } *callback_data = data;
+ SV *callback;
+ struct worker_task *task;
+ } *callback_data = data;
SV *sv;
dTHXa (perl_interpreter);
call_sv (callback_data->callback, G_SCALAR);
- /* Set save point */
- callback_data->task->save.saved = 0;
+ /* Set save point */
+ callback_data->task->save.saved = 0;
process_filters (callback_data->task);
SPAGAIN;