<commit_before># ty, command-line program to manage Teensy devices
# http://github.com/Koromix/ty
# Copyright (C) 2014 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 2.8)
project(ty C)

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
    find_package(PkgConfig REQUIRED)
    pkg_check_modules(LIBUDEV REQUIRED libudev)

    include_directories(${LIBUDEV_INCLUDE_DIRS})
    list(APPEND LIBRARIES ${LIBUDEV_LIBRARIES})
endif()

if(WIN32)
    list(APPEND LIBRARIES setupapi hid)
endif()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
    set(CMAKE_COMPILER_IS_CLANG 1)
endif()

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
    set(CMAKE_C_FLAGS "-std=gnu99 -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wshadow -Wconversion -Wformat=2")

    if(CMAKE_COMPILER_IS_GNUCC)
        set(CMAKE_C_FLAGS_DEBUG "-Og -ggdb -D_FORTIFY_SOURCE=2")
    else()
        set(CMAKE_C_FLAGS_DEBUG "-O1 -g -D_FORTIFY_SOURCE=2")
    endif()
    set(CMAKE_C_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2")
endif()

if(WIN32)
    add_definitions(-DWINVER=0x0600 -D_WIN32_WINNT=0x0600)
endif()

set(EXPERIMENTAL OFF CACHE BOOL "Build experimental and unsafe features")
if(EXPERIMENTAL)
    add_definitions(-DTY_EXPERIMENTAL=1)
endif()

include(CheckSymbolExists)
check_symbol_exists(stpcpy string.h HAVE_STPCPY)
check_symbol_exists(asprintf stdio.h HAVE_ASPRINTF)

configure_file(src/config.h.in src/config.h)

include_directories(include include/ty "${CMAKE_CURRENT_BINARY_DIR}/src")

set(SOURCES include/ty.h
            include/ty/board.h
            include/ty/common.h
            include/ty/device.h
            include/ty/firmware.h
            include/ty/list.h
            include/ty/system.h

            src/board.c
            src/common.c
            src/compat.c
            src/device.c
            src/device_priv.h
            src/firmware.c
            src/firmware_ihex.c
            src/system.c

            cli/list.c
            cli/main.c
            cli/monitor.c
            cli/reset.c
            cli/upload.c)
if(WIN32)
    list(APPEND SOURCES src/system_win32.c
                        src/device_win32.c)
else()
    list(APPEND SOURCES src/system_unix.c
                        src/system_linux.c
                        src/device_linux.c
                        src/device_unix.c)
endif()

add_executable(ty ${SOURCES})
target_link_libraries(ty ${LIBRARIES})

install(TARGETS ty RUNTIME DESTINATION bin)
install(FILES data/udev/teensy.rules DESTINATION /lib/udev/rules.d RENAME 49-teensy.rules)<commit_msg>Fix broken cmake install due to data/udev/teensy.rules<commit_after># ty, command-line program to manage Teensy devices
# http://github.com/Koromix/ty
# Copyright (C) 2014 Niel<NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 2.8)
project(ty C)

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
    find_package(PkgConfig REQUIRED)
    pkg_check_modules(LIBUDEV REQUIRED libudev)

    include_directories(${LIBUDEV_INCLUDE_DIRS})
    list(APPEND LIBRARIES ${LIBUDEV_LIBRARIES})
endif()

if(WIN32)
    list(APPEND LIBRARIES setupapi hid)
endif()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
    set(CMAKE_COMPILER_IS_CLANG 1)
endif()

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
    set(CMAKE_C_FLAGS "-std=gnu99 -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wshadow -Wconversion -Wformat=2")

    if(CMAKE_COMPILER_IS_GNUCC)
        set(CMAKE_C_FLAGS_DEBUG "-Og -ggdb -D_FORTIFY_SOURCE=2")
    else()
        set(CMAKE_C_FLAGS_DEBUG "-O1 -g -D_FORTIFY_SOURCE=2")
    endif()
    set(CMAKE_C_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2")
endif()

if(WIN32)
    add_definitions(-DWINVER=0x0600 -D_WIN32_WINNT=0x0600)
endif()

set(EXPERIMENTAL OFF CACHE BOOL "Build experimental and unsafe features")
if(EXPERIMENTAL)
    add_definitions(-DTY_EXPERIMENTAL=1)
endif()

include(CheckSymbolExists)
check_symbol_exists(stpcpy string.h HAVE_STPCPY)
check_symbol_exists(asprintf stdio.h HAVE_ASPRINTF)

configure_file(src/config.h.in src/config.h)

include_directories(include include/ty "${CMAKE_CURRENT_BINARY_DIR}/src")

set(SOURCES include/ty.h
            include/ty/board.h
            include/ty/common.h
            include/ty/device.h
            include/ty/firmware.h
            include/ty/list.h
            include/ty/system.h

            src/board.c
            src/common.c
            src/compat.c
            src/device.c
            src/device_priv.h
            src/firmware.c
            src/firmware_ihex.c
            src/system.c

            cli/list.c
            cli/main.c
            cli/monitor.c
            cli/reset.c
            cli/upload.c)
if(WIN32)
    list(APPEND SOURCES src/system_win32.c
                        src/device_win32.c)
else()
    list(APPEND SOURCES src/system_unix.c
                        src/system_linux.c
                        src/device_linux.c
                        src/device_unix.c)
endif()

add_executable(ty ${SOURCES})
target_link_libraries(ty ${LIBRARIES})

install(TARGETS ty RUNTIME DESTINATION bin)
install(FILES contrib/udev/teensy.rules DESTINATION /lib/udev/rules.d RENAME 49-teensy.rules)
{'fraction_non_alphanumeric': 0.09035004730368969, 'fraction_numerical': 0.012929675181330811, 'mean_word_length': 2.964375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4959421', 'n_tokens_mistral': 2296, 'n_tokens_neox': 2137, 'n_words': 495}