gen.lua (7124B)
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 error_prints.c 119 evdev.c 120 evdev_mpers.c 121 eventfd.c 122 execve.c 123 exitkill.c 124 fadvise.c 125 fallocate.c 126 fanotify.c 127 fchownat.c 128 fcntl.c 129 fetch_bpf_fprog.c 130 fetch_indirect_syscall_args.c 131 fetch_struct_flock.c 132 fetch_struct_iovec.c 133 fetch_struct_keyctl_kdf_params.c 134 fetch_struct_mmsghdr.c 135 fetch_struct_msghdr.c 136 fetch_struct_stat.c 137 fetch_struct_stat64.c 138 fetch_struct_statfs.c 139 fetch_struct_xfs_quotastat.c 140 file_handle.c 141 filter_qualify.c 142 filter_seccomp.c 143 flock.c 144 fs_0x94_ioctl.c 145 fs_f_ioctl.c 146 fs_x_ioctl.c 147 fsconfig.c 148 fsmount.c 149 fsopen.c 150 fspick.c 151 fstatfs.c 152 fstatfs64.c 153 futex.c 154 futex2.c 155 gen/gen_hdio.c 156 get_personality.c 157 get_robust_list.c 158 getcpu.c 159 getcwd.c 160 getpagesize.c 161 getpid.c 162 getrandom.c 163 gpio_ioctl.c 164 hdio.c 165 hostname.c 166 inotify.c 167 inotify_ioctl.c 168 io.c 169 io_uring.c 170 ioctl.c 171 ioperm.c 172 ioprio.c 173 ipc.c 174 ipc_msg.c 175 ipc_msgctl.c 176 ipc_sem.c 177 ipc_semctl.c 178 ipc_shm.c 179 ipc_shmctl.c 180 kcmp.c 181 kd_ioctl.c 182 kd_mpers_ioctl.c 183 kexec.c 184 keyctl.c 185 kvm.c 186 landlock.c 187 ldt.c 188 link.c 189 lirc_ioctl.c 190 listen.c 191 listmount.c 192 lookup_dcookie.c 193 loop.c 194 lseek.c 195 lsm.c 196 map_shadow_stack.c 197 mem.c 198 membarrier.c 199 memfd_create.c 200 memfd_secret.c 201 mknod.c 202 mmap_cache.c 203 mmap_notify.c 204 mmsghdr.c 205 mount.c 206 mount_setattr.c 207 move_mount.c 208 mq.c 209 msghdr.c 210 mtd.c 211 nbd_ioctl.c 212 net.c 213 netlink.c 214 netlink_crypto.c 215 netlink_inet_diag.c 216 netlink_kobject_uevent.c 217 netlink_netfilter.c 218 netlink_netlink_diag.c 219 netlink_packet_diag.c 220 netlink_route.c 221 netlink_selinux.c 222 netlink_smc_diag.c 223 netlink_sock_diag.c 224 netlink_unix_diag.c 225 nlattr.c 226 nsfs.c 227 numa.c 228 number_set.c 229 oldstat.c 230 open.c 231 open_tree.c 232 or1k_atomic.c 233 pathtrace.c 234 perf.c 235 perf_ioctl.c 236 personality.c 237 pidfd_getfd.c 238 pidfd_open.c 239 pidns.c 240 pkeys.c 241 poke.c 242 poll.c 243 prctl.c 244 print_dev_t.c 245 print_group_req.c 246 print_ifindex.c 247 print_instruction_pointer.c 248 print_kernel_sigset.c 249 print_kernel_version.c 250 print_mac.c 251 print_mq_attr.c 252 print_msgbuf.c 253 print_sg_req_info.c 254 print_sigevent.c 255 print_statfs.c 256 print_struct_stat.c 257 print_syscall_number.c 258 print_time.c 259 print_timespec32.c 260 print_timespec64.c 261 print_timeval.c 262 print_timeval64.c 263 print_timex.c 264 printmode.c 265 printrusage.c 266 printsiginfo.c 267 process_vm.c 268 ptp.c 269 ptrace.c 270 ptrace_syscall_info.c 271 quota.c 272 random_ioctl.c 273 readahead.c 274 readlink.c 275 reboot.c 276 regset.c 277 renameat.c 278 resource.c 279 retval.c 280 riscv.c 281 rt_sigframe.c 282 rt_sigreturn.c 283 rtc.c 284 rtnl_addr.c 285 rtnl_addrlabel.c 286 rtnl_cachereport.c 287 rtnl_dcb.c 288 rtnl_link.c 289 rtnl_mdb.c 290 rtnl_neigh.c 291 rtnl_neightbl.c 292 rtnl_netconf.c 293 rtnl_nh.c 294 rtnl_nsid.c 295 rtnl_route.c 296 rtnl_rule.c 297 rtnl_stats.c 298 rtnl_tc.c 299 rtnl_tc_action.c 300 s390.c 301 sched.c 302 scsi.c 303 seccomp.c 304 seccomp_ioctl.c 305 sendfile.c 306 sg_io_v3.c 307 sg_io_v4.c 308 shutdown.c 309 sigaltstack.c 310 signal.c 311 signalfd.c 312 sigreturn.c 313 sock.c 314 sockaddr.c 315 socketcall.c 316 socketutils.c 317 sparc.c 318 sram_alloc.c 319 stage_output.c 320 stat.c 321 stat64.c 322 statfs.c 323 statfs64.c 324 statmount.c 325 statx.c 326 strauss.c 327 string_to_uint.c 328 swapon.c 329 sync_file_range.c 330 sync_file_range2.c 331 syscall.c 332 syscall_name.c 333 sysctl.c 334 sysinfo.c 335 syslog.c 336 sysmips.c 337 tee.c 338 term.c 339 time.c 340 times.c 341 trie.c 342 truncate.c 343 ubi.c 344 ucopy.c 345 uid.c 346 uid16.c 347 umask.c 348 umount.c 349 uname.c 350 upeek.c 351 upoke.c 352 userfaultfd.c 353 ustat.c 354 util.c 355 utime.c 356 utimes.c 357 v4l2.c 358 wait.c 359 watchdog_ioctl.c 360 xattr.c 361 xgetdents.c 362 xlat.c 363 xmalloc.c 364 )]] 365 366 build('sed', '$outdir/sys_func.h', expand{'$srcdir/', srcs}, { 367 expr=[[-n 's/^SYS_FUNC(.*/extern &;/p']], 368 }) 369 370 pkg.deps = { 371 '$outdir/config.h', 372 '$outdir/ioctlent0.h', 373 '$outdir/ioctlent1.h', 374 '$outdir/ioctlent2.h', 375 '$outdir/native_printer_decls.h', 376 '$outdir/native_printer_defs.h', 377 '$outdir/printers.h', 378 '$outdir/scno.h', 379 '$outdir/sen.h', 380 '$outdir/sys_func.h', 381 'pkg/devel/linux-headers/headers', 382 } 383 384 lib('libstrace.a', srcs) 385 exe('strace', {'src/strace.c', 'libstrace.a'}) 386 file('bin/strace', '755', '$outdir/strace') 387 388 build('sed', '$outdir/strace.1', '$srcdir/doc/strace.1.in', { 389 expr={ 390 [[-e 's,@STRACE_MANPAGE_DATE@,2024-03-13,']], 391 [[-e 's,@VERSION@,6.8,']], 392 [[-e 's,@ENABLE_STACKTRACE_TRUE@,#,']], 393 [[-e 's,@ENABLE_STACKTRACE_FALSE@,,']], 394 [[-e 's,@ENABLE_SECONTEXT_TRUE@,#,']], 395 [[-e 's,@ENABLE_SECONTEXT_FALSE@,,']], 396 }, 397 }) 398 man({'$outdir/strace.1'}) 399 400 fetch('curl')