diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-10-17 14:19:38 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-10-17 14:19:38 +0300 |
commit | 96e14f0474571c1c27164ff79a16413de9b3027a (patch) | |
tree | 150f67f2f8d97521e3a3e535718a53629e48002f | |
parent | b441439d550de340e892903b1309fb35bfba6312 (diff) | |
download | rspamd-96e14f0474571c1c27164ff79a16413de9b3027a.tar.gz rspamd-96e14f0474571c1c27164ff79a16413de9b3027a.zip |
Fix build under Solaris10. Reported in https://bitbucket.org/vstakhov/rspamd/issue/21/rspamd-solaris10-x86-openindiana
-rw-r--r-- | CMakeLists.txt | 157 | ||||
-rw-r--r-- | config.h.in | 30 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/dns.h | 2 | ||||
-rw-r--r-- | src/evdns/CMakeLists.txt | 4 |
5 files changed, 137 insertions, 61 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ae042706a..5b15eb667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/config.h.in b/config.h.in index 804ef08b5..eb20d7b5d 100644 --- a/config.h.in +++ b/config.h.in @@ -58,6 +58,36 @@ #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 diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 12ffaf62e..38674d6e7 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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) @@ -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; diff --git a/src/evdns/CMakeLists.txt b/src/evdns/CMakeLists.txt index aef7f95d2..fff890e59 100644 --- a/src/evdns/CMakeLists.txt +++ b/src/evdns/CMakeLists.txt @@ -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) |