]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
* Fix issue with -fPIC and DynaLoader
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 18 Feb 2009 11:21:06 +0000 (14:21 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 18 Feb 2009 11:21:06 +0000 (14:21 +0300)
* Retab perl.c

CMakeLists.txt
src/perl.c

index 93de41c63920eed41e0c479142ff7bd4bd511c19..70e14b47241c96416cdceed0e9a6e68ed33e0406 100644 (file)
@@ -42,6 +42,14 @@ STRING(REGEX REPLACE "[\r\n]" " " PERL_CFLAGS ${PERL_CFLAGS})
 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)
@@ -54,6 +62,10 @@ ENDIF(NOT LEX_EXECUTABLE OR NOT YACC_EXECUTABLE)
 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})
@@ -257,13 +269,18 @@ ADD_CUSTOM_TARGET(perlxs ALL
 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})
index eaa334d8d257666944d6cf81199363973b261820..08a101285005dc7c31179684515ab4195fa2cdd5 100644 (file)
@@ -4,11 +4,11 @@
  *
  * 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
@@ -46,40 +46,40 @@ xs_init(pTHX)
        /* 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;
                }
        }
 }
@@ -257,9 +257,9 @@ perl_call_chain_filter (const char *function, struct worker_task *task, int *mar
 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);
@@ -278,8 +278,8 @@ void perl_call_memcached_callback (memcached_ctx_t *ctx, memc_error_t error, voi
 
        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;