1 set(LIBC_INCLUDE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
2 include(LLVMLibCHeaderRules)
4 add_subdirectory(llvm-libc-macros)
5 add_subdirectory(llvm-libc-types)
28 .llvm-libc-types.ino_t
29 .llvm-libc-types.struct_dirent
38 .llvm-libc-macros.fcntl_macros
39 .llvm-libc-types.mode_t
48 .llvm-libc-types.fenv_t
49 .llvm-libc-types.fexcept_t
54 DEF_FILE inttypes.h.def
58 .llvm-libc-types.imaxdiv_t
67 .llvm-libc-types.double_t
68 .llvm-libc-types.float_t
71 # TODO: This should be conditional on POSIX networking being included.
72 file(MAKE_DIRECTORY "arpa")
76 DEF_FILE arpa/inet.h.def
96 .llvm-libc-types.jmp_buf
101 DEF_FILE string.h.def
105 .llvm-libc-macros.null_macro
106 .llvm-libc-types.size_t
111 DEF_FILE strings.h.def
115 .llvm-libc-types.size_t
124 .llvm-libc-macros.time_macros
125 .llvm-libc-types.time_t
126 .llvm-libc-types.clock_t
127 .llvm-libc-types.clockid_t
128 .llvm-libc-types.struct_tm
129 .llvm-libc-types.struct_timespec
130 .llvm-libc-types.struct_timeval
135 DEF_FILE threads.h.def
139 .llvm-libc-types.__call_once_func_t
140 .llvm-libc-types.cnd_t
141 .llvm-libc-types.mtx_t
142 .llvm-libc-types.once_flag
143 .llvm-libc-types.thrd_start_t
144 .llvm-libc-types.thrd_t
145 .llvm-libc-types.tss_t
146 .llvm-libc-types.tss_dtor_t
154 .llvm-libc-macros.generic_error_number_macros
159 DEF_FILE signal.h.def
161 platform_signal=../config/${LIBC_TARGET_OS}/signal.h.in
164 ../config/${LIBC_TARGET_OS}/signal.h.in
166 .llvm-libc-macros.signal_macros
167 .llvm-libc-types.__sighandler_t
168 .llvm-libc-types.sigset_t
169 .llvm-libc-types.sig_atomic_t
170 .llvm-libc-types.stack_t
171 .llvm-libc-types.struct_sigaction
172 .llvm-libc-types.pid_t
181 .llvm-libc-macros.file_seek_macros
182 .llvm-libc-macros.stdio_macros
183 .llvm-libc-types.cookie_io_functions_t
184 .llvm-libc-types.FILE
185 .llvm-libc-types.off_t
186 .llvm-libc-types.size_t
191 DEF_FILE stdlib.h.def
195 .llvm-libc-macros.stdlib_macros
196 .llvm-libc-types.__bsearchcompare_t
197 .llvm-libc-types.__qsortcompare_t
198 .llvm-libc-types.div_t
199 .llvm-libc-types.ldiv_t
200 .llvm-libc-types.lldiv_t
201 .llvm-libc-types.size_t
202 .llvm-libc-types.__atexithandler_t
207 DEF_FILE unistd.h.def
211 .llvm-libc-macros.file_seek_macros
212 .llvm-libc-macros.unistd_macros
213 .llvm-libc-types.__exec_argv_t
214 .llvm-libc-types.__exec_envp_t
215 .llvm-libc-types.off_t
216 .llvm-libc-types.pid_t
217 .llvm-libc-types.size_t
218 .llvm-libc-types.ssize_t
219 .llvm-libc-types.uid_t
220 .llvm-libc-types.__getoptargv_t
225 DEF_FILE pthread.h.def
229 .llvm-libc-types.__atfork_callback_t
230 .llvm-libc-types.__pthread_start_t
231 .llvm-libc-types.__pthread_tss_dtor_t
232 .llvm-libc-types.pthread_attr_t
233 .llvm-libc-types.pthread_key_t
234 .llvm-libc-types.pthread_mutex_t
235 .llvm-libc-types.pthread_mutexattr_t
236 .llvm-libc-types.pthread_once_t
237 .llvm-libc-types.__pthread_once_func_t
238 .llvm-libc-types.pthread_t
247 .llvm-libc-types.cpu_set_t
248 .llvm-libc-macros.sched_macros
257 .llvm-libc-types.mode_t
258 .llvm-libc-types.pid_t
259 .llvm-libc-types.posix_spawnattr_t
260 .llvm-libc-types.posix_spawn_file_actions_t
263 # TODO: Not all platforms will have a include/sys directory. Add the sys
264 # directory and the targets for sys/*.h files conditional to the OS requiring
266 file(MAKE_DIRECTORY "sys")
270 DEF_FILE sys/auxv.h.def
274 .llvm-libc-macros.sys_auxv_macros
279 DEF_FILE sys/ioctl.h.def
283 .llvm-libc-macros.sys_ioctl_macros
288 DEF_FILE sys/mman.h.def
292 .llvm-libc-types.off_t
293 .llvm-libc-types.ssize_t
294 .llvm-libc-macros.sys_mman_macros
299 DEF_FILE sys/prctl.h.def
307 DEF_FILE sys/random.h.def
311 .llvm-libc-macros.sys_random_macros
312 .llvm-libc-types.ssize_t
313 .llvm-libc-types.size_t
318 DEF_FILE sys/resource.h.def
319 GEN_HDR sys/resource.h
322 .llvm-libc-macros.sys_resource_macros
323 .llvm-libc-types.rlim_t
324 .llvm-libc-types.struct_rlimit
329 DEF_FILE sys/stat.h.def
333 .llvm-libc-macros.sys_stat_macros
334 .llvm-libc-types.mode_t
335 .llvm-libc-types.struct_stat
340 DEF_FILE sys/select.h.def
344 .llvm-libc-macros.sys_select_macros
345 .llvm-libc-types.fd_set
346 .llvm-libc-types.sigset_t
347 .llvm-libc-types.struct_timespec
348 .llvm-libc-types.struct_timeval
349 .llvm-libc-types.suseconds_t
350 .llvm-libc-types.time_t
351 .llvm-libc-types.ssize_t
356 DEF_FILE sys/sendfile.h.def
357 GEN_HDR sys/sendfile.h
360 .llvm-libc-types.off_t
361 .llvm-libc-types.ssize_t
366 DEF_FILE sys/socket.h.def
370 .llvm-libc-macros.sys_socket_macros
375 DEF_FILE sys/syscall.h.def
376 GEN_HDR sys/syscall.h
378 syscall_numbers=../config/${LIBC_TARGET_OS}/syscall_numbers.h.inc
380 ../config/${LIBC_TARGET_OS}/syscall_numbers.h.inc
385 DEF_FILE sys/time.h.def
389 .llvm-libc-types.struct_timeval
390 .llvm-libc-macros.sys_time_macros
395 DEF_FILE sys/types.h.def
399 .llvm-libc-types.blkcnt_t
400 .llvm-libc-types.blksize_t
401 .llvm-libc-types.clockid_t
402 .llvm-libc-types.dev_t
403 .llvm-libc-types.gid_t
404 .llvm-libc-types.ino_t
405 .llvm-libc-types.mode_t
406 .llvm-libc-types.nlink_t
407 .llvm-libc-types.off_t
408 .llvm-libc-types.pid_t
409 .llvm-libc-types.pthread_attr_t
410 .llvm-libc-types.pthread_key_t
411 .llvm-libc-types.pthread_mutex_t
412 .llvm-libc-types.pthread_mutexattr_t
413 .llvm-libc-types.pthread_once_t
414 .llvm-libc-types.pthread_t
415 .llvm-libc-types.size_t
416 .llvm-libc-types.ssize_t
417 .llvm-libc-types.suseconds_t
418 .llvm-libc-types.time_t
419 .llvm-libc-types.uid_t
424 DEF_FILE sys/utsname.h.def
425 GEN_HDR sys/utsname.h
428 .llvm-libc-types.struct_utsname
433 DEF_FILE sys/wait.h.def
437 .llvm-libc-macros.sys_wait_macros
438 .llvm-libc-types.pid_t
439 .llvm-libc-types.struct_rusage
444 DEF_FILE termios.h.def
448 .llvm-libc-macros.termios_macros
449 .llvm-libc-types.cc_t
450 .llvm-libc-types.speed_t
451 .llvm-libc-types.struct_termios
452 .llvm-libc-types.tcflag_t
455 if(NOT LLVM_LIBC_FULL_BUILD)
456 # We don't install headers in non-fullbuild mode.
460 function(get_all_install_header_targets out_var)
461 set(all_deps ${ARGN})
462 foreach(target IN LISTS ARGN)
463 get_target_property(deps ${target} DEPS)
467 list(APPEND all_deps ${deps})
468 get_all_install_header_targets(nested_deps ${deps})
469 list(APPEND all_deps ${nested_deps})
471 list(REMOVE_DUPLICATES all_deps)
472 set(${out_var} ${all_deps} PARENT_SCOPE)
473 endfunction(get_all_install_header_targets)
475 get_all_install_header_targets(all_install_header_targets ${TARGET_PUBLIC_HEADERS})
476 add_custom_target(libc-headers)
477 add_dependencies(libc-headers ${all_install_header_targets})
478 foreach(target IN LISTS all_install_header_targets)
479 get_target_property(header_file ${target} HEADER_FILE_PATH)
481 message(FATAL_ERROR "Installable header file '${target}' does not have the "
482 "HEADER_FILE_PATH property set.")
484 file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_BINARY_DIR} ${header_file})
485 get_filename_component(nested_dir ${relative_path} DIRECTORY)
486 install(FILES ${header_file}
487 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${nested_dir}
488 COMPONENT libc-headers)