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