file(GLOB C_FILES *.c)
file(GLOB PY_FILES *.py)
file(GLOB SH_FILES *.sh)
file(GLOB TXT_FILES *.txt)
list(REMOVE_ITEM TXT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
foreach(FIL ${PY_FILES})
  get_filename_component(FIL_WE ${FIL} NAME_WE)
  install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
endforeach()
foreach(FIL ${SH_FILES})
  if(${FIL} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/reset-trace.sh)
    get_filename_component(FIL_WE ${FIL} NAME_WE)
    install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
  else()
    file(READ ${FIL} CONTENT)
    string(REPLACE ".py -l" " -l" CONTENT_WE ${CONTENT})
    string(REPLACE "\"" "\\\"" CONTENT_WE ${CONTENT_WE})
    get_filename_component(FIL_WE ${FIL} NAME_WE)
    install(PROGRAMS ${FIL} DESTINATION share/bcc/tools RENAME ${FIL_WE})
    install(CODE "file(WRITE \"\$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX}/share/bcc/tools/${FIL_WE}\" \"${CONTENT_WE}\")")
  endif()
endforeach()
install(FILES ${C_FILES} DESTINATION share/bcc/tools)
install(FILES ${TXT_FILES} DESTINATION share/bcc/tools/doc)
add_subdirectory(lib)
add_subdirectory(old)
