logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

gen.lua (7607B)


  1. local targets = {
  2. aarch64={
  3. cflags={'-D AARCH64=1'},
  4. ioctls=1,
  5. },
  6. riscv64={
  7. cflags={'-D RISCV64=1'},
  8. ioctls=0,
  9. },
  10. x86_64={
  11. cflags={'-D X86_64=1'},
  12. ioctls=2,
  13. },
  14. }
  15. local arch = config.target.platform:match('[^-]*')
  16. local targ = targets[arch]
  17. if not targ then return end
  18. cflags{
  19. '-D HAVE_CONFIG_H',
  20. '-D IN_STRACE',
  21. -- it is important that the arch-specific directory is searched first
  22. '-I $srcdir/src/linux/'..arch,
  23. '-I $srcdir/src/linux/generic',
  24. '-I $srcdir/src',
  25. '-I $outdir',
  26. '-isystem $builddir/pkg/linux-headers/include',
  27. }
  28. cflags(targ.cflags)
  29. build('cat', '$outdir/config.h', {
  30. '$builddir/probe/HAVE___BUILTIN_POPCOUNT',
  31. '$dir/config.h',
  32. })
  33. build('cpp', '$outdir/ioctl_iocdef.i', '$srcdir/src/ioctl_iocdef.c')
  34. build('sed', '$outdir/ioctl_iocdef.h', '$outdir/ioctl_iocdef.i', {
  35. expr=[[-n 's/^DEFINE HOST/#define /p']],
  36. })
  37. sub('tools.ninja', function()
  38. toolchain(config.host)
  39. cflags{
  40. '-I $srcdir/src/linux/'..arch,
  41. '-I $srcdir/src/linux',
  42. '-I $outdir',
  43. }
  44. cflags(targ.cflags)
  45. for i = 0, targ.ioctls do
  46. build('cat', '$outdir/ioctls_all'..i..'.h', {
  47. '$srcdir/src/linux/'..arch..'/ioctls_inc'..i..'.h',
  48. '$srcdir/src/linux/'..arch..'/ioctls_arch'..i..'.h',
  49. })
  50. build('cc', '$outdir/ioctlsort'..i..'.c.o', {
  51. '$srcdir/src/ioctlsort.c',
  52. '|', '$outdir/ioctl_iocdef.h', '$srcdir/ioctls_zfs.h', '$outdir/ioctls_all'..i..'.h',
  53. }, {cflags=string.format([[$cflags -D 'IOCTLSORT_INC="ioctls_all%d.h"']], i)})
  54. exe('ioctlsort'..i, {'ioctlsort'..i..'.c.o'})
  55. rule('ioctlsort'..i, '$outdir/ioctlsort'..i..' >$out')
  56. build('ioctlsort'..i, '$outdir/ioctlent'..i..'.h', {'|', '$outdir/ioctlsort'..i})
  57. end
  58. end)
  59. local mpers = lines('mpers.txt')
  60. for _, f in ipairs(mpers) do
  61. build('cpp', '$outdir/'..f..'.mpers.i', {'$srcdir/src/'..f, '|', '$outdir/config.h'}, {
  62. cflags='$cflags -DIN_MPERS_BOOTSTRAP',
  63. })
  64. end
  65. local function makempers(name, script)
  66. build('awk', '$outdir/'..name, {expand{'$outdir/', mpers, '.mpers.i'}, '|', '$dir/'..script}, {
  67. expr='-f $dir/'..script,
  68. })
  69. end
  70. makempers('printers.h', 'printers.awk')
  71. makempers('native_printer_decls.h', 'printerdecls.awk')
  72. makempers('native_printer_defs.h', 'printerdefs.awk')
  73. build('cpp', '$outdir/syscallent.i', '$srcdir/src/linux/'..arch..'/syscallent.h')
  74. build('awk', '$outdir/scno-syscallent.h', {'$outdir/syscallent.i', '|', '$dir/scno.awk'}, {
  75. expr='-f $dir/scno.awk',
  76. })
  77. build('cat', '$outdir/scno.h', {'$srcdir/src/scno.head', '$outdir/scno-syscallent.h'})
  78. -- this seems to be enough syscall headers to build
  79. local syscalls = expand{'$srcdir/src/linux/', {
  80. '32/syscallent.h',
  81. '64/syscallent.h',
  82. 'arm/syscallent.h',
  83. 'generic/subcallent.h',
  84. 'generic/syscallent-common.h',
  85. 'i386/syscallent.h',
  86. 'riscv64/syscallent.h',
  87. 'sparc/syscallent.h',
  88. 'sparc64/syscallent.h',
  89. 'x86_64/syscallent.h',
  90. }}
  91. build('awk', '$outdir/sen.h', {syscalls, '|', '$dir/sen.awk'}, {
  92. expr='-f $dir/sen.awk',
  93. })
  94. local srcs = paths[[src/(
  95. access.c
  96. affinity.c
  97. aio.c
  98. alarm.c
  99. alpha.c
  100. basic_filters.c
  101. bind.c
  102. bjm.c
  103. block.c
  104. bpf.c
  105. bpf_filter.c
  106. bpf_seccomp_filter.c
  107. bpf_sock_filter.c
  108. btrfs.c
  109. cacheflush.c
  110. cachestat.c
  111. capability.c
  112. chdir.c
  113. chmod.c
  114. clone.c
  115. close_range.c
  116. copy_file_range.c
  117. count.c
  118. counter_ioctl.c
  119. delay.c
  120. desc.c
  121. dirent.c
  122. dirent64.c
  123. dirent_types.c
  124. dm.c
  125. dup.c
  126. dyxlat.c
  127. epoll.c
  128. epoll_ioctl.c
  129. error_prints.c
  130. evdev.c
  131. evdev_mpers.c
  132. eventfd.c
  133. execve.c
  134. exit.c
  135. exitkill.c
  136. fadvise.c
  137. fallocate.c
  138. fanotify.c
  139. fchownat.c
  140. fcntl.c
  141. fetch_bpf_fprog.c
  142. fetch_indirect_syscall_args.c
  143. fetch_struct_flock.c
  144. fetch_struct_iovec.c
  145. fetch_struct_keyctl_kdf_params.c
  146. fetch_struct_mmsghdr.c
  147. fetch_struct_msghdr.c
  148. fetch_struct_stat.c
  149. fetch_struct_stat64.c
  150. fetch_struct_statfs.c
  151. fetch_struct_xfs_quotastat.c
  152. file_attr.c
  153. file_handle.c
  154. filter_qualify.c
  155. filter_seccomp.c
  156. flock.c
  157. fs_0x15_ioctl.c
  158. fs_0x94_ioctl.c
  159. fs_f_ioctl.c
  160. fs_x_ioctl.c
  161. fsconfig.c
  162. fsmount.c
  163. fsopen.c
  164. fspick.c
  165. fstatfs.c
  166. fstatfs64.c
  167. futex.c
  168. futex2.c
  169. gen/gen_hdio.c
  170. get_personality.c
  171. get_robust_list.c
  172. getcpu.c
  173. getcwd.c
  174. getpagesize.c
  175. getpid.c
  176. getrandom.c
  177. gpio_ioctl.c
  178. hdio.c
  179. hostname.c
  180. inotify.c
  181. inotify_ioctl.c
  182. io.c
  183. io_uring.c
  184. ioctl.c
  185. ioperm.c
  186. iopl.c
  187. ioprio.c
  188. ipc.c
  189. ipc_msg.c
  190. ipc_msgctl.c
  191. ipc_sem.c
  192. ipc_semctl.c
  193. ipc_shm.c
  194. ipc_shmctl.c
  195. kcmp.c
  196. kd_ioctl.c
  197. kd_mpers_ioctl.c
  198. kexec.c
  199. keyctl.c
  200. kvm.c
  201. landlock.c
  202. ldt.c
  203. link.c
  204. lirc_ioctl.c
  205. listen.c
  206. listmount.c
  207. listns.c
  208. lookup_dcookie.c
  209. loop.c
  210. lseek.c
  211. lsm.c
  212. map_shadow_stack.c
  213. mem.c
  214. membarrier.c
  215. memfd_create.c
  216. memfd_secret.c
  217. mknod.c
  218. mmap_cache.c
  219. mmap_notify.c
  220. mmsghdr.c
  221. mount.c
  222. mount_setattr.c
  223. move_mount.c
  224. mq.c
  225. msghdr.c
  226. mtd.c
  227. nbd_ioctl.c
  228. net.c
  229. netlink.c
  230. netlink_crypto.c
  231. netlink_generic.c
  232. netlink_inet_diag.c
  233. netlink_kobject_uevent.c
  234. netlink_netfilter.c
  235. netlink_netlink_diag.c
  236. netlink_nlctrl.c
  237. netlink_packet_diag.c
  238. netlink_route.c
  239. netlink_selinux.c
  240. netlink_smc_diag.c
  241. netlink_sock_diag.c
  242. netlink_unix_diag.c
  243. nice.c
  244. nlattr.c
  245. nsfs.c
  246. numa.c
  247. number_set.c
  248. oldstat.c
  249. open.c
  250. or1k_atomic.c
  251. pathtrace.c
  252. perf.c
  253. perf_ioctl.c
  254. personality.c
  255. pidfd_getfd.c
  256. pidfd_open.c
  257. pidns.c
  258. pkeys.c
  259. poke.c
  260. poll.c
  261. prctl.c
  262. print_dev_t.c
  263. print_group_req.c
  264. print_ifindex.c
  265. print_instruction_pointer.c
  266. print_kernel_sigset.c
  267. print_kernel_version.c
  268. print_mac.c
  269. print_mq_attr.c
  270. print_msgbuf.c
  271. print_sg_req_info.c
  272. print_sigevent.c
  273. print_statfs.c
  274. print_struct_stat.c
  275. print_syscall_number.c
  276. print_time.c
  277. print_timespec32.c
  278. print_timespec64.c
  279. print_timeval.c
  280. print_timeval64.c
  281. print_timex.c
  282. printmode.c
  283. printrusage.c
  284. printsiginfo.c
  285. process_vm.c
  286. ptp.c
  287. ptrace.c
  288. ptrace_syscall_info.c
  289. quota.c
  290. random_ioctl.c
  291. readahead.c
  292. readlink.c
  293. reboot.c
  294. regset.c
  295. renameat.c
  296. resource.c
  297. retval.c
  298. riscv.c
  299. rt_sigframe.c
  300. rt_sigreturn.c
  301. rtc.c
  302. rtnl_addr.c
  303. rtnl_addrlabel.c
  304. rtnl_cachereport.c
  305. rtnl_dcb.c
  306. rtnl_link.c
  307. rtnl_mdb.c
  308. rtnl_neigh.c
  309. rtnl_neightbl.c
  310. rtnl_netconf.c
  311. rtnl_nh.c
  312. rtnl_nsid.c
  313. rtnl_route.c
  314. rtnl_rule.c
  315. rtnl_stats.c
  316. rtnl_tc.c
  317. rtnl_tc_action.c
  318. s390.c
  319. sched.c
  320. scsi.c
  321. seccomp.c
  322. seccomp_ioctl.c
  323. sendfile.c
  324. set_tid_address.c
  325. sg_io_v3.c
  326. sg_io_v4.c
  327. shutdown.c
  328. sigaltstack.c
  329. signal.c
  330. signalfd.c
  331. sigreturn.c
  332. sock.c
  333. sockaddr.c
  334. socketcall.c
  335. socketutils.c
  336. sparc.c
  337. sram_alloc.c
  338. stage_output.c
  339. stat.c
  340. stat64.c
  341. statfs.c
  342. statfs64.c
  343. statmount.c
  344. statx.c
  345. strauss.c
  346. string_to_uint.c
  347. swapon.c
  348. sync_file_range.c
  349. sync_file_range2.c
  350. syscall.c
  351. syscall_name.c
  352. sysctl.c
  353. sysinfo.c
  354. syslog.c
  355. sysmips.c
  356. tee.c
  357. term.c
  358. time.c
  359. times.c
  360. trie.c
  361. truncate.c
  362. ubi.c
  363. ucopy.c
  364. uid.c
  365. uid16.c
  366. umask.c
  367. umount.c
  368. uname.c
  369. upeek.c
  370. upoke.c
  371. userfaultfd.c
  372. ustat.c
  373. util.c
  374. utime.c
  375. utimes.c
  376. v4l2.c
  377. wait.c
  378. watchdog_ioctl.c
  379. xattr.c
  380. xgetdents.c
  381. xlat.c
  382. xmalloc.c
  383. )]]
  384. build('sed', '$outdir/sys_func.h', expand{'$srcdir/', srcs}, {
  385. expr=[[-n 's/^SYS_FUNC(.*/extern &;/p']],
  386. })
  387. pkg.deps = {
  388. '$outdir/config.h',
  389. '$outdir/native_printer_decls.h',
  390. '$outdir/native_printer_defs.h',
  391. '$outdir/printers.h',
  392. '$outdir/scno.h',
  393. '$outdir/sen.h',
  394. '$outdir/sys_func.h',
  395. 'pkg/linux-headers/headers',
  396. }
  397. for i = 0, targ.ioctls do
  398. table.insert(pkg.deps, '$outdir/ioctlent'..i..'.h')
  399. end
  400. lib('libstrace.a', srcs)
  401. exe('strace', {'src/strace.c', 'libstrace.a'})
  402. file('bin/strace', '755', '$outdir/strace')
  403. build('sed', '$outdir/strace.1', '$srcdir/doc/strace.1.in', {
  404. expr={
  405. [[-e 's,@STRACE_MANPAGE_DATE@,2025-11-13,']],
  406. [[-e 's,@VERSION@,6.19,']],
  407. [[-e 's,@ENABLE_STACKTRACE_TRUE@,#,']],
  408. [[-e 's,@ENABLE_STACKTRACE_FALSE@,,']],
  409. [[-e 's,@ENABLE_SECONTEXT_TRUE@,#,']],
  410. [[-e 's,@ENABLE_SECONTEXT_FALSE@,,']],
  411. },
  412. })
  413. man{'$outdir/strace.1'}
  414. fetch 'curl'