-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
151 lines (134 loc) · 6.46 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# SPDX-License-Identifier: MIT
# Copyright (c) 2021-2023, Matthew Madison
cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0048 NEW)
project(tegra_boot_tools LANGUAGES C VERSION 3.1.2)
include(GNUInstallDirs)
set(CMAKE_C_STANDARD 11)
set(SYSTEMD_SYSTEM_UNITDIR "" CACHE PATH "Location for systemd service files")
set(TMPFILESDIR "" CACHE PATH "Location for systemd-tmpfiles config files")
set(LOCK_DIR_GROUP "root" CACHE STRING "Group owner for lock directory")
set(MACHINE "" CACHE STRING "Machine configuration name")
set(ROOTFS_DEVICE "mmcblk0p1" CACHE STRING "Device name for booting rootfs, without /dev")
set(BOOT_DEVICE "/dev/mmcblk0boot0" CACHE PATH "Device where boot partitions are stored")
set(GPT_DEVICE "/dev/mmcblk0boot1" CACHE PATH "Device where pseudo-GPT for boot partitions is stored")
set(EXTENSION_SECTOR_COUNT "15" CACHE STRING "Number of extra 512-byte sectors for boot variable storage")
find_package(PkgConfig REQUIRED)
pkg_check_modules(ZLIB REQUIRED IMPORTED_TARGET zlib)
pkg_check_modules(UUID REQUIRED IMPORTED_TARGET uuid)
pkg_check_modules(TEGRA_EEPROM REQUIRED IMPORTED_TARGET tegra-eeprom)
pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET systemd)
if("${SYSTEMD_SYSTEM_UNITDIR}" STREQUAL "")
pkg_get_variable(SYSTEMD_SYSTEM_UNITDIR systemd systemdsystemunitdir)
endif()
if("${TMPFILESDIR}" STREQUAL "")
pkg_get_variable(TMPFILESDIR systemd tmpfilesdir)
endif()
string(REGEX REPLACE "^/dev/(.*)" "\\1" BOOTDEV_BASE "${BOOT_DEVICE}")
if("${BOOT_DEVICE}" STREQUAL "${GPT_DEVICE}")
set(BOOTDEVS "dev-${BOOTDEV_BASE}.device")
else()
string(REGEX REPLACE "^/dev/(.*)" "\\1" GPTDEV_BASE "${GPT_DEVICE}")
set(BOOTDEVS "dev-${BOOTDEV_BASE}.device dev-${GPTDEV_BASE}.device")
endif()
configure_file(config.h.in config.h @ONLY)
configure_file(tegra-boot-tools.pc.in tegra-boot-tools.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tegra-boot-tools.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
configure_file("config-files/machine-name.conf.in" "config-files/machine-name.conf" @ONLY)
configure_file("config-files/rootfsdev.conf.in" "config-files/rootfsdev.conf" @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/config-files/machine-name.conf
${CMAKE_CURRENT_BINARY_DIR}/config-files/rootfsdev.conf
DESTINATION "${CMAKE_INSTALL_DATADIR}/tegra-boot-tools")
configure_file(config-files/update_bootinfo.service.in config-files/update_bootinfo.service @ONLY)
configure_file(config-files/bootcountcheck.service.in config-files/bootcountcheck.service @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/config-files/update_bootinfo.service
${CMAKE_CURRENT_BINARY_DIR}/config-files/bootcountcheck.service
DESTINATION "${SYSTEMD_SYSTEM_UNITDIR}")
configure_file(config-files/tegra-bootinfo.conf.in config-files/tegra-bootinfo.conf @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config-files/tegra-bootinfo.conf DESTINATION "${TMPFILESDIR}")
add_library(tegra-boot-tools SHARED
smd.c smd.h gpt.c gpt.h bup.c bup.h ver.c ver.h posix-crc32.c posix-crc32.h util.c util.h bootinfo.c bootinfo.h)
set_target_properties(tegra-boot-tools PROPERTIES
VERSION 1.0.0
SOVERSION 1)
target_include_directories(tegra-boot-tools PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/nvidia)
target_link_libraries(tegra-boot-tools PUBLIC PkgConfig::ZLIB PkgConfig::UUID PkgConfig::TEGRA_EEPROM)
target_compile_definitions(tegra-boot-tools PUBLIC "CONFIGPATH=${CMAKE_INSTALL_FULL_DATADIR}/tegra-boot-tools")
target_compile_options(tegra-boot-tools PRIVATE -Wall -Werror)
install(TARGETS tegra-boot-tools LIBRARY)
add_executable(tegra-bootloader-update
tegra-bootloader-update.c
bct_t18x.c
bct_t19x.c
bct_t21x.c
bct.h
nvidia/nvcommon.h
nvidia/t18x/arse0.h
nvidia/t18x/nvboot_crypto_signatures.h
nvidia/t18x/nvboot_se_rsa.h
nvidia/t18x/nvboot_section_defs.h
nvidia/t18x/nvboot_crypto_sha_param.h
nvidia/t18x/nvboot_sdmmc_param.h
nvidia/t18x/nvboot_se_aes.h
nvidia/t18x/nvboot_crypto_aes_param.h
nvidia/t18x/nvboot_ufs_param.h
nvidia/t18x/nvboot_crypto_param.h
nvidia/t18x/nvboot_bct.h
nvidia/t18x/nvboot_crypto_ecc_param.h
nvidia/t18x/nvboot_devparams.h
nvidia/t18x/nvboot_sdram_param.h
nvidia/t18x/nvboot_sdram_param_generated.h
nvidia/t18x/nvboot_util_int.h
nvidia/t18x/nvboot_spi_flash_param.h
nvidia/t18x/nvboot_crypto_se_param.h
nvidia/t18x/nvboot_fuse.h
nvidia/t18x/nvboot_usb3_param.h
nvidia/t18x/nvboot_sata_param.h
nvidia/t18x/nvboot_hash.h
nvidia/t18x/nvboot_se_defs.h
nvidia/t18x/nvboot_error.h
nvidia/t18x/nvboot_config.h
nvidia/t18x/nvboot_crypto_rsa_param.h
nvidia/t19x/arse0.h
nvidia/t19x/nvboot_crypto_signatures.h
nvidia/t19x/nvboot_crypto_public_keystore.h
nvidia/t19x/nvboot_se_rsa.h
nvidia/t19x/nvboot_crypto_eddsa_param.h
nvidia/t19x/nvboot_section_defs.h
nvidia/t19x/nvboot_crypto_sha_param.h
nvidia/t19x/nvboot_sdmmc_param.h
nvidia/t19x/nvboot_se_aes.h
nvidia/t19x/nvboot_crypto_aes_param.h
nvidia/t19x/nvboot_ufs_param.h
nvidia/t19x/nvboot_crypto_param.h
nvidia/t19x/nvboot_bct.h
nvidia/t19x/nvboot_crypto_ecc_param.h
nvidia/t19x/nvboot_devparams.h
nvidia/t19x/nvboot_sdram_param.h
nvidia/t19x/nvboot_sdram_param_generated.h
nvidia/t19x/nvboot_util_int.h
nvidia/t19x/nvboot_spi_flash_param.h
nvidia/t19x/nvboot_crypto_se_param.h
nvidia/t19x/nvboot_fuse.h
nvidia/t19x/nvboot_sata_param.h
nvidia/t19x/nvboot_hash.h
nvidia/t19x/nvboot_se_defs.h
nvidia/t19x/nvboot_error.h
nvidia/t19x/nvboot_config.h
nvidia/t19x/nvboot_crypto_rsa_param.h
nvidia/t19x/nvboot_boot_component.h)
target_include_directories(tegra-bootloader-update PRIVATE nvidia ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(tegra-bootloader-update PUBLIC tegra-boot-tools PkgConfig::TEGRA_EEPROM)
target_compile_options(tegra-bootloader-update PRIVATE -Wall -Werror)
add_executable(tegra-boot-control tegra-boot-control.c)
target_include_directories(tegra-boot-control PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(tegra-boot-control PUBLIC tegra-boot-tools PkgConfig::TEGRA_EEPROM)
target_compile_options(tegra-boot-control PRIVATE -Wall -Werror)
add_executable(tegra-bootinfo tegra-bootinfo.c)
target_include_directories(tegra-bootinfo PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(tegra-bootinfo PUBLIC tegra-boot-tools PkgConfig::ZLIB PkgConfig::TEGRA_EEPROM)
target_compile_options(tegra-bootinfo PRIVATE -Wall -Werror)
install(TARGETS tegra-boot-tools tegra-bootloader-update tegra-boot-control tegra-bootinfo RUNTIME)
install(PROGRAMS scripts/bootcountcheck scripts/nvbootctrl scripts/nv_update_engine TYPE SBIN)