opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

gen.lua (7244B)


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