+PKG_CHECK_MODULES(json-c REQUIRED json-c)
+
+CHECK_INCLUDE_FILES(magic.h HAVE_MAGIC_H)
+CHECK_LIBRARY_EXISTS(magic magic_load "" HAVE_LIBMAGIC_SO)
+IF(HAVE_MAGIC_H)
+ IF(HAVE_LIBMAGIC_SO)
+ SET(HAVE_LIBMAGIC "1")
+ SET(LIBMAGIC_LDFLAGS -lmagic)
+ ENDIF(HAVE_LIBMAGIC_SO)
+ENDIF(HAVE_MAGIC_H)
+
+PKG_CHECK_MODULES(libsystemd libsystemd>=222)
+PKG_CHECK_MODULES(libmicrohttpd libmicrohttpd>=0.9.60)
+PKG_CHECK_MODULES(openssl openssl)
+PKG_CHECK_MODULES(uuid uuid)
+PKG_CHECK_MODULES(cynara cynara-client)
+
+ADD_DEFINITIONS("-DAFS_SUPERVISION_SOCKET=\"${AFS_SUPERVISION_SOCKET}\"")
+ADD_DEFINITIONS("-DAFS_SUPERVISOR_TOKEN=\"${AFS_SUPERVISOR_TOKEN}\"")
+ADD_DEFINITIONS("-DAFS_SUPERVISOR_PORT=${AFS_SUPERVISOR_PORT}")
+
+IF(cynara_FOUND)
+ ADD_DEFINITIONS(-DBACKEND_PERMISSION_IS_CYNARA)
+ENDIF(cynara_FOUND)
+
+IF(HAVE_LIBMAGIC AND libsystemd_FOUND AND libmicrohttpd_FOUND AND openssl_FOUND AND uuid_FOUND)
+ ADD_DEFINITIONS(-DUSE_MAGIC_MIME_TYPE)
+ELSE()
+ IF(NOT HAVE_LIBMAGIC)
+ MESSAGE(WARNING "\"magic.h\" or \"libmagic.so\" missing.
+ Please install the \"file-devel\" or \"libmagic-dev\" package !")
+ ENDIF(NOT HAVE_LIBMAGIC)
+ IF(NOT libsystemd_FOUND)
+ MESSAGE(WARNING "Dependency to 'libsystemd' is missing")
+ ENDIF()
+ IF(NOT libmicrohttpd_FOUND)
+ MESSAGE(WARNING "Dependency to 'libmicrohttpd' is missing")
+ ENDIF()
+ IF(NOT openssl_FOUND)
+ MESSAGE(WARNING "Dependency to 'openssl' is missing")
+ ENDIF()
+ IF(NOT uuid_FOUND)
+ MESSAGE(WARNING "Dependency to 'uuid' is missing")
+ ENDIF()
+ IF(NOT ONLY_DEVTOOLS)
+ MESSAGE(FATAL_ERROR "Can't compile the binder, either define ONLY_DEVTOOLS or install dependencies")
+ ENDIF()
+ENDIF()
+
+ADD_DEFINITIONS(-DAFB_VERSION="${PROJECT_VERSION}")
+
+INCLUDE_DIRECTORIES(