summaryrefslogtreecommitdiffstats
path: root/tdm/ConfigureChecks.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'tdm/ConfigureChecks.cmake')
-rw-r--r--tdm/ConfigureChecks.cmake84
1 files changed, 79 insertions, 5 deletions
diff --git a/tdm/ConfigureChecks.cmake b/tdm/ConfigureChecks.cmake
index cb5615243..d0080f4f1 100644
--- a/tdm/ConfigureChecks.cmake
+++ b/tdm/ConfigureChecks.cmake
@@ -10,11 +10,19 @@
#################################################
find_library( UTIL_LIBRARY util )
+if( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
+ set( UTIL_LIBRARY "" )
+endif()
check_function_exists( getdomainname HAVE_GETDOMAINNAME )
check_function_exists( initgroups HAVE_INITGROUPS )
check_function_exists( mkstemp HAVE_MKSTEMP )
check_function_exists( setproctitle HAVE_SETPROCTITLE )
+tde_save_and_set( CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE" "-D__BSD_VISIBLE=1" )
+tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "pthread" )
+check_function_exists( pthread_setname_np HAVE_PTHREAD_SETNAME_NP )
+tde_restore( CMAKE_REQUIRED_DEFINITIONS )
+tde_restore( CMAKE_REQUIRED_LIBRARIES )
check_function_exists( sysinfo HAVE_SYSINFO )
check_function_exists( strnlen HAVE_STRNLEN )
check_function_exists( getifaddrs HAVE_GETIFADDRS )
@@ -118,13 +126,79 @@ if( WITH_XDMCP )
endif()
-if( WITH_PAM )
+# If a tdm.service file is wanted, find systemd, then work out which
+# distribution is running, select an appropriate template and create the file.
+# When it is not possible to identify the distribution or there is no specific
+# template is available, use the default of 'tde.service.cmake'. The template
+# can also be set from the command line.
+
+if( BUILD_TDM_SYSTEMD_UNIT_FILE )
+
+ if( NOT SYSTEMDSYSTEMUNITDIR )
+ pkg_search_module( SYSTEMD systemd )
+ if( SYSTEMD_FOUND )
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=systemdsystemunitdir systemd
+ OUTPUT_VARIABLE SYSTEMDSYSTEMUNITDIR
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ endif( )
+ endif( )
+
+ if( "${SYSTEMDSYSTEMUNITDIR}" STREQUAL "" )
+ set( SYSTEMDSYSTEMUNITDIR "/usr/lib/systemd/system" )
+ endif( )
+
+ if( NOT TDM_SERVICE_FILE_TEMPLATE )
+
+ find_program( LSB_RELEASE lsb_release HINTS ENV PATH )
+ unset( _DIST_ID_LIST )
+
+ if( EXISTS "/etc/os-release" )
+
+ file( READ "/etc/os-release" _OS_RELEASE )
+
+ if( "\n${_OS_RELEASE}" MATCHES "\nID=\"*([^\"\n]*)" )
+ set( _DISTRIBUTION "${CMAKE_MATCH_1}" )
+ endif( )
+ if( "\n${_OS_RELEASE}" MATCHES "\nVERSION_ID=\"*([^\\.\"\n]*)" )
+ set( _DIST_VERSION "${CMAKE_MATCH_1}" )
+ endif( )
+ if( "\n${_OS_RELEASE}" MATCHES "\nID_LIKE=\"*([^\\.\"\n]*)" )
+ string( REGEX REPLACE " " ";" _DIST_ID_LIST "${CMAKE_MATCH_1}" )
+ endif( )
+
+ if( _DISTRIBUTION )
+ message( STATUS "Running ${_DISTRIBUTION} distribution, version ${_DIST_VERSION}" )
+ string( TOLOWER "${_DISTRIBUTION}" _DISTRIBUTION )
+ list( INSERT _DIST_ID_LIST 0 "${_DISTRIBUTION}" )
+ endif( )
+
+ foreach( _DIST_ID IN LISTS _DIST_ID_LIST )
+ if( NOT TDM_SERVICE_FILE_TEMPLATE )
+ if( _DIST_VERSION AND
+ EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tdm.service.${_DIST_ID}-${_DIST_VERSION}.cmake" )
+ set( TDM_SERVICE_FILE_TEMPLATE "tdm.service.${_DIST_ID}-${_DIST_VERSION}.cmake" )
+ elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tdm.service.${_DIST_ID}.cmake" )
+ set( TDM_SERVICE_FILE_TEMPLATE "tdm.service.${_DIST_ID}.cmake" )
+ endif( )
+ endif( )
+ endforeach( )
+
+ else( )
+
+ message(STATUS "**WARNING** /etc/os-release was not found. The default template for tdm.service will be used.")
+
+ endif( )
+
+ if( NOT TDM_SERVICE_FILE_TEMPLATE )
+ set( TDM_SERVICE_FILE_TEMPLATE "tdm.service.cmake" )
+ endif( )
- set( USE_PAM 1 CACHE INTERNAL "" FORCE )
+ message( STATUS "tdm.service template file is ${TDM_SERVICE_FILE_TEMPLATE}" )
-elseif( WITH_SHADOW )
+ configure_file( "${TDM_SERVICE_FILE_TEMPLATE}" tdm.service @ONLY )
- set( HAVE_SHADOW 1 CACHE INTERNAL "" FORCE )
- set( USESHADOW 1 CACHE INTERNAL "" FORCE )
+ endif( )
endif( )