-
-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
216 lines (197 loc) · 6.03 KB
/
Copy pathCMakeLists.txt
File metadata and controls
216 lines (197 loc) · 6.03 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
cmake_minimum_required(VERSION 3.10)
project(ipctool C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "-std=gnu99")
# sensors.c serialises sensor detection with a pthread mutex. On musl and
# glibc >= 2.34 the pthread symbols live in libc, but older glibc and uClibc
# need the explicit link flag, so ask for it rather than rely on the toolchain.
find_package(Threads REQUIRED)
cmake_policy(SET CMP0069 NEW)
if(NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_C_FLAGS "-static ${CMAKE_C_FLAGS}")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -s -Os -ffunction-sections -Wl,--gc-sections -DNDEBUG -Wextra")
else()
if(BUILD_SHARED_LIBS)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -O1 -g -fno-omit-frame-pointer")
endif()
endif()
if(NOT SKIP_VERSION)
set(VERSION_SRC ${CMAKE_CURRENT_BINARY_DIR}/version.c)
# Add a custom command that produces version.c, plus a dummy output that's not
# actually produced, in order to force version.cmake to always be re-run
# before the build
add_custom_command(
OUTPUT ${VERSION_SRC} ${CMAKE_CURRENT_BINARY_DIR}/_version.c
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake)
else()
add_definitions(-DSKIP_VERSION)
endif()
include_directories(./src/)
# Vendor HALs are only reachable through the detection table in chipid.c, so a
# consumer that already knows its SoC family can drop the ones it can never run
# on. The HiSilicon HAL stays in unconditionally — chipid.c dispatches to it
# directly rather than through the table. Affects libipchw only; the ipctool
# executable is a diagnostic tool and always carries every vendor.
set(IPCHW_OPTIONAL_VENDORS
allwinner bcm fh gm ingenic novatek rockchip sstar tegra xilinx xm)
set(IPCHW_VENDORS "all" CACHE STRING
"Vendor HALs to compile into libipchw: 'all', 'none', or a ;-separated \
subset of: ${IPCHW_OPTIONAL_VENDORS}")
if(IPCHW_VENDORS STREQUAL "all")
set(_ipchw_selected ${IPCHW_OPTIONAL_VENDORS})
elseif(IPCHW_VENDORS STREQUAL "none")
set(_ipchw_selected "")
else()
set(_ipchw_selected ${IPCHW_VENDORS})
endif()
set(COMMON_LIB_SRC_BASE
src/chipid.c
src/chipid.h
src/cjson/cJSON.c
src/cjson/cJSON.h
src/hal/common.c
src/hal/common.h
src/hal/hisi/hal_hisi.c
src/hal/hisi/hal_hisi.h
src/hal/hisi/ispreg.c
src/hwinfo.c
src/hwinfo.h
src/mmap.h
src/sensors.c
src/sensors.h
src/tools.c
src/tools.h
src/version.h)
# Full set, used by the ipctool executable
set(COMMON_LIB_SRC_ALL ${COMMON_LIB_SRC_BASE})
foreach(_v IN LISTS IPCHW_OPTIONAL_VENDORS)
list(APPEND COMMON_LIB_SRC_ALL src/hal/${_v}.c src/hal/${_v}.h)
string(TOUPPER ${_v} _V)
list(APPEND IPCHW_ALL_VENDOR_DEFS IPCHW_VENDOR_${_V})
endforeach()
# Selected subset, used by libipchw
set(COMMON_LIB_SRC ${COMMON_LIB_SRC_BASE})
foreach(_v IN LISTS _ipchw_selected)
if(NOT _v IN_LIST IPCHW_OPTIONAL_VENDORS)
message(FATAL_ERROR
"IPCHW_VENDORS: unknown vendor '${_v}'; "
"expected 'all', 'none', or a subset of ${IPCHW_OPTIONAL_VENDORS}")
endif()
list(APPEND COMMON_LIB_SRC src/hal/${_v}.c src/hal/${_v}.h)
string(TOUPPER ${_v} _V)
list(APPEND IPCHW_VENDOR_DEFS IPCHW_VENDOR_${_V})
endforeach()
message(STATUS "libipchw vendor HALs: hisi ${_ipchw_selected}")
set(IPCTOOL_SRC
src/backup.c
src/backup.h
src/bootrom.c
src/bootrom.h
src/clocks.c
src/clocks.h
src/cpubench.c
src/cpubench.h
src/crypto/aes.c
src/crypto/aes.h
src/crypto/chachapoly.c
src/crypto/chachapoly.h
src/crypto/gcm.c
src/crypto/gcm.h
src/crypto/hisi_cipher.c
src/crypto/hisi_cipher.h
src/cryptobench.c
src/cryptobench.h
src/dns.c
src/dns.h
src/ethernet.c
src/ethernet.h
src/fake_symbols.c
src/firmware.c
src/firmware.h
src/hal/hisi/clocks_v4.c
src/hal/hisi/clocks_v4a.c
src/hal/hisi/clocks_v5.c
src/hal/hisi/ethernet.c
src/hal/hisi/ethernet.h
src/hal/hisi/ispreg.c
src/hal/hisi/ispreg.h
src/hal/hisi/ptrace.c
src/hal/hisi/ptrace.h
src/hashtable.c
src/hashtable.h
src/http.c
src/http.h
src/i2cspi.c
src/i2cspi.h
src/main.c
src/membw.c
src/membw.h
src/mtd.c
src/mtd.h
src/network.c
src/network.h
src/ptrace.c
src/ptrace.h
src/ram.c
src/ram.h
src/reginfo.c
src/reginfo.h
src/sha1.c
src/sha1.h
src/snstool.c
src/snstool.h
#src/stack.c
src/uboot.c
src/uboot.h
src/watchdog.c
src/watchdog.h
src/cjson/cJSON.c
src/cjson/cJSON.h
src/cjson/cYAML.c
src/cjson/cYAML.h
src/boards/anjoy.c
src/boards/anjoy.h
src/boards/buildroot.c
src/boards/buildroot.h
src/boards/common.c
src/boards/common.h
src/boards/hankvision.c
src/boards/hankvision.h
src/boards/linux.c
src/boards/linux.h
src/boards/openwrt.c
src/boards/openwrt.h
src/boards/ruision.c
src/boards/ruision.h
src/boards/xm.c
src/boards/xm.h
src/boards/sstar.c
src/boards/sstar.h
${VERSION_SRC})
set(CYAML_TEST_SRC
src/cjson/cYAML_test.c
src/cjson/cJSON.c
src/cjson/cJSON.h
src/cjson/cYAML.c
src/cjson/cYAML.h)
add_library(ipchw STATIC ${COMMON_LIB_SRC})
target_compile_definitions(ipchw PUBLIC STANDALONE_LIBRARY ${IPCHW_VENDOR_DEFS})
# Threads is carried on the interface so anything linking this static library
# (ipcinfo here, and external consumers of libipchw) pulls pthread in too.
target_link_libraries(ipchw m Threads::Threads)
if(NOT ONLY_LIBRARY)
add_executable(ipctool ${IPCTOOL_SRC} ${COMMON_LIB_SRC_ALL})
target_compile_definitions(ipctool PRIVATE ${IPCHW_ALL_VENDOR_DEFS})
target_link_libraries(ipctool m Threads::Threads)
install(TARGETS ipctool RUNTIME DESTINATION /usr/bin/)
add_executable(ipcinfo example/ipcinfo.c src/tools.c ${VERSION_SRC})
target_include_directories(ipcinfo PUBLIC include)
target_link_libraries(ipcinfo ipchw)
install(TARGETS ipcinfo RUNTIME DESTINATION /usr/bin/)
add_executable(cYAML_test ${CYAML_TEST_SRC})
endif()