summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
diff options
context:
space:
mode:
authorDenis Kozadaev <denis@dilos.org>2023-06-06 21:15:57 +0300
committerDenis Kozadaev <denis@dilos.org>2023-06-20 11:17:21 +0300
commit3c23abfd84440d769bc20707e04cb356ddb48c1a (patch)
tree183d393557f700ae20f7121ec4b5a9da4c9e8e13 /ConfigureChecks.cmake
parentdc8852cc1d6b347fe4681ef24f31732c6d96bb8b (diff)
downloadtdebase-3c23abfd84440d769bc20707e04cb356ddb48c1a.tar.gz
tdebase-3c23abfd84440d769bc20707e04cb356ddb48c1a.zip
Find power related system tools instead of hardcode them
Signed-off-by: Denis Kozadaev <denis@dilos.org>
Diffstat (limited to 'ConfigureChecks.cmake')
-rw-r--r--ConfigureChecks.cmake86
1 files changed, 86 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 926b29a43..244a6e48a 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -593,6 +593,92 @@ if( BUILD_KCONTROL OR BUILD_TDM )
endif()
set( KSTAT_LIBRARIES "" )
endif( )
+
+ if( NOT DEFINED REBOOT_BINARY )
+ message( STATUS "Looking for reboot" )
+ find_program( REBOOT_BINARY reboot
+ HINTS /sbin
+ /usr/sbin
+ )
+ if( REBOOT_BINARY )
+ message( STATUS "Looking for reboot - ${REBOOT_BINARY}" )
+ endif( REBOOT_BINARY )
+ endif( NOT DEFINED REBOOT_BINARY )
+
+ if( NOT DEFINED POWEROFF_BINARY )
+ message( STATUS "Looking for poweroff" )
+ find_program( POWEROFF_BINARY poweroff
+ HINTS /sbin
+ /usr/sbin
+ )
+ if( POWEROFF_BINARY )
+ message( STATUS "Looking for poweroff - ${POWEROFF_BINARY}" )
+ endif( POWEROFF_BINARY )
+ endif( NOT DEFINED POWEROFF_BINARY )
+
+ if( NOT DEFINED HALT_BINARY )
+ message( STATUS "Looking for halt" )
+ find_program( HALT_BINARY halt
+ HINTS /sbin
+ /usr/sbin
+ )
+ if( HALT_BINARY )
+ message( STATUS "Looking for halt - ${HALT_BINARY}" )
+ endif( HALT_BINARY )
+ endif( NOT DEFINED HALT_BINARY )
+
+ if( NOT DEFINED SHUTDOWN_BINARY )
+ message( STATUS "Looking for shutdown" )
+ find_program( SHUTDOWN_BINARY shutdown
+ HINTS /sbin
+ /usr/sbin
+ )
+ if( SHUTDOWN_BINARY )
+ message( STATUS "Looking for shutdown - ${SHUTDOWN_BINARY}" )
+ endif( SHUTDOWN_BINARY )
+ endif( NOT DEFINED SHUTDOWN_BINARY )
+
+ if( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
+ # SunOS based systems
+ if( NOT REBOOT_BINARY AND SHUTDOWN_BINARY )
+ # emulate reboot
+ set( REBOOT_BINARY "${SHUTDOWN_BINARY} -y -i 6")
+ endif( NOT REBOOT_BINARY AND SHUTDOWN_BINARY )
+
+ if( NOT POWEROFF_BINARY AND SHUTDOWN_BINARY )
+ # emulate poweroff
+ set( POWEROFF_BINARY "${SHUTDOWN_BINARY} -y -i 5")
+ endif( NOT POWEROFF_BINARY AND SHUTDOWN_BINARY )
+
+ else( ) # default condition
+ if( NOT REBOOT_BINARY AND SHUTDOWN_BINARY )
+ # emulate reboot
+ set( REBOOT_BINARY "${SHUTDOWN_BINARY} -r now")
+ endif( NOT REBOOT_BINARY AND SHUTDOWN_BINARY )
+
+ if( NOT POWEROFF_BINARY AND SHUTDOWN_BINARY )
+ # emulate poweroff
+ set( POWEROFF_BINARY "${SHUTDOWN_BINARY} -h now")
+ endif( NOT POWEROFF_BINARY AND SHUTDOWN_BINARY )
+
+ if( NOT POWEROFF_BINARY AND HALT_BINARY )
+ # emulate poweroff
+ set( POWEROFF_BINARY "${HALT_BINARY} -p")
+ endif( NOT POWEROFF_BINARY AND HALT_BINARY )
+
+ endif( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
+
+ if( NOT REBOOT_BINARY )
+ tde_message_fatal( "reboot command is not defined" )
+ endif( NOT REBOOT_BINARY )
+
+ if( NOT POWEROFF_BINARY )
+ tde_message_fatal( "poweroff command is not defined" )
+ endif( NOT POWEROFF_BINARY )
+
+ message( STATUS "poweroff - ${POWEROFF_BINARY}" )
+ message( STATUS "reboot - ${REBOOT_BINARY}" )
+
endif( BUILD_KCONTROL OR BUILD_TDM )
check_include_files( "sys/time.h;sys/loadavg.h" HAVE_SYS_LOADAVG_H )