]> source.dussan.org Git - rspamd.git/commitdiff
Fix build under Solaris10. Reported in https://bitbucket.org/vstakhov/rspamd/issue...
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 17 Oct 2011 11:19:38 +0000 (14:19 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 17 Oct 2011 11:19:38 +0000 (14:19 +0300)
CMakeLists.txt
config.h.in
lib/CMakeLists.txt
src/dns.h
src/evdns/CMakeLists.txt

index ae042706abe02b5b9bd4ff777d4841a6b9fe3253..5b15eb6672964e34dcef28c65d6da2fe8f457478 100644 (file)
@@ -177,7 +177,38 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 
 IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
-       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DSOLARIS")
+       IF(NOT BUILD_CPU_MODE)
+               SET (BUILD_CPU_MODE "32")
+       ENDIF(NOT BUILD_CPU_MODE)
+       
+       IF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
+               set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xa -xregs=no%frameptr -xstrconst")
+               set(SUN_BUILD32 "-xtarget=generic")
+               set(SUN_BUILD64 "-xtagret=generic64")
+               IF(ENABLE_OPTIMIZATION MATCHES "ON")
+                       SET(CMAKE_C_OPT_FLAGS "-fast -xdepend")
+               ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
+                       SET(CMAKE_C_OPT_FLAGS "-xO0")
+               ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")
+       ELSE("${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
+               set(SUN_BUILD32 "-m32")
+               set(SUN_BUILD64 "-m64")         
+       ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro)
+
+       IF (BUILD_CPU_MODE STREQUAL "32")
+       message (STATUS "Building 32-bit mode on Solaris")
+       # If we are asked to build 32 bit mode
+               set(CMAKE_C_FLAGS  "${SUN_BUILD32} ${CMAKE_C_FLAGS}")
+               set(CMAKE_SHARED_LINKER_FLAGS  "${CMAKE_SHARED_LINKER_FLAGS} ${SUN_BUILD32}")
+       ELSE (BUILD_CPU_MODE STREQUAL "32")
+       # solaris 64-bit mode
+               message (STATUS "Building 64-bit mode on Solaris")
+               set(CMAKE_C_FLAGS  "${SUN_BUILD64} ${CMAKE_C_FLAGS}")
+               set(CMAKE_SHARED_LINKER_FLAGS  "${CMAKE_SHARED_LINKER_FLAGS} ${SUN_BUILD64}")
+    ENDIF (BUILD_CPU_MODE STREQUAL "32")
+
+       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS")
+
        IF(CMAKE_INSTALL_PREFIX)
                IF(NOT ETC_PREFIX)
                SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
@@ -194,7 +225,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
                SET(ETC_PREFIX /etc)
        ENDIF(NOT ETC_PREFIX)
        IF(NOT PREFIX)
-               SET(PREFIX /opt/rspamd)
+               SET(PREFIX /usr)
        ENDIF(NOT PREFIX)
        IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX /usr/share/man)
@@ -207,8 +238,11 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
        LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
        LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl)
        LIST(APPEND CMAKE_REQUIRED_LIBRARIES resolv)
-       LIST(APPEND CMAKE_REQUIRED_LIBRARIES m)
-       MESSAGE(STATUS "Configuring for Solaris")
+       LIST(APPEND CMAKE_REQUIRED_LIBRARIES nsl)
+       LIST(APPEND CMAKE_REQUIRED_LIBRARIES umem)
+       SET(CMAKE_VERBOSE_MAKEFILE ON)
+       SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+       SET(CMAKE_INSTALL_RPATH "${PREFIX}/lib")        
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
 # Check prefixes
@@ -498,7 +532,64 @@ IF(LIBUTIL_LIBRARY)
                                DOC "Path to libutil header")
 ENDIF(LIBUTIL_LIBRARY)
 
+ # Process with warn flags
+ IF(CMAKE_COMPILER_IS_GNUCC)
+ CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL)
+ CHECK_C_COMPILER_FLAG(-Wall SUPPORT_W)
+ CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER)
+ CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM)
+ CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION)
+ CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR)
+ CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN)
+ CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG)
+ CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG)
+ SET(CMAKE_C_WARN_FLAGS "")
+ IF(SUPPORT_W)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W")
+ ENDIF(SUPPORT_W)
+ IF(SUPPORT_WALL)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall")
+ ENDIF(SUPPORT_WALL)
+ IF(SUPPORT_WPOINTER)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith")
+ ENDIF(SUPPORT_WPOINTER)
+ IF(SUPPORT_WPARAM)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter")
+ ENDIF(SUPPORT_WPARAM)
+ IF(SUPPORT_WFUNCTION)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function")
+ ENDIF(SUPPORT_WFUNCTION)
+ IF(SUPPORT_WUNUSED_VAR)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable")
+ ENDIF(SUPPORT_WUNUSED_VAR)
+ IF(SUPPORT_WPOINTER_SIGN)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign")
+ ENDIF(SUPPORT_WPOINTER_SIGN)
+ IF(SUPPORT_PEDANTIC_FLAG)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic")
+ ENDIF(SUPPORT_PEDANTIC_FLAG)
+ IF(SUPPORT_STD_FLAG)
+       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99")
+ ENDIF(SUPPORT_STD_FLAG)
+ ENDIF(CMAKE_COMPILER_IS_GNUCC)
+ # Optimization flags
+IF(NOT CMAKE_C_OPT_FLAGS)
+       IF(ENABLE_OPTIMIZATION MATCHES "ON")
+               SET(CMAKE_C_OPT_FLAGS "-O3")
+       ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
+               SET(CMAKE_C_OPT_FLAGS "-O0")
+       ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")
+ENDIF(NOT CMAKE_C_OPT_FLAGS)
+
+IF(DEBUG_MODE MATCHES "ON")
+       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+ENDIF(DEBUG_MODE MATCHES "ON")
 
+SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}")
 # Check platform specific includes
 CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
 CHECK_INCLUDE_FILES(sys/time.h  HAVE_SYS_TIME_H)
@@ -574,8 +665,9 @@ CHECK_SYMBOL_EXISTS(MAP_SHARED sys/mman.h HAVE_MMAP_SHARED)
 CHECK_SYMBOL_EXISTS(MAP_ANON sys/mman.h HAVE_MMAP_ANON)
 CHECK_SYMBOL_EXISTS(MAP_NOCORE sys/mman.h HAVE_MMAP_NOCORE)
 CHECK_SYMBOL_EXISTS(_SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN)
-CHECK_SYMBOL_EXISTS(SA_SIGINFO signal.h HAVE_SA_SIGINFO)
+CHECK_SYMBOL_EXISTS(SA_SIGINFO "signal.h;siginfo.h" HAVE_SA_SIGINFO)
 
+IF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 IF(HAVE_CLOCK_GETTIME)
        CHECK_SYMBOL_EXISTS(CLOCK_PROCESS_CPUTIME_ID time.h HAVE_CLOCK_PROCESS_CPUTIME_ID)
        CHECK_SYMBOL_EXISTS(CLOCK_VIRTUAL time.h HAVE_CLOCK_VIRTUAL)
@@ -589,6 +681,7 @@ CHECK_C_SOURCE_COMPILES ("#include <sys/types.h>
                                                        __asm __volatile(\"pause\");
                                                        return 0;
                                                  }" HAVE_ASM_PAUSE)
+ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
 # Check queue.h compatibility
 IF(NOT HAVE_COMPATIBLE_QUEUE_H)
@@ -598,60 +691,6 @@ ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H)
 
 SET(CONTRIBSRC "")
 
-# Optimization flags
-IF(ENABLE_OPTIMIZATION MATCHES "ON")
-       SET(CMAKE_C_OPT_FLAGS "-O3")
-ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
-       SET(CMAKE_C_OPT_FLAGS "-O0")
-ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")
-
-# Process with warn flags
-CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL)
-CHECK_C_COMPILER_FLAG(-Wall SUPPORT_W)
-CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER)
-CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM)
-CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION)
-CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR)
-CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN)
-CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG)
-CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG)
-
-SET(CMAKE_C_WARN_FLAGS "")
-
-IF(SUPPORT_W)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W")
-ENDIF(SUPPORT_W)
-IF(SUPPORT_WALL)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall")
-ENDIF(SUPPORT_WALL)
-IF(SUPPORT_WPOINTER)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith")
-ENDIF(SUPPORT_WPOINTER)
-IF(SUPPORT_WPARAM)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter")
-ENDIF(SUPPORT_WPARAM)
-IF(SUPPORT_WFUNCTION)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function")
-ENDIF(SUPPORT_WFUNCTION)
-IF(SUPPORT_WUNUSED_VAR)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable")
-ENDIF(SUPPORT_WUNUSED_VAR)
-IF(SUPPORT_WPOINTER_SIGN)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign")
-ENDIF(SUPPORT_WPOINTER_SIGN)
-IF(SUPPORT_PEDANTIC_FLAG)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic")
-ENDIF(SUPPORT_PEDANTIC_FLAG)
-IF(SUPPORT_STD_FLAG)
-       SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99")
-ENDIF(SUPPORT_STD_FLAG)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}")
-
-IF(DEBUG_MODE MATCHES "ON")
-       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
-ENDIF(DEBUG_MODE MATCHES "ON")
-
 IF(NOT DESTDIR)
     SET(DESTDIR $ENV{DESTDIR})
 ENDIF(NOT DESTDIR)
index 804ef08b5a6d312fa7d6b0efb9cf1d67126c0dee..eb20d7b5d18c70302810b462931d17f14ac9cb9a 100644 (file)
 #cmakedefine HAVE_MACHINE_ENDIAN_H  1
 #cmakedefine HAVE_SYS_CDEFS_H    1
 
+ #ifdef HAVE_ENDIAN_H
+ #include <endian.h>
+ #else 
+ #ifdef HAVE_SYS_ENDIAN_H
+ #include <sys/endian.h>
+ #else
+ #ifdef HAVE_MACHINE_ENDIAN_H
+ #include <machine/endian.h>
+ #else
+ #define LITTLE_ENDIAN   1234    
+ #define BIG_ENDIAN      4321    
+ #if defined(i386) || defined(__i386) || defined(__amd64) || \
+        defined(BIT_ZERO_ON_RIGHT) || defined(__x86__)
+ #define BYTE_ORDER      LITTLE_ENDIAN
+ #endif
+ #if defined(__sparc) || defined(__sparc__) || defined(__powerpc__)
+ #define BYTE_ORDER      BIG_ENDIAN
+ #endif
+ #endif /* HAVE_MACHINE_ENDIAN_H */
+ #endif /* HAVE_SYS_ENDIAN_H */
+ #endif /* HAVE_ENDIAN_H */
+ #if !defined(BYTE_ORDER) || (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
+         error "Undefined or unknown BYTE_ORDER";
+ #endif
+
+
 #cmakedefine HAVE_SYS_QUEUE_H    1
 #cmakedefine HAVE_SYS_MMAN_H     1
 #cmakedefine HAVE_SYS_SOCKET_H   1
index 12ffaf62e71fe403290a887bc1e69b251e43d844..38674d6e7a2ef48efd1ea78b21fa08d0842f8c9c 100644 (file)
@@ -3,9 +3,12 @@ SET(LIBRSPAMDSRC                         librspamdclient.c ../src/mem_pool.c ../src/upstream.c ../sr
 
 ADD_LIBRARY(rspamdclient SHARED ${LIBRSPAMDSRC})
 ADD_LIBRARY(rspamdclient_static STATIC ${LIBRSPAMDSRC})
-SET_TARGET_PROPERTIES(rspamdclient PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
 SET_TARGET_PROPERTIES(rspamdclient PROPERTIES PUBLIC_HEADER "librspamdclient.h")
+
+IF(CMAKE_COMPILER_IS_GNUCC)
+SET_TARGET_PROPERTIES(rspamdclient PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
 SET_TARGET_PROPERTIES(rspamdclient_static PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing")
+ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 TARGET_LINK_LIBRARIES(rspamdclient ${CMAKE_REQUIRED_LIBRARIES})
 TARGET_LINK_LIBRARIES(rspamdclient pcre)
index ba2a60c6e8187c5311a18a8ee911cae4244d0dbf..526598e6abd67da2d4b0e473ea01c7a5d7aa9150 100644 (file)
--- a/src/dns.h
+++ b/src/dns.h
@@ -146,7 +146,7 @@ struct rspamd_dns_reply {
 struct dns_header {
                guint qid:16;
 
-#if __BYTE_ORDER == BIG_ENDIAN
+#if BYTE_ORDER == BIG_ENDIAN
                guint qr:1;
                guint opcode:4;
                guint aa:1;
index aef7f95d222838559f4f7085b87ea0768631d792..fff890e5964ab94a64a6a3f756bc89f869023df5 100644 (file)
@@ -2,4 +2,8 @@
 SET(EVDNSSRC                     evdns.c)
 
 ADD_LIBRARY(rspamd_evdns STATIC ${EVDNSSRC})
+IF(CMAKE_COMPILER_IS_GNUCC)
 SET_TARGET_PROPERTIES(rspamd_evdns PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -DRSPAMD_LIB")
+ELSE
+SET_TARGET_PROPERTIES(rspamd_evdns PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
+ENDIF(CMAKE_COMPILER_IS_GNUCC)