commit 9f38e25adf0c17309e132485dc8a4cc62fa86d8a
Author: Filippos Giannakos <philipgian@grnet.gr>
Date:   Mon Feb 24 13:31:52 2014 +0200

    xseg: Derive xseg version from MAJOR, MINOR library version

diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 2ae086b..71ebbfc 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -50,6 +50,7 @@ set(ENV "env")
 set(H2XML_FLAGS "-c")
 set(H2XML_DEPS "")
 set(H2XML_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../src/include")
+set(H2XML_INCLUDE_DIR2 "${CMAKE_CURRENT_BINARY_DIR}/../src/include")
 
 set(H2XML_OUTPUT_XSEG "${CMAKE_CURRENT_BINARY_DIR}/xseg.xml")
 set(H2XML_INPUT_XSEG "${CMAKE_CURRENT_SOURCE_DIR}/../src/include/xseg/xseg.h")
@@ -89,13 +90,13 @@ ADD_CUSTOM_COMMAND( OUTPUT ${H2XML_OUTPUT_XSEG} ${H2XML_OUTPUT_PROTOCOL} ${XML2P
 	            COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/xseg
 		    COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/xseg/__init__.py
 
-                    COMMAND ${H2XML} ${H2XML_FLAGS} -I ${H2XML_INCLUDE_DIR} -o ${H2XML_OUTPUT_XSEG} ${H2XML_INPUT_XSEG}
+		    COMMAND ${H2XML} ${H2XML_FLAGS} -I ${H2XML_INCLUDE_DIR} -I ${H2XML_INCLUDE_DIR2} -o ${H2XML_OUTPUT_XSEG} ${H2XML_INPUT_XSEG}
 		    COMMAND ${ENV} ${XML2PY_ENV} ${XML2PY} ${H2XML_OUTPUT_XSEG} -d -k defst -c -l ${XSEG_LIB} -o ${XML2PY_OUTPUT_XSEG}
 		    COMMAND ${SED1}
 		    COMMAND ${SED2}
 		    COMMAND ${SED3}
 
-                    COMMAND ${H2XML} ${H2XML_FLAGS} -I ${H2XML_INCLUDE_DIR} -o ${H2XML_OUTPUT_PROTOCOL} ${H2XML_INPUT_PROTOCOL}
+		    COMMAND ${H2XML} ${H2XML_FLAGS} -I ${H2XML_INCLUDE_DIR} -I ${H2XML_INCLUDE_DIR2} -o ${H2XML_OUTPUT_PROTOCOL} ${H2XML_INPUT_PROTOCOL}
 		    COMMAND ${ENV} ${XML2PY_ENV} ${XML2PY}
 		    ${H2XML_OUTPUT_PROTOCOL} -d -k defst -c -l ${XSEG_LIB} -o ${XML2PY_OUTPUT_PROTOCOL}
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d4f5d67..e72c33f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -69,7 +69,11 @@ set(CMAKE_C_FLAGS  "-O2 -finline -march=nocona -Wall -std=gnu99 -pedantic -g -rd
 #add_subdirectory(exports)
 
 
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/xseg/version.h.in
+	${CMAKE_CURRENT_BINARY_DIR}/include/xseg/version.h)
+
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 set(xseg_srcs xseg.c initialize.c xseg_posix.c xseg_pthread.c xseg_posixfd.c
 	xseg_user.c xtypes/xcache.c xtypes/xbinheap.c xtypes/xhash.c
@@ -98,7 +102,8 @@ SET_TARGET_PROPERTIES(
 INSTALL_TARGETS(/lib xseg)
 INSTALL_TARGETS(/bin xseg-tool)
 #INSTALL_FILES(/include )
-INSTALL(DIRECTORY include DESTINATION /usr)
+INSTALL(DIRECTORY include DESTINATION /usr FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include DESTINATION /usr)
 #install(FILES libxseg0.so DESTINATION $DESTDIR/usr/lib/)
 #install(FILES libxseg0.so.${MAJOR} DESTINATION $DESTDIR/usr/lib/)
 #install(FILES libxseg0.so.${MAJOR}.${MINOR} DESTINATION $DESTDIR/usr/lib/)
diff --git a/src/include/xseg/version.h.in b/src/include/xseg/version.h.in
new file mode 100644
index 0000000..b21e1bf
--- /dev/null
+++ b/src/include/xseg/version.h.in
@@ -0,0 +1,10 @@
+#ifndef XSEG_VERSION_H
+
+#define XSEG_VERSION_H
+
+#define XSEG_MAJOR ((uint64_t)${MAJOR})
+#define XSEG_MINOR ((uint64_t)${MINOR})
+
+#define XSEG_VERSION ((uint64_t)((XSEG_MAJOR << 48) + (XSEG_MINOR << 16)) + 0)
+
+#endif /* XSEG_VERSION_H */
diff --git a/src/include/xseg/xseg.h b/src/include/xseg/xseg.h
index a09ffb4..e4fa4ab 100644
--- a/src/include/xseg/xseg.h
+++ b/src/include/xseg/xseg.h
@@ -35,10 +35,6 @@
 #ifndef _XSEG_H
 #define _XSEG_H
 
-#ifndef XSEG_VERSION
-#define XSEG_VERSION 2012022601
-#endif
-
 #ifndef XSEG_PAGE_SHIFT
 #define XSEG_PAGE_SHIFT 12
 #endif
@@ -53,6 +49,7 @@
 
 #include <stdint.h>
 #include <sys/time.h>
+#include <xseg/version.h>
 #include <xseg/util.h>
 #include <xseg/xq.h>
 #include <xseg/xobj.h>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b230d34..67b1868 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -36,6 +36,7 @@ cmake_minimum_required(VERSION 2.8)
 project (xseg_tests)
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src/include)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src/include)
 
 add_executable(xbinheap_test xbinheap_test.c)
 target_link_libraries(xbinheap_test xseg)
