]> git.openstreetmap.org Git - nominatim.git/commitdiff
BSD compat: use sys/endian.h if available
authorMelvyn Sopacua <m.r.sopacua@gmail.com>
Mon, 13 Feb 2017 13:30:48 +0000 (14:30 +0100)
committerMelvyn Sopacua <m.r.sopacua@gmail.com>
Mon, 13 Feb 2017 13:30:48 +0000 (14:30 +0100)
<byteswap.h> is a linuxism. On BSD-like systems this is <sys/endian.h>

nominatim/CMakeLists.txt
nominatim/postgresql.h

index 53b5073bb7dadc414a80796197552b3760f679f1..726ec4cc3007a1d8918bf2994b505e285eb9bcae 100644 (file)
@@ -1,4 +1,12 @@
 add_executable(nominatim export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c)
-
+include(CheckIncludeFile)
+CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
+CHECK_INCLUDE_FILE(sys/endian.h HAVE_SYS_ENDIAN_H)
+if(HAVE_BYTESWAP_H)
+  target_compile_definitions(nominatim PRIVATE HAVE_BYTESWAP_H)
+endif(HAVE_BYTESWAP_H)
+if(HAVE_SYS_ENDIAN_H)
+  target_compile_definitions(nominatim PRIVATE HAVE_SYS_ENDIAN_H)
+endif(HAVE_SYS_ENDIAN_H)
 target_link_libraries(nominatim ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PostgreSQL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
index 6a14e94e6ea56d33e2fd038979b677b0be601e04..7050fca4ed7302399097b4bbf262b32b38a2e5ec 100644 (file)
@@ -7,7 +7,11 @@
 #define PG_OID_INT8                    20
 #define PG_OID_INT4                    23
 
+#if defined(HAVE_BYTESWAP_H)
 #include <byteswap.h>
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#endif
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 #define PGint16(x)     (x)