--- CMakeLists.txt.orig	2024-09-12 07:10:44 UTC
+++ CMakeLists.txt
@@ -17,7 +17,6 @@ project (epsonscan2)
 #  CMakeLists.txt -- template and derived ESC/I ESC/I-2 protocol commands
 
 project (epsonscan2)
-set (CMAKE_INSTALL_PREFIX "/usr")
 cmake_minimum_required (VERSION 2.8.12.2)
 
 include(GNUInstallDirs)
@@ -54,6 +53,14 @@ message(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}") 
 message(" Boost_LIBRARIES: ${Boost_LIBRARIES}")  
 message(" Boost_LIBRARY_DIRS: ${Boost_LIBRARY_DIRS}") 
 
+### USB library ##############
+
+if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+set(usb_LIBRARY "usb")
+else()
+set(usb_LIBRARY "usb-1.0")
+endif()
+
 ##############################
 
 #### Dependents package ######
@@ -86,7 +93,11 @@ set(EPSON_SETTINGS_PATH $ENV{HOME}/.epsonscan2/)
 set(EPSON_WORK_PATH /tmp/epsonWork/)
 set(EPSON_SETTINGS_PATH $ENV{HOME}/.epsonscan2/)
 
+if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+set (CMAKE_INSTALL_PREFIX /usr/local)
+else()
 SET (CMAKE_INSTALL_PREFIX /usr)
+endif()
 set(EPSON_INSTALL_PATH ${CMAKE_INSTALL_FULL_LIBDIR}/epsonscan2/)
 set(COMMON_SHARE_PATH ${CMAKE_INSTALL_FULL_DATAROOTDIR})
 
@@ -113,11 +124,19 @@ install(DIRECTORY Resources DESTINATION ${EPSON_INSTAL
 
 install(DIRECTORY Resources DESTINATION ${EPSON_INSTALL_ROOT}${EPSON_INSTALL_PATH})
 
+if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+install(FILES epsonscan2.rules DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d/ RENAME 60-epsonscan2.rules)
+install(FILES epsonscan2 DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/sane.d/dll.d)
+install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{STAGEDIR}${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_FULL_LIBDIR}/sane/)")
+install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../epsonscan2/libsane-epsonscan2.so $ENV{STAGEDIR}${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_FULL_LIBDIR}/sane/libsane-epsonscan2.so.1)")
+install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../epsonscan2/libsane-epsonscan2.so $ENV{STAGEDIR}${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_FULL_LIBDIR}/sane/libsane-epsonscan2.so.1.0.0)")
+else()
 install(FILES epsonscan2.rules DESTINATION ${EPSON_INSTALL_ROOT}/lib/udev/rules.d/ RENAME 60-epsonscan2.rules)
 install(FILES epsonscan2 DESTINATION ${EPSON_INSTALL_ROOT}/etc/sane.d/dll.d)
 install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_FULL_LIBDIR}/sane/)")
 install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../epsonscan2/libsane-epsonscan2.so ${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_FULL_LIBDIR}/sane/libsane-epsonscan2.so.1)")
 install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../epsonscan2/libsane-epsonscan2.so ${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_FULL_LIBDIR}/sane/libsane-epsonscan2.so.1.0.0)")
+endif()
 
 install(FILES changelog.Debian DESTINATION ${EPSON_INSTALL_ROOT}${CMAKE_INSTALL_PREFIX}/share/doc/epsonscan2${EPSON_VERSION})
 
