#-----------------------------------------------------------------------------
#
# Copyright (C) 2012 - 2025  Florian Pose <fp@igh.de>
#               2022         Bjarne von Horn <vh at igh dot de>
#
# This file is part of the data logging service (DLS).
#
# DLS is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# DLS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the DLS. If not, see <http://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------

set(BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
configure_file(dls.service.in "${CMAKE_CURRENT_BINARY_DIR}/dls.service" @ONLY)
configure_file(dls_quota.service.in "${CMAKE_CURRENT_BINARY_DIR}/dls_quota.service" @ONLY)
configure_file(profile.sh.in "${CMAKE_CURRENT_BINARY_DIR}/profile.sh" @ONLY)

if(DLSD_INSTALL_SERVICE)
    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dls.service" DESTINATION "${DLSD_INSTALL_SERVICE}")
    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dls_quota.service" DESTINATION "${DLSD_INSTALL_SERVICE}")
    install(FILES dls_quota.timer DESTINATION "${DLSD_INSTALL_SERVICE}")
endif()

install(PROGRAMS dls_quota.pl DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME dls_quota)
install(PROGRAMS dls_status.pl DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME dls_status)
install(
    FILES "${CMAKE_CURRENT_BINARY_DIR}/profile.sh"
    DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/profile.d"
    RENAME dls.sh
)
install(FILES sysconfig DESTINATION "${DLS_ENVIRONMENT_FILE_LOCATION}" RENAME dls)
