build FEATURE add ABI check
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 943b5c4..ece7343 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -149,6 +149,47 @@
         working-directory: ${{ github.workspace }}/build
         run: ctest --output-on-failure
 
+  abi:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Dependencies
+        shell: bash
+        run: |
+          sudo add-apt-repository ppa:kedazo/libssh-0.7.x -y
+          sudo apt-get update
+          sudo apt-get install $DEFAULT_PACKAGES abi-dumper abi-compliance-checker
+          sudo snap install core universal-ctags
+
+          GIT_BRANCH=`echo ${{ github.ref }} | cut -d'/' -f 3`
+          git clone -b $GIT_BRANCH https://github.com/CESNET/libyang.git
+          cd libyang
+          mkdir build
+          cd build
+          CC=gcc cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILD_TESTS=OFF ..
+          make -j2
+          sudo make install
+
+          git clone https://github.com/DNSSEC-Tools/DNSSEC-Tools.git dnssec-tools
+          cd dnssec-tools/dnssec-tools/validator
+          ./configure
+          make -j2
+          sudo make install
+
+      - name: Configure
+        shell: bash
+        working-directory: ${{ github.workspace }}
+        run: |
+          mkdir build
+          cd build
+          CC=gcc cmake -DCMAKE_BUILD_TYPE=ABICheck ..
+
+      - name: Build
+        shell: bash
+        working-directory: ${{ github.workspace }}/build
+        run: LC_ALL=C.UTF-8 PATH=/snap/bin:$PATH make abi-check
+
   coverage:
     runs-on: ubuntu-latest
     steps:
@@ -166,7 +207,7 @@
           cd libyang
           mkdir build
           cd build
-          CC=${{ matrix.config.cc }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build-type }} -DENABLE_BUILD_TESTS=OFF ..
+          CC=gcc cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_BUILD_TESTS=OFF ..
           make -j2
           sudo make install
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76741a1..d2eb90d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@
 include(CheckCSourceCompiles)
 include(CheckIncludeFile)
 include(UseCompat)
+include(ABICheck)
 include(SourceFormat)
 include(GenDoc)
 
@@ -34,15 +35,17 @@
 # normalize build type string
 string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_UPPER)
 if ("${BUILD_TYPE_UPPER}" STREQUAL "RELEASE")
-  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
-elseif ("${BUILD_TYPE_UPPER}" STREQUAL "DEBUG")
-  set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE)
-elseif ("${BUILD_TYPE_UPPER}" STREQUAL "RELWITHDEBINFO")
-  set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build Type" FORCE)
-elseif ("${BUILD_TYPE_UPPER}" STREQUAL "RELWITHDEBUG")
-  set(CMAKE_BUILD_TYPE "RelWithDebug" CACHE STRING "Build Type" FORCE)
-elseif ("${BUILD_TYPE_UPPER}" STREQUAL "DOCONLY")
-  set(CMAKE_BUILD_TYPE "DocOnly" CACHE STRING "Build Type" FORCE)
+    set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
+elseif("${BUILD_TYPE_UPPER}" STREQUAL "DEBUG")
+    set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE)
+elseif("${BUILD_TYPE_UPPER}" STREQUAL "RELWITHDEBINFO")
+    set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build Type" FORCE)
+elseif("${BUILD_TYPE_UPPER}" STREQUAL "RELWITHDEBUG")
+    set(CMAKE_BUILD_TYPE "RelWithDebug" CACHE STRING "Build Type" FORCE)
+elseif("${BUILD_TYPE_UPPER}" STREQUAL "ABICHECK")
+    set(CMAKE_BUILD_TYPE "ABICheck" CACHE STRING "Build Type" FORCE)
+elseif("${BUILD_TYPE_UPPER}" STREQUAL "DOCONLY")
+    set(CMAKE_BUILD_TYPE "DocOnly" CACHE STRING "Build Type" FORCE)
 endif()
 
 # Version of the project
@@ -108,6 +111,7 @@
 set(CMAKE_C_FLAGS           "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_COVERAGE} -Wall -Wextra -fvisibility=hidden -std=gnu99")
 set(CMAKE_C_FLAGS_RELEASE   "-DNDEBUG -O2")
 set(CMAKE_C_FLAGS_DEBUG     "-g -O0")
+set(CMAKE_C_FLAGS_ABICHECK  "-g -Og")
 
 # options
 option(ENABLE_SSH "Enable NETCONF over SSH support (via libssh)" ON)
@@ -149,7 +153,6 @@
 endif()
 
 set(headers
-    ${PROJECT_BINARY_DIR}/src/config.h
     src/log.h
     src/netconf.h
     src/session.h
@@ -279,7 +282,7 @@
 # install headers
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_client.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nc_server.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libnetconf2)
+install(FILES ${headers} ${PROJECT_BINARY_DIR}/src/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libnetconf2)
 
 # install pkg-config file
 find_package(PkgConfig)
@@ -320,6 +323,11 @@
 # generate doxygen documentation for libnetconf2 API
 gen_doc("${doxy_files}" ${LIBNETCONF2_VERSION} ${LIBNETCONF2_DESCRIPTION} "")
 
+# generate API/ABI report
+if ("${BUILD_TYPE_UPPER}" STREQUAL "ABICHECK")
+    lib_abi_check(netconf2 "${headers}" ${LIBNETCONF2_SOVERSION_FULL} a11ddd9f032e0b7bdaa8583c49f4eca168c9c642)
+endif()
+
 # clean cmake cache
 add_custom_target(cleancache
                   COMMAND make clean
diff --git a/CMakeModules/ABICheck.cmake b/CMakeModules/ABICheck.cmake
new file mode 100644
index 0000000..814c5f9
--- /dev/null
+++ b/CMakeModules/ABICheck.cmake
@@ -0,0 +1,66 @@
+# generate API/ABI report
+macro(LIB_ABI_CHECK LIB_TARGET LIB_HEADERS LIB_SOVERSION_FULL ABI_BASE_HASH)
+    # get short hash
+    string(SUBSTRING "${ABI_BASE_HASH}" 0 8 ABI_BASE_HASH_SHORT)
+
+    # find abi-dumper
+    find_program(ABI_DUMPER abi-dumper)
+    find_package_handle_standard_args(abi-dumper DEFAULT_MSG ABI_DUMPER)
+    if(NOT ABI_DUMPER)
+        message(FATAL_ERROR "Program abi-dumper not found!")
+    endif()
+
+    # find abi-checker
+    find_program(ABI_CHECKER abi-compliance-checker)
+    find_package_handle_standard_args(abi-compliance-checker DEFAULT_MSG ABI_CHECKER)
+    if(NOT ABI_CHECKER)
+        message(FATAL_ERROR "Program abi-compliance-checker not found!")
+    endif()
+
+    # abi-dump target - generating an ABI dump
+    set(PUBLIC_HEADERS ${LIB_HEADERS})
+    string(PREPEND PUBLIC_HEADERS "${CMAKE_SOURCE_DIR}/")
+    string(REPLACE ";" "\n${CMAKE_SOURCE_DIR}/" PUBLIC_HEADERS "${PUBLIC_HEADERS}")
+    file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/public_headers CONTENT "${PUBLIC_HEADERS}")
+    add_custom_target(abi-dump
+            COMMAND ${ABI_DUMPER} ./lib${LIB_TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX}
+            -o lib${LIB_TARGET}.${LIB_SOVERSION_FULL}.dump
+            -lver ${LIB_SOVERSION_FULL} -public-headers ${CMAKE_BINARY_DIR}/public_headers
+            DEPENDS ${LIB_TARGET}
+            BYPRODUCTS ${CMAKE_BINARY_DIR}/lib${LIB_TARGET}.${LIB_SOVERSION_FULL}.dump
+            WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+            COMMENT "Dumping ABI information of version ${LIB_SOVERSION_FULL} for abi-check")
+
+    # get URL for fetching origin
+    execute_process(COMMAND git remote get-url origin OUTPUT_VARIABLE ORIGIN_URL OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+    # generate script for generating the base ABI dump
+    file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/abibase.sh CONTENT "#!/bin/sh
+if [ ! -d abibase ]; then mkdir abibase; fi
+cd abibase
+if [ ! -f build/lib${LIB_TARGET}.*.dump ]; then
+    if [ -d .git ] && [ \"${ABI_BASE_HASH}\" != \"`git log --pretty=oneline | cut -d' ' -f1`\" ]; then rm -rf .* 2> /dev/null; fi
+    if [ ! -d .git ]; then
+        git init --initial-branch=master
+        git remote add origin ${ORIGIN_URL}
+        git fetch origin --depth 1 ${ABI_BASE_HASH}
+        git reset --hard FETCH_HEAD
+    fi
+    if [ ! -d build ]; then mkdir build; fi
+    cd build
+    cmake -DCMAKE_BUILD_TYPE=ABICheck ..
+    make abi-dump
+fi
+")
+
+    # abi-check target - check ABI compatibility of current version and the base hash version
+    add_custom_target(abi-check
+            COMMAND bash ./abibase.sh
+            COMMAND ${ABI_CHECKER} -l lib${LIB_TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX}
+            -old abibase/build/lib${LIB_TARGET}.*.dump
+            -new ./lib${LIB_TARGET}.${LIB_SOVERSION_FULL}.dump -s
+            DEPENDS ${LIB_TARGET} abi-dump
+            BYPRODUCTS ${CMAKE_BINARY_DIR}/compat_reports/lib${LIB_TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX}/*_to_${LIB_SOVERSION_FULL}/compat_report.html
+            WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+            COMMENT "Checking ABI compatibility of version ${LIB_SOVERSION_FULL} and revision ${ABI_BASE_HASH_SHORT}")
+endmacro()