-SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
-
-INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
-
-FIND_PACKAGE(EXPAT REQUIRED)
-FIND_LIBRARY(RPMDB_LIBRARY NAMES rpmdb)
-FIND_LIBRARY(ZLIB_LIBRARY NAMES z)
-
-SET( PACKAGE "satsolver" )
-SET( VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}.${LIBSATSOLVER_PATCH}" )
-
-ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
-ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
-
-SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "mls solver")
-SET(CPACK_PACKAGE_VENDOR "Novell Inc.")
-SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBSATSOLVER_MAJOR})
-SET(CPACK_PACKAGE_VERSION_MINOR ${LIBSATSOLVER_MINOR})
-SET(CPACK_PACKAGE_VERSION_PATCH ${LIBSATSOLVER_PATCH})
-SET( CPACK_GENERATOR "TBZ2")
-SET( CPACK_SOURCE_GENERATOR "TBZ2")
-SET( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
+SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
+INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
+
+INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
+
+FIND_PACKAGE (EXPAT REQUIRED)
+FIND_PACKAGE (ZLIB REQUIRED)
+
+IF (FEDORA)
+MESSAGE(STATUS "Building for Fedora")
+ADD_DEFINITIONS (-DFEDORA)
+SET (ENABLE_RPMDB ON)
+SET (ENABLE_RPMMD ON)
+ENDIF (FEDORA)
+
+IF (DEBIAN)
+MESSAGE (STATUS "Building for Debian")
+ADD_DEFINITIONS (-DDEBIAN -DDEBIAN_SEMANTICS)
+SET (ENABLE_DEBIAN ON)
+ENDIF (DEBIAN)
+
+IF (RPM5)
+MESSAGE (STATUS "Enabling RPM 5 support")
+ADD_DEFINITIONS (-DRPM5)
+SET (ENABLE_RPMDB ON)
+SET (ENABLE_RPMMD ON)
+FIND_PACKAGE (PkgConfig REQUIRED)
+PKG_CHECK_MODULES (RPM REQUIRED rpm)
+INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
+ENDIF (RPM5)
+
+IF (MULTI_SEMANTICS)
+MESSAGE (STATUS "Enabling multi dist support")
+ADD_DEFINITIONS (-DMULTI_SEMANTICS)
+ENDIF (MULTI_SEMANTICS)
+
+# compat: enable some database types
+IF (NOT ENABLE_RPMDB AND
+ NOT ENABLE_RPMMD AND
+ NOT ENABLE_SUSEREPO AND
+ NOT ENABLE_HELIXREPO AND
+ NOT ENABLE_DEBIAN)
+ SET (ENABLE_RPMDB ON)
+ SET (ENABLE_RPMDB_PUBKEY ON)
+ SET (ENABLE_RPMMD ON)
+ SET (ENABLE_SUSEREPO ON)
+ SET (ENABLE_HELIXREPO ON)
+ SET (ENABLE_DEBIAN ON)
+ENDIF ()
+
+IF (ENABLE_RPMDB)
+ FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
+
+ IF (NOT RPMDB_LIBRARY)
+ FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
+ ENDIF (NOT RPMDB_LIBRARY)
+
+ FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
+ IF (RPMIO_LIBRARY)
+ SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
+ ENDIF (RPMIO_LIBRARY)
+
+ IF (RPM5)
+ FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
+ IF (RPMMISC_LIBRARY)
+ SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
+ ENDIF (RPMMISC_LIBRARY)
+ ENDIF (RPM5)
+
+ IF (RPM5 OR FEDORA)
+ FIND_LIBRARY (DB_LIBRARY NAMES db)
+ IF (DB_LIBRARY)
+ SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
+ ENDIF (DB_LIBRARY)
+ ENDIF (RPM5 OR FEDORA)
+ENDIF (ENABLE_RPMDB)
+
+INCLUDE (CheckFunctionExists)
+INCLUDE (TestBigEndian)
+
+CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
+CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
+CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
+TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
+
+# should create config.h with #cmakedefine instead...
+FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
+ ENABLE_RPMDB ENABLE_RPMDB_PUBKEY ENABLE_RPMMD ENABLE_SUSEREPO ENABLE_COMPS
+ ENABLE_HELIXREPO ENABLE_DEBIAN)
+ IF(${VAR})
+ ADD_DEFINITIONS (-D${VAR}=1)
+ SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
+ ENDIF (${VAR})
+ENDFOREACH (VAR)
+
+SET (PACKAGE "libsolv")
+SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
+
+ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
+ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
+CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
+
+SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
+SET (CPACK_PACKAGE_VENDOR "SUSE")
+SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
+SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
+SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
+SET (CPACK_GENERATOR "TBZ2")
+SET (CPACK_SOURCE_GENERATOR "TBZ2")
+SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
+SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
+SET (CPACK_TOPLEVEL_TAG "Linux-Source:")