hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

gen-stdlib (33281B)


      1 #!/bin/sh
      2 # The purpose of this script is to generate make targets for the Hare standard
      3 # library. If you are adding new modules to the standard library, write a
      4 # function for that module (e.g. encoding_utf8), and call the following helper
      5 # commands:
      6 #
      7 # gen_srcs module::name list.ha of.ha sources.ha
      8 # gen_ssa module::name list of module::names yours depends on
      9 #
     10 # Then add your module to the list of modules at the bottom.
     11 #
     12 # Then run ./scripts/gen-stdlib > stdlib.mk to generate new rules.
     13 
     14 srcdir="$(dirname "$0")"
     15 eval ". $srcdir/gen-stdlib.sh"
     16 
     17 all_platforms="linux
     18 freebsd"
     19 
     20 gensrcs_rt() {
     21 	gen_srcs -plinux rt \
     22 		+linux/platform_abort.ha \
     23 		+linux/env.ha \
     24 		+linux/errno.ha \
     25 		+linux/types.ha \
     26 		+linux/segmalloc.ha \
     27 		+linux/platformstart-libc.ha \
     28 		+linux/prctl.ha \
     29 		+linux/'+$(ARCH)'.ha \
     30 		+linux/syscallno+'$(ARCH)'.ha \
     31 		+linux/syscalls.ha \
     32 		+linux/syscallsarch+'$(ARCH)'.ha \
     33 		+linux/signal.ha \
     34 		+linux/stat.ha \
     35 		+linux/socket.ha \
     36 		'+$(ARCH)'/arch_jmp.ha \
     37 		'+$(ARCH)'/backtrace.ha \
     38 		fenv_defs.ha \
     39 		'+$(ARCH)'/cpuid.ha \
     40 		ensure.ha \
     41 		jmp.ha \
     42 		malloc.ha \
     43 		memcpy.ha \
     44 		memmove.ha \
     45 		memset.ha \
     46 		strcmp.ha \
     47 		$*
     48 	gen_srcs -pfreebsd rt \
     49 		+freebsd/platform_abort.ha \
     50 		+freebsd/env.ha \
     51 		+freebsd/errno.ha \
     52 		+freebsd/platformstart.ha \
     53 		+freebsd/segmalloc.ha \
     54 		+freebsd/signal.ha \
     55 		+freebsd/socket.ha \
     56 		+freebsd/'+$(ARCH)'.ha \
     57 		+freebsd/syscallno.ha \
     58 		+freebsd/syscalls.ha \
     59 		+freebsd/types.ha \
     60 		+'$(ARCH)'/arch_jmp.ha \
     61 		+'$(ARCH)'/backtrace.ha \
     62 		fenv_defs.ha \
     63 		+'$(ARCH)'/cpuid.ha \
     64 		ensure.ha \
     65 		jmp.ha \
     66 		malloc.ha \
     67 		memcpy.ha \
     68 		memmove.ha \
     69 		memset.ha \
     70 		strcmp.ha \
     71 		$*
     72 }
     73 
     74 rt() {
     75 	# This one is complicated, don't use it as a reference for other modules
     76 	if [ $testing -eq 0 ]
     77 	then
     78 		printf '%s\n' 'rtscript = $(STDLIB)/rt/hare.sc'
     79 		gensrcs_rt \
     80 			abort.ha \
     81 			start.ha
     82 	else
     83 		gensrcs_rt \
     84 			abort+test.ha \
     85 			start+test.ha \
     86 			+test/signal_test.ha
     87 	fi
     88 	gen_ssa -plinux rt
     89 	gen_ssa -pfreebsd rt
     90 	cat <<EOF
     91 \$($cache)/rt/start.o: \$(STDLIB)/rt/+\$(PLATFORM)/start+\$(ARCH)-libc.s
     92 	@printf 'AS \t%s\n' "\$@"
     93 	@mkdir -p \$($cache)/rt
     94 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(PLATFORM)/start+\$(ARCH)-libc.s
     95 
     96 ${stdlib}_asm = \$($cache)/rt/syscall.o \\
     97 	\$($cache)/rt/setjmp.o \\
     98 	\$($cache)/rt/longjmp.o \\
     99 	\$($cache)/rt/restore.o \\
    100 	\$($cache)/rt/getfp.o \\
    101 	\$($cache)/rt/fenv.o \\
    102 	\$($cache)/rt/start.o \\
    103 	\$($cache)/rt/cpuid_native.o
    104 
    105 \$($cache)/rt/syscall.o: \$(STDLIB)/rt/+\$(PLATFORM)/syscall+\$(ARCH).s
    106 	@printf 'AS \t%s\n' "\$@"
    107 	@mkdir -p \$($cache)/rt
    108 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(PLATFORM)/syscall+\$(ARCH).s
    109 
    110 \$($cache)/rt/setjmp.o: \$(STDLIB)/rt/+\$(ARCH)/setjmp.s
    111 	@printf 'AS \t%s\n' "\$@"
    112 	@mkdir -p \$($cache)/rt
    113 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(ARCH)/setjmp.s
    114 
    115 \$($cache)/rt/longjmp.o: \$(STDLIB)/rt/+\$(ARCH)/longjmp.s
    116 	@printf 'AS \t%s\n' "\$@"
    117 	@mkdir -p \$($cache)/rt
    118 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(ARCH)/longjmp.s
    119 
    120 \$($cache)/rt/restore.o: \$(STDLIB)/rt/+\$(ARCH)/restore.s
    121 	@printf 'AS \t%s\n' "\$@"
    122 	@mkdir -p \$($cache)/rt
    123 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(ARCH)/restore.s
    124 
    125 \$($cache)/rt/fenv.o: \$(STDLIB)/rt/+\$(ARCH)/fenv.s
    126 	@printf 'AS \t%s\n' "\$@"
    127 	@mkdir -p \$($cache)/rt
    128 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(ARCH)/fenv.s
    129 
    130 \$($cache)/rt/getfp.o: \$(STDLIB)/rt/+\$(ARCH)/getfp.s
    131 	@printf 'AS \t%s\n' "\$@"
    132 	@mkdir -p \$($cache)/rt
    133 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(ARCH)/getfp.s
    134 
    135 \$($cache)/rt/cpuid_native.o: \$(STDLIB)/rt/+\$(ARCH)/cpuid_native.s
    136 	@printf 'AS \t%s\n' "\$@"
    137 	@mkdir -p \$($cache)/rt
    138 	@\$(AS) -o \$@ \$(STDLIB)/rt/+\$(ARCH)/cpuid_native.s
    139 
    140 \$($cache)/rt/rt-linux.a: \$($cache)/rt/rt-linux.o \$(${stdlib}_asm)
    141 	@printf 'AR \t%s\n' "\$@"
    142 	@\$(AR) -csr \$@ \$($cache)/rt/rt-linux.o \$(${stdlib}_asm)
    143 
    144 \$($cache)/rt/rt-freebsd.a: \$($cache)/rt/rt-freebsd.o \$(${stdlib}_asm)
    145 	@printf 'AR \t%s\n' "\$@"
    146 	@\$(AR) -csr \$@ \$($cache)/rt/rt-freebsd.o \$(${stdlib}_asm)
    147 
    148 ${stdlib}_rt = \$($cache)/rt/rt-\$(PLATFORM).a
    149 ${stdlib}_env += HARE_TD_rt=\$($cache)/rt/rt.td
    150 ${stdlib}_deps_linux += \$(${stdlib}_rt)
    151 ${stdlib}_deps_freebsd += \$(${stdlib}_rt)
    152 ${stdlib}_deps_any += \$(${stdlib}_rt)
    153 
    154 EOF
    155 }
    156 
    157 test() {
    158 	if [ $testing -eq 0 ]; then
    159 		gen_srcs test common.ha
    160 		gen_ssa test
    161 	else
    162 		gen_srcs test common.ha +test.ha fail+test.ha
    163 		gen_ssa test bufio encoding::hex encoding::utf8 fmt fnmatch io \
    164 			os rt strings memio time unix::signal
    165 	fi
    166 }
    167 
    168 ascii() {
    169 	gen_srcs ascii \
    170 		ctype.ha \
    171 		string.ha \
    172 		valid.ha
    173 	gen_ssa ascii strings
    174 }
    175 
    176 bufio() {
    177 	if [ $testing -eq 0 ]; then
    178 		gen_srcs bufio \
    179 			stream.ha \
    180 			scanner.ha
    181 		gen_ssa bufio bytes encoding::utf8 errors io strings types
    182 	else
    183 		gen_srcs bufio \
    184 			stream.ha \
    185 			scanner.ha \
    186 			stream_test+test.ha \
    187 			scanner_test+test.ha
    188 		gen_ssa bufio bytes encoding::utf8 errors io memio strings types
    189 	fi
    190 }
    191 
    192 bytes() {
    193 	gen_srcs bytes \
    194 		contains.ha \
    195 		equal.ha \
    196 		index.ha \
    197 		reverse.ha \
    198 		tokenize.ha \
    199 		trim.ha \
    200 		two_way.ha \
    201 		zero.ha
    202 	gen_ssa bytes types
    203 }
    204 
    205 crypto() {
    206 	if [ $testing -eq 0 ]
    207 	then
    208 		gen_srcs crypto \
    209 			authenc.ha \
    210 			keyderiv.ha
    211 		gen_ssa crypto bytes crypto::argon2 crypto::chachapoly \
    212 			crypto::math endian errors io memio
    213 	else
    214 		gen_srcs crypto \
    215 			authenc.ha \
    216 			keyderiv.ha \
    217 			+test/authenc_test.ha
    218 		gen_ssa crypto bytes crypto::argon2 crypto::chachapoly \
    219 			crypto::math endian errors io memio
    220 	fi
    221 }
    222 
    223 gensrcs_crypto_aes() {
    224 	gen_srcs crypto::aes \
    225 		aes.ha \
    226 		aes_ct64.ha \
    227 		block.ha \
    228 		$*
    229 }
    230 
    231 crypto_aes() {
    232 	if [ $testing -eq 0 ]
    233 	then
    234 		gensrcs_crypto_aes
    235 		gen_ssa crypto::aes bytes crypto::cipher crypto::math endian \
    236 			rt io
    237 	else
    238 		gensrcs_crypto_aes \
    239 			ct64+test.ha \
    240 			cbc+test.ha \
    241 			ctr+test.ha \
    242 			rt+test.ha \
    243 			+test/gcm.ha
    244 		gen_ssa crypto::aes bytes crypto::cipher crypto::math \
    245 			endian errors io memio rt 
    246 	fi
    247 }
    248 
    249 crypto_aes_xts() {
    250 	if [ $testing -eq 0 ]
    251 	then
    252 		gen_srcs crypto::aes::xts xts.ha
    253 	else
    254 		gen_srcs crypto::aes::xts xts.ha +test.ha
    255 	fi
    256 	gen_ssa crypto::aes::xts crypto::aes crypto::cipher bytes
    257 }
    258 
    259 crypto_argon2() {
    260 	if [ $testing -eq 0 ]
    261 	then
    262 		gen_srcs crypto::argon2 argon2.ha
    263 		gen_ssa crypto::argon2 bytes crypto::blake2b \
    264 			crypto::math endian errors hash io memio rt types
    265 	else
    266 		gen_srcs crypto::argon2 argon2.ha +test.ha
    267 		gen_ssa crypto::argon2 bytes crypto::blake2b \
    268 			crypto::math encoding::hex endian errors hash io memio \
    269 			rt strings types
    270 	fi
    271 }
    272 
    273 crypto_bcrypt() {
    274 	if [ $testing -eq 0 ]
    275 	then
    276 		gen_srcs crypto::bcrypt bcrypt.ha base64.ha
    277 	else
    278 		gen_srcs crypto::bcrypt bcrypt.ha base64.ha +test.ha
    279 	fi
    280 	gen_ssa crypto::bcrypt bytes crypto crypto::blowfish \
    281 		crypto::cipher crypto::random encoding::base64 errors \
    282 		fmt io memio strconv strings
    283 }
    284 
    285 gensrcs_crypto_blake2b() {
    286 	gen_srcs crypto::blake2b \
    287 		blake2b.ha \
    288 		$*
    289 }
    290 
    291 crypto_blake2b() {
    292 	if [ $testing -eq 0 ]
    293 	then
    294 		gensrcs_crypto_blake2b
    295 		gen_ssa crypto::blake2b bytes crypto::math endian hash io
    296 	else
    297 		gensrcs_crypto_blake2b +test.ha vectors+test.ha
    298 		gen_ssa crypto::blake2b encoding::hex fmt hash io strings \
    299 			memio crypto::math endian bytes
    300 	fi
    301 }
    302 
    303 gensrcs_crypto_blowfish() {
    304 	gen_srcs crypto::blowfish \
    305 		blowfish.ha \
    306 		const.ha \
    307 		$*
    308 }
    309 
    310 crypto_blowfish() {
    311 	if [ $testing -eq 0 ]
    312 	then
    313 		gensrcs_crypto_blowfish
    314 	else
    315 		gensrcs_crypto_blowfish +test.ha
    316 	fi
    317 	gen_ssa crypto::blowfish bytes crypto::cipher endian
    318 }
    319 
    320 gensrcs_crypto_bigint() {
    321 		gen_srcs crypto::bigint arithm.ha encoding.ha monty.ha types.ha \
    322             util.ha $*
    323 }
    324 
    325 crypto_bigint() {
    326 	if [ $testing -eq 0 ]
    327 	then
    328 		gensrcs_crypto_bigint
    329         gen_ssa crypto::bigint bytes crypto::math
    330 	else
    331 		gensrcs_crypto_bigint +test/arithm_test.ha +test/encoding_test.ha \
    332             +test/monty_test.ha +test/utils.ha
    333         gen_ssa crypto::bigint bytes crypto::math encoding::hex
    334 	fi
    335 }
    336 
    337 crypto_chacha() {
    338 	if [ $testing -eq 0 ]
    339 	then
    340 		gen_srcs crypto::chacha chacha20.ha
    341 		gen_ssa crypto::chacha bytes crypto::cipher crypto::math \
    342 			endian io
    343 	else
    344 		gen_srcs crypto::chacha chacha20.ha +test.ha
    345 		gen_ssa crypto::chacha bytes crypto::cipher crypto::math \
    346 			endian io memio
    347 	fi
    348 }
    349 
    350 crypto_chachapoly() {
    351 	if [ $testing -eq 0 ]
    352 	then
    353 		gen_srcs crypto::chachapoly chachapoly.ha
    354 	else
    355 		gen_srcs crypto::chachapoly chachapoly.ha encryption+test.ha
    356 	fi
    357 	gen_ssa crypto::chachapoly bufio bytes crypto::chacha crypto::mac \
    358 		crypto::math crypto::poly1305 endian errors io types
    359 }
    360 
    361 crypto_cipher() {
    362 	gen_srcs crypto::cipher \
    363 		cipher.ha \
    364 		block.ha \
    365 		cbc.ha \
    366 		ctr.ha \
    367 		stream.ha \
    368 		gcm.ha \
    369 		ghash.ha
    370 	gen_ssa crypto::cipher crypto::math bytes endian errors io types
    371 }
    372 
    373 crypto_hkdf() {
    374 	if [ $testing -eq 0 ]
    375 	then
    376 		gen_srcs crypto::hkdf hkdf.ha
    377 		gen_ssa crypto::hkdf bytes crypto::hmac crypto::mac hash
    378 	else
    379 		gen_srcs crypto::hkdf hkdf.ha +test.ha
    380 		gen_ssa crypto::hkdf bytes crypto::hmac crypto::mac hash \
    381 			crypto::sha1 crypto::sha256
    382 	fi
    383 }
    384 
    385 crypto_hmac() {
    386 	if [ $testing -eq 0 ]
    387 	then
    388 		gen_srcs crypto::hmac \
    389 			hmac.ha \
    390 			sha1.ha \
    391 			sha256.ha
    392 		gen_ssa crypto::hmac crypto::mac crypto::sha1 crypto::sha256 hash io bytes
    393 	else
    394 		gen_srcs crypto::hmac \
    395 			hmac.ha \
    396 			sha1.ha \
    397 			sha256.ha \
    398 			+test.ha
    399 		gen_ssa crypto::hmac bytes crypto::mac hash crypto::sha1 \
    400 			crypto::sha256 encoding::hex io strings
    401 	fi
    402 }
    403 
    404 crypto_mac() {
    405 	gen_srcs crypto::mac \
    406 		mac.ha
    407 	gen_ssa crypto::mac io
    408 }
    409 
    410 crypto_math() {
    411 	gen_srcs crypto::math \
    412 		arithm.ha bits.ha
    413 	gen_ssa crypto::math
    414 }
    415 
    416 crypto_poly1305() {
    417 	if [ $testing -eq 0 ]
    418 	then
    419 		gen_srcs crypto::poly1305 \
    420 			poly1305.ha
    421 		gen_ssa crypto::poly1305 bytes crypto::mac endian io
    422 	else
    423 		gen_srcs crypto::poly1305 \
    424 			poly1305.ha \
    425 			+test.ha
    426 		gen_ssa crypto::poly1305 bytes crypto::mac endian encoding::hex io
    427 	fi
    428 }
    429 
    430 crypto_random() {
    431 	gen_srcs -plinux crypto::random \
    432 		+linux.ha \
    433 		random.ha
    434 	gen_ssa -plinux crypto::random rt io errors
    435 
    436 	gen_srcs -pfreebsd crypto::random \
    437 		+freebsd.ha \
    438 		random.ha
    439 	gen_ssa -pfreebsd crypto::random rt io errors
    440 }
    441 
    442 gensrcs_crypto_rsa() {
    443 	gen_srcs crypto::rsa core.ha  errors.ha  keys.ha  pkcs1.ha $*
    444 }
    445 
    446 genssa_crypto_rsa() {
    447 	gen_ssa crypto::rsa bufio bytes crypto::bigint crypto::math \
    448 		crypto::sha1 crypto::sha256 crypto::sha512 endian errors hash \
    449 		io memio types $*
    450 }
    451 
    452 crypto_rsa() {
    453 	if [ $testing -eq 0 ]
    454 	then
    455 		gensrcs_crypto_rsa
    456 		genssa_crypto_rsa
    457 	else
    458 		gensrcs_crypto_rsa +test/core_test.ha +test/keys_test.ha \
    459 			+test/pkcs1_test.ha
    460 		genssa_crypto_rsa
    461 	fi
    462 }
    463 
    464 crypto_salsa() {
    465 	if [ $testing -eq 0 ]
    466 	then
    467 		gen_srcs crypto::salsa salsa20.ha
    468 		gen_ssa crypto::salsa bytes crypto::cipher crypto::math endian \
    469 			io
    470 	else
    471 		gen_srcs crypto::salsa salsa20.ha +test.ha
    472 		gen_ssa crypto::salsa bytes crypto::cipher crypto::math \
    473 			endian io memio types
    474 	fi
    475 }
    476 
    477 gensrcs_crypto_sha256() {
    478 	gen_srcs crypto::sha256 \
    479 		sha256.ha \
    480 		$*
    481 }
    482 
    483 genssa_crypto_sha256() {
    484 	gen_ssa crypto::sha256 crypto::math bytes hash io endian $*
    485 }
    486 
    487 crypto_sha256() {
    488 	if [ $testing -eq 0 ]
    489 	then
    490 		gensrcs_crypto_sha256
    491 		genssa_crypto_sha256
    492 	else
    493 		gensrcs_crypto_sha256 \
    494 			+test.ha
    495 		genssa_crypto_sha256 fmt strings encoding::hex
    496 	fi
    497 }
    498 
    499 crypto_sha1() {
    500 	if [ $testing -eq 0 ]
    501 	then
    502 		gen_srcs crypto::sha1 sha1.ha
    503 		gen_ssa crypto::sha1 crypto::math bytes hash io endian
    504 	else
    505 		gen_srcs crypto::sha1 sha1.ha +test.ha
    506 		gen_ssa crypto::sha1 crypto::math bytes hash endian fmt strings encoding::hex
    507 	fi
    508 }
    509 
    510 crypto_sha512() {
    511 	if [ $testing -eq 0 ]
    512 	then
    513 		gen_srcs crypto::sha512 sha512.ha
    514 		gen_ssa crypto::sha512 crypto::math bytes hash io endian
    515 	else
    516 		gen_srcs crypto::sha512 sha512.ha +test.ha
    517 		gen_ssa crypto::sha512 crypto::math bytes hash endian fmt strings encoding::hex
    518 	fi
    519 }
    520 
    521 crypto_curve25519() {
    522 	if [ $testing -eq 0 ]
    523 	then
    524 		gen_srcs crypto::curve25519 curve25519.ha
    525 		gen_ssa crypto::curve25519 bytes
    526 	else
    527 		gen_srcs crypto::curve25519 curve25519.ha +test.ha
    528 		gen_ssa crypto::curve25519 bytes fmt io encoding::hex crypto::random
    529 	fi
    530 }
    531 
    532 crypto_ed25519() {
    533 	if [ $testing -eq 0 ]
    534 	then
    535 		gen_srcs crypto::ed25519 ed25519.ha edwards25519.ha
    536 		gen_ssa crypto::ed25519 bytes crypto::sha512 hash
    537 	else
    538 		gen_srcs crypto::ed25519 ed25519.ha edwards25519.ha +test.ha
    539 		gen_ssa crypto::ed25519 bytes crypto::sha512 hash encoding::hex strings
    540 	fi
    541 }
    542 
    543 crypto_x25519() {
    544 	if [ $testing -eq 0 ]
    545 	then
    546 		gen_srcs crypto::x25519 x25519.ha
    547 		gen_ssa crypto::x25519 crypto::curve25519
    548 	else
    549 		gen_srcs crypto::x25519 x25519.ha +test.ha
    550 		gen_ssa crypto::x25519 bytes crypto::curve25519 encoding::hex \
    551 			crypto::random
    552 	fi
    553 }
    554 
    555 datetime() {
    556 	gen_srcs -plinux datetime \
    557 		arithmetic.ha \
    558 		chronology.ha \
    559 		errors.ha \
    560 		date.ha \
    561 		datetime.ha \
    562 		duration.ha \
    563 		format.ha \
    564 		parse.ha \
    565 		period.ha \
    566 		reckon.ha \
    567 		time.ha \
    568 		timezone.ha \
    569 		virtual.ha
    570 	gen_ssa -plinux datetime ascii errors fmt io strconv strings memio \
    571 		time time::chrono
    572 	gen_srcs -pfreebsd datetime \
    573 		arithmetic.ha \
    574 		chronology.ha \
    575 		errors.ha \
    576 		date.ha \
    577 		datetime.ha \
    578 		duration.ha \
    579 		format.ha \
    580 		parse.ha \
    581 		period.ha \
    582 		reckon.ha \
    583 		time.ha \
    584 		timezone.ha \
    585 		virtual.ha
    586 	gen_ssa -pfreebsd datetime ascii errors fmt io strconv strings memio \
    587 		time time::chrono
    588 }
    589 
    590 dirs() {
    591 	gen_srcs dirs \
    592 		xdg.ha
    593 	gen_ssa dirs errors fs io os path fmt unix
    594 }
    595 
    596 encoding_base64() {
    597 	gen_srcs encoding::base64 \
    598 		base64.ha
    599 	gen_ssa encoding::base64 ascii bytes errors io os strings memio
    600 }
    601 
    602 encoding_base32() {
    603 	gen_srcs encoding::base32 \
    604 		base32.ha
    605 	gen_ssa encoding::base32 ascii bytes errors io strings os memio
    606 }
    607 
    608 encoding_hex() {
    609 	gen_srcs encoding::hex \
    610 		hex.ha
    611 	gen_ssa encoding::hex ascii bytes errors fmt io strconv memio \
    612 		strings
    613 }
    614 
    615 encoding_pem() {
    616 	if [ $testing -eq 0 ]
    617 	then
    618 		gen_srcs encoding::pem \
    619 			pem.ha
    620 		gen_ssa encoding::pem strings memio io errors \
    621 			encoding::base64 ascii os fmt
    622 	else
    623 		gen_srcs encoding::pem \
    624 			pem.ha \
    625 			+test.ha
    626 		gen_ssa encoding::pem strings memio io errors \
    627 			encoding::base64 ascii os fmt bytes
    628 	fi
    629 }
    630 
    631 encoding_utf8() {
    632 	gen_srcs encoding::utf8 \
    633 		decode.ha \
    634 		decodetable.ha \
    635 		encode.ha \
    636 		rune.ha
    637 	gen_ssa encoding::utf8 types
    638 }
    639 
    640 endian() {
    641 	gen_srcs endian \
    642 		big.ha \
    643 		network.ha \
    644 		little.ha \
    645 		endian.ha \
    646 		'host+$(ARCH).ha'
    647 	gen_ssa endian
    648 }
    649 
    650 errors() {
    651 	gen_srcs errors \
    652 		common.ha \
    653 		opaque.ha \
    654 		string.ha \
    655 		rt.ha
    656 	gen_ssa errors rt
    657 }
    658 
    659 fmt() {
    660 	gen_srcs fmt \
    661 		fmt.ha
    662 	gen_ssa fmt ascii encoding::utf8 io memio os strconv strings types
    663 }
    664 
    665 fnmatch() {
    666 	if [ $testing -eq 0 ]
    667 	then
    668 		gen_srcs fnmatch fnmatch.ha
    669 	else
    670 		gen_srcs fnmatch fnmatch.ha +test.ha
    671 	fi
    672 	gen_ssa fnmatch ascii errors strings sort
    673 }
    674 
    675 format_elf() {
    676 	gen_srcs format::elf \
    677 		'arch+$(ARCH).ha' \
    678 		'platform+$(PLATFORM).ha' \
    679 		types.ha
    680 	gen_ssa format::elf
    681 }
    682 
    683 gensrcs_format_ini() {
    684 	gen_srcs format::ini \
    685 		scan.ha \
    686 		types.ha \
    687 		$*
    688 }
    689 
    690 format_ini() {
    691 	if [ $testing -eq 0 ]
    692 	then
    693 		gensrcs_format_ini
    694 	else
    695 		gensrcs_format_ini +test.ha
    696 	fi
    697 	gen_ssa format::ini encoding::utf8 fmt io memio strings
    698 }
    699 
    700 format_tar() {
    701 	gen_srcs format::tar \
    702 		types.ha \
    703 		reader.ha
    704 	gen_ssa format::tar bytes endian errors io strconv memio types::c
    705 }
    706 
    707 fs() {
    708 	gen_srcs fs \
    709 		types.ha \
    710 		fs.ha \
    711 		util.ha
    712 	gen_ssa fs io strings path time errors
    713 }
    714 
    715 getopt() {
    716 	gen_srcs getopt \
    717 		getopts.ha
    718 	gen_ssa getopt encoding::utf8 fmt io os strings
    719 }
    720 
    721 glob() {
    722 	if [ $testing -eq 0 ]
    723 	then
    724 		gen_srcs glob glob.ha
    725 	else
    726 		gen_srcs glob glob.ha +test.ha
    727 	fi
    728 	gen_ssa glob fnmatch fs io os sort strings memio
    729 }
    730 
    731 hare_ast() {
    732 	gen_srcs hare::ast \
    733 		decl.ha \
    734 		expr.ha \
    735 		ident.ha \
    736 		import.ha \
    737 		type.ha \
    738 		unit.ha
    739 	gen_ssa hare::ast hare::lex strings
    740 }
    741 
    742 gensrcs_hare_lex() {
    743 	gen_srcs hare::lex \
    744 		token.ha \
    745 		lex.ha \
    746 		$*
    747 }
    748 
    749 hare_lex() {
    750 	if [ $testing -eq 0 ]
    751 	then
    752 		gensrcs_hare_lex
    753 	else
    754 		gensrcs_hare_lex \
    755 			+test.ha
    756 	fi
    757 	gen_ssa hare::lex ascii io encoding::utf8 fmt memio sort \
    758 		strconv strings path
    759 }
    760 
    761 hare_module() {
    762 	gen_srcs hare::module \
    763 		types.ha \
    764 		context.ha \
    765 		scan.ha \
    766 		manifest.ha \
    767 		walk.ha
    768 	gen_ssa hare::module \
    769 		hare::ast hare::lex hare::parse hare::unparse memio fs io strings hash \
    770 		crypto::sha256 dirs bytes encoding::utf8 ascii fmt time bufio \
    771 		strconv os encoding::hex sort errors temp path
    772 }
    773 
    774 gensrcs_hare_parse() {
    775 	gen_srcs hare::parse \
    776 		decl.ha \
    777 		expr.ha \
    778 		ident.ha \
    779 		import.ha \
    780 		parse.ha \
    781 		type.ha \
    782 		unit.ha \
    783 		$*
    784 }
    785 
    786 hare_parse() {
    787 	if [ $testing -eq 0 ]
    788 	then
    789 		gensrcs_hare_parse
    790 		gen_ssa hare::parse ascii hare::ast hare::lex fmt types \
    791 			strings math
    792 	else
    793 		gensrcs_hare_parse \
    794 			+test/expr_test.ha \
    795 			+test/ident_test.ha \
    796 			+test/loc.ha \
    797 			+test/roundtrip.ha \
    798 			+test/types.ha \
    799 			+test/unit_test.ha
    800 		gen_ssa hare::parse ascii memio hare::ast hare::lex \
    801 			hare::unparse io fmt types strings math encoding::utf8
    802 	fi
    803 }
    804 
    805 gensrcs_hare_types() {
    806 	gen_srcs hare::types \
    807 		'+$(ARCH)/writesize.ha' \
    808 		arch.ha \
    809 		builtins.ha \
    810 		class.ha \
    811 		hash.ha \
    812 		lookup.ha \
    813 		store.ha \
    814 		types.ha \
    815 		$*
    816 }
    817 
    818 hare_types() {
    819 	if [ $testing -eq 1 ]
    820 	then
    821 		gensrcs_hare_types +test.ha
    822 		gen_ssa hare::types hare::ast hash hash::fnv endian strings \
    823 			errors sort fmt hare::lex hare::parse io
    824 	else
    825 		gensrcs_hare_types
    826 		gen_ssa hare::types hare::ast hash hash::fnv endian strings \
    827 			errors memio sort fmt
    828 	fi
    829 }
    830 
    831 gensrcs_hare_unit() {
    832 	gen_srcs hare::unit \
    833 		check.ha \
    834 		context.ha \
    835 		errors.ha \
    836 		expr.ha \
    837 		process.ha \
    838 		scan.ha \
    839 		scope.ha \
    840 		unit.ha \
    841 		$*
    842 }
    843 
    844 hare_unit() {
    845 	if [ $testing -eq 1 ]
    846 	then
    847 		gensrcs_hare_unit +test.ha
    848 		gen_ssa hare::unit hare::ast hare::types hash hash::fnv \
    849 			strings hare::lex hare::parse memio
    850 	else
    851 		gensrcs_hare_unit
    852 		gen_ssa hare::unit hare::ast hare::types hash hash::fnv \
    853 			strings hare::lex memio
    854 	fi
    855 }
    856 
    857 hare_unparse() {
    858 	gen_srcs hare::unparse \
    859 		expr.ha \
    860 		decl.ha \
    861 		ident.ha \
    862 		import.ha \
    863 		type.ha \
    864 		unit.ha \
    865 		util.ha
    866 	gen_ssa hare::unparse fmt io strings memio hare::ast hare::lex
    867 }
    868 
    869 hash() {
    870 	gen_srcs hash \
    871 		hash.ha
    872 	gen_ssa hash crypto::math io fmt
    873 }
    874 
    875 hash_adler32() {
    876 	gen_srcs hash::adler32 \
    877 		adler32.ha
    878 	gen_ssa hash::adler32 endian hash io strings
    879 }
    880 
    881 hash_crc16() {
    882 	gen_srcs hash::crc16 \
    883 		crc16.ha
    884 	gen_ssa hash::crc16 endian hash io strings
    885 }
    886 
    887 hash_crc32() {
    888 	gen_srcs hash::crc32 \
    889 		crc32.ha
    890 	gen_ssa hash::crc32 endian hash io strings
    891 }
    892 
    893 hash_crc64() {
    894 	gen_srcs hash::crc64 \
    895 		crc64.ha
    896 	gen_ssa hash::crc64 endian hash io strings
    897 }
    898 
    899 hash_fnv() {
    900 	gen_srcs hash::fnv \
    901 		'+$(ARCH).ha' \
    902 		fnv.ha
    903 	gen_ssa hash::fnv endian hash io strings
    904 }
    905 
    906 hash_siphash() {
    907 	if [ $testing -eq 0 ]
    908 	then
    909 		gen_srcs hash::siphash siphash.ha
    910 		gen_ssa hash::siphash hash io endian crypto::math
    911 	else
    912 		gen_srcs hash::siphash siphash.ha +test.ha
    913 		gen_ssa hash::siphash hash io endian crypto::math \
    914 			fmt memio strings
    915 	fi
    916 }
    917 
    918 gensrcs_io() {
    919 	gen_srcs -plinux io \
    920 		'arch+$(ARCH).ha' \
    921 		+linux/mmap.ha \
    922 		+linux/platform_file.ha \
    923 		+linux/vector.ha \
    924 		copy.ha \
    925 		drain.ha \
    926 		empty.ha \
    927 		file.ha \
    928 		handle.ha \
    929 		limit.ha \
    930 		stream.ha \
    931 		tee.ha \
    932 		types.ha \
    933 		util.ha \
    934 		zero.ha \
    935 		$*
    936 	gen_srcs -pfreebsd io \
    937 		'arch+$(ARCH).ha' \
    938 		+freebsd/mmap.ha \
    939 		+freebsd/platform_file.ha \
    940 		+freebsd/vector.ha \
    941 		copy.ha \
    942 		drain.ha \
    943 		empty.ha \
    944 		file.ha \
    945 		handle.ha \
    946 		limit.ha \
    947 		stream.ha \
    948 		tee.ha \
    949 		types.ha \
    950 		util.ha \
    951 		zero.ha \
    952 		$*
    953 }
    954 
    955 io() {
    956 	if [ $testing -eq 0 ]
    957 	then
    958 		gensrcs_io
    959 	else
    960 		gensrcs_io \
    961 			+test/limit_test.ha \
    962 			+test/stream_test.ha
    963 	fi
    964 	gen_ssa -plinux io strings errors bytes rt
    965 	gen_ssa -pfreebsd io strings errors bytes rt
    966 }
    967 
    968 linux() {
    969 	gen_srcs -plinux linux \
    970 		start.ha \
    971 		env.ha
    972 	gen_ssa -plinux linux format::elf rt
    973 }
    974 
    975 linux_keyctl() {
    976 	gen_srcs -plinux linux::keyctl \
    977 		keyctl.ha \
    978 		types.ha
    979 	gen_ssa -plinux linux::keyctl rt errors bytes types::c
    980 }
    981 
    982 linux_timerfd() {
    983 	gen_srcs -plinux linux::timerfd \
    984 		timerfd.ha
    985 	gen_ssa -plinux linux::timerfd errors rt time io endian
    986 }
    987 
    988 linux_vdso() {
    989 	gen_srcs -plinux linux::vdso \
    990 		vdso.ha
    991 	gen_ssa -plinux linux::vdso linux format::elf types::c
    992 }
    993 
    994 log() {
    995 	gen_srcs -plinux log logger.ha global.ha funcs.ha silent.ha
    996 	gen_ssa -plinux log fmt io os time::date
    997 	gen_srcs -pfreebsd log logger.ha global.ha funcs.ha silent.ha
    998 	gen_ssa -pfreebsd log fmt io os time::date
    999 }
   1000 
   1001 gensrcs_math() {
   1002 	gen_srcs math \
   1003 		math.ha \
   1004 		fenv_func.ha \
   1005 		'fenv+$(ARCH).ha' \
   1006 		floats.ha  \
   1007 		ints.ha \
   1008 		uints.ha \
   1009 		trig.ha \
   1010 		$*
   1011 }
   1012 
   1013 math() {
   1014 	if [ $testing -eq 0 ]; then
   1015 		gensrcs_math
   1016 	else
   1017 		gensrcs_math \
   1018 			+test/data.ha \
   1019 			+test/math_test.ha \
   1020 			+test/floats_test.ha \
   1021 			+test/trig_test.ha
   1022 	fi
   1023 	gen_ssa math types rt
   1024 }
   1025 
   1026 math_checked() {
   1027 	gen_srcs math::checked checked.ha
   1028 	gen_ssa math::checked math
   1029 }
   1030 
   1031 mime() {
   1032 	# This module is not built by default because gen-stdlib does not do a good
   1033 	# job of resolving @init dependency ordering issues
   1034 	if [ $testing -eq 0 ]; then
   1035 		gen_srcs mime \
   1036 			database.ha \
   1037 			lookup.ha \
   1038 			parse.ha \
   1039 			system.ha
   1040 	else
   1041 		gen_srcs mime \
   1042 			database.ha \
   1043 			lookup.ha \
   1044 			parse.ha \
   1045 			system.ha \
   1046 			entries+test.ha
   1047 	fi
   1048 	gen_ssa mime ascii errors strings hash::fnv encoding::utf8 bufio \
   1049 		fs io os fmt
   1050 }
   1051 
   1052 net() {
   1053 	gen_srcs -plinux net \
   1054 		+linux.ha \
   1055 		errors.ha \
   1056 		msg.ha \
   1057 		types.ha
   1058 	gen_ssa -plinux net io errors rt fmt
   1059 
   1060 	gen_srcs -pfreebsd net \
   1061 		+freebsd.ha \
   1062 		errors.ha \
   1063 		msg.ha \
   1064 		types.ha
   1065 	gen_ssa -pfreebsd net io errors rt fmt
   1066 }
   1067 
   1068 net_dial() {
   1069 	gen_srcs net::dial \
   1070 		registry.ha \
   1071 		dial.ha \
   1072 		ip.ha \
   1073 		resolve.ha
   1074 	gen_ssa net::dial net net::ip net::tcp net::udp net::dns net::uri \
   1075 		crypto::random strconv strings unix::hosts
   1076 }
   1077 
   1078 net_dns() {
   1079 	gen_srcs net::dns \
   1080 		decode.ha \
   1081 		error.ha \
   1082 		encode.ha \
   1083 		query.ha \
   1084 		strdomain.ha \
   1085 		types.ha
   1086 	gen_ssa net::dns ascii endian net net::udp net::ip fmt strings \
   1087 		unix::resolvconf unix::poll time errors
   1088 }
   1089 
   1090 gensrcs_net_ip() {
   1091 	gen_srcs -plinux net::ip \
   1092 		+linux.ha \
   1093 		ip.ha \
   1094 		$*
   1095 	gen_srcs -pfreebsd net::ip \
   1096 		+freebsd.ha \
   1097 		ip.ha \
   1098 		$*
   1099 }
   1100 
   1101 net_ip() {
   1102 	if [ $testing -eq 0 ]
   1103 	then
   1104 		gensrcs_net_ip
   1105 	else
   1106 		gensrcs_net_ip \
   1107 			test+test.ha
   1108 	fi
   1109 	gen_ssa -plinux net::ip bytes endian io strconv strings memio fmt
   1110 	gen_ssa -pfreebsd net::ip bytes endian io strconv strings memio fmt
   1111 }
   1112 
   1113 net_tcp() {
   1114 	gen_srcs -plinux net::tcp \
   1115 		+linux.ha \
   1116 		listener.ha \
   1117 		options.ha
   1118 	gen_ssa -plinux net::tcp errors io net net::ip os rt
   1119 
   1120 	gen_srcs -pfreebsd net::tcp \
   1121 		+freebsd.ha \
   1122 		listener.ha \
   1123 		options.ha
   1124 	gen_ssa -pfreebsd net::tcp errors io net net::ip os rt
   1125 }
   1126 
   1127 net_udp() {
   1128 	gen_srcs -plinux net::udp \
   1129 		+linux.ha \
   1130 		options.ha
   1131 	gen_ssa -plinux net::udp errors net net::ip errors rt os io
   1132 
   1133 	gen_srcs -pfreebsd net::udp \
   1134 		+freebsd.ha \
   1135 		options.ha
   1136 	gen_ssa -pfreebsd net::udp errors net net::ip errors rt os io
   1137 }
   1138 
   1139 net_unix() {
   1140 	gen_srcs -plinux net::unix \
   1141 		+linux.ha \
   1142 		addr.ha \
   1143 		cmsg.ha \
   1144 		dial.ha \
   1145 		listener.ha \
   1146 		options.ha \
   1147 		socketpair.ha
   1148 	gen_ssa -plinux net::unix net errors os io strings types fmt \
   1149 		net::dial rt
   1150 
   1151 	gen_srcs -pfreebsd net::unix \
   1152 		+freebsd.ha \
   1153 		addr.ha \
   1154 		cmsg.ha \
   1155 		dial.ha \
   1156 		listener.ha \
   1157 		options.ha \
   1158 		socketpair.ha
   1159 	gen_ssa -pfreebsd net::unix net errors os io strings types fmt \
   1160 		net::dial rt
   1161 }
   1162 
   1163 gensrcs_net_uri() {
   1164 	gen_srcs net::uri \
   1165 		fmt.ha \
   1166 		parse.ha \
   1167 		query.ha \
   1168 		uri.ha \
   1169 		$*
   1170 }
   1171 
   1172 net_uri() {
   1173 	if [ $testing -eq 0 ]
   1174 	then
   1175 		gensrcs_net_uri
   1176 	else
   1177 		gensrcs_net_uri \
   1178 			+test.ha
   1179 	fi
   1180 	gen_ssa net::uri \
   1181 		ascii encoding::utf8 fmt io net::ip strconv strings memio
   1182 }
   1183 
   1184 gensrcs_math_complex() {
   1185 	gen_srcs math::complex \
   1186 		complex.ha \
   1187 		$*
   1188 }
   1189 
   1190 math_complex() {
   1191 	if [ $testing -eq 0 ]
   1192 	then
   1193 		gensrcs_math_complex
   1194 	else
   1195 		gensrcs_math_complex \
   1196 			+test.ha
   1197 	fi
   1198 	gen_ssa math::complex math
   1199 }
   1200 
   1201 math_random() {
   1202 	gen_srcs math::random \
   1203 		random.ha
   1204 	gen_ssa math::random
   1205 }
   1206 
   1207 os() {
   1208 	if [ $testing -eq 0 ]
   1209 	then
   1210 		exit=exit.ha
   1211 	else
   1212 		exit=exit+test.ha
   1213 	fi
   1214 
   1215 	gen_srcs -plinux os \
   1216 		+linux/dirfdfs.ha \
   1217 		+linux/platform_environ.ha \
   1218 		+linux/$exit \
   1219 		+linux/fs.ha \
   1220 		+linux/memory.ha \
   1221 		+linux/status.ha \
   1222 		+linux/stdfd.ha \
   1223 		environ.ha \
   1224 		os.ha
   1225 	gen_ssa -plinux os io strings fs encoding::utf8 bufio \
   1226 		errors math types::c
   1227 
   1228 	gen_srcs -pfreebsd os \
   1229 		+freebsd/platform_environ.ha \
   1230 		+freebsd/$exit \
   1231 		+freebsd/dirfdfs.ha \
   1232 		+freebsd/status.ha \
   1233 		+freebsd/stdfd.ha \
   1234 		+freebsd/fs.ha \
   1235 		environ.ha \
   1236 		os.ha
   1237 	gen_ssa -pfreebsd os io strings fs encoding::utf8 bufio \
   1238 		errors types::c
   1239 }
   1240 
   1241 os_exec() {
   1242 	gen_srcs -plinux os::exec \
   1243 		exec+linux.ha \
   1244 		process+linux.ha \
   1245 		types.ha \
   1246 		cmd.ha
   1247 	gen_ssa -plinux os::exec os strings fmt errors unix rt io ascii \
   1248 		unix::signal types::c time
   1249 
   1250 	gen_srcs -pfreebsd os::exec \
   1251 		exec+freebsd.ha \
   1252 		process+freebsd.ha \
   1253 		types.ha \
   1254 		cmd.ha
   1255 	gen_ssa -pfreebsd os::exec os strings fmt errors unix rt io ascii \
   1256 		unix::signal types::c time
   1257 }
   1258 
   1259 path() {
   1260 	gen_srcs path \
   1261 		'+$(PLATFORM).ha' \
   1262 		buffer.ha \
   1263 		error.ha \
   1264 		stack.ha \
   1265 		ext_stack.ha \
   1266 		posix.ha \
   1267 		prefix.ha \
   1268 		iter.ha
   1269 	gen_ssa path strings bytes errors
   1270 }
   1271 
   1272 regex() {
   1273 	if [ $testing -eq 0 ]; then
   1274 		gen_srcs regex regex.ha
   1275 		gen_ssa regex ascii bufio encoding::utf8 errors io strconv \
   1276 			strings bufio types memio
   1277 	else
   1278 		gen_srcs regex regex.ha +test.ha
   1279 		gen_ssa regex encoding::utf8 errors strconv strings fmt io os \
   1280 			bufio types memio
   1281 	fi
   1282 }
   1283 
   1284 gensrcs_strconv() {
   1285 	gen_srcs strconv \
   1286 		types.ha \
   1287 		itos.ha \
   1288 		utos.ha \
   1289 		stou.ha \
   1290 		stoi.ha \
   1291 		numeric.ha \
   1292 		ftos.ha \
   1293 		stof.ha \
   1294 		stof_data.ha \
   1295 		$*
   1296 }
   1297 
   1298 gensrcs_shlex() {
   1299 	gen_srcs shlex \
   1300 		escape.ha \
   1301 		split.ha \
   1302 		$*
   1303 }
   1304 
   1305 shlex() {
   1306 	if [ $testing -eq 0 ]
   1307 	then
   1308 		gensrcs_shlex
   1309 	else
   1310 		gensrcs_shlex \
   1311 			+test.ha
   1312 	fi
   1313 	gen_ssa shlex ascii encoding::utf8 io strings memio
   1314 }
   1315 
   1316 gensrcs_sort() {
   1317 	gen_srcs sort \
   1318 		bisect.ha \
   1319 		search.ha \
   1320 		sort.ha \
   1321 		types.ha \
   1322 		$*
   1323 }
   1324 
   1325 sort() {
   1326 	if [ $testing -eq 0 ]
   1327 	then
   1328 		gensrcs_sort
   1329 	else
   1330 		gensrcs_sort \
   1331 			+test.ha
   1332 	fi
   1333 	gen_ssa sort strings types
   1334 }
   1335 
   1336 strconv() {
   1337 	if [ $testing -eq 0 ]
   1338 	then
   1339 		gensrcs_strconv
   1340 	else
   1341 		gensrcs_strconv \
   1342 			+test/stou_test.ha \
   1343 			+test/stoi_test.ha
   1344 	fi
   1345 	gen_ssa strconv types strings ascii math bytes encoding::utf8
   1346 }
   1347 
   1348 strings() {
   1349 	gen_srcs strings \
   1350 		concat.ha \
   1351 		contains.ha \
   1352 		dup.ha \
   1353 		iter.ha \
   1354 		runes.ha \
   1355 		sub.ha \
   1356 		suffix.ha \
   1357 		tokenize.ha \
   1358 		utf8.ha \
   1359 		index.ha \
   1360 		trim.ha \
   1361 		compare.ha \
   1362 		pad.ha \
   1363 		replace.ha
   1364 	gen_ssa strings bytes encoding::utf8 types
   1365 }
   1366 
   1367 strings_template() {
   1368 	gen_srcs strings::template \
   1369 		template.ha
   1370 	gen_ssa strings::template ascii errors fmt io strings memio
   1371 }
   1372 
   1373 memio() {
   1374 	gen_srcs memio \
   1375 		stream.ha \
   1376 		ops.ha
   1377 	gen_ssa memio errors io strings encoding::utf8
   1378 }
   1379 
   1380 temp() {
   1381 	gen_srcs -plinux temp +linux.ha
   1382 	gen_ssa -plinux temp \
   1383 		crypto::random encoding::hex errors fs io os path memio fmt
   1384 
   1385 	gen_srcs -pfreebsd temp +freebsd.ha
   1386 	gen_ssa -pfreebsd temp \
   1387 		crypto::random encoding::hex errors fs io os path memio fmt
   1388 }
   1389 
   1390 time() {
   1391 	gen_srcs -plinux time \
   1392 		+linux/functions.ha \
   1393 		+linux/+'$(ARCH)'.ha \
   1394 		arithm.ha \
   1395 		conv.ha \
   1396 		types.ha
   1397 	gen_ssa -plinux time \
   1398 		linux::vdso math
   1399 	gen_srcs -pfreebsd time \
   1400 		+freebsd/functions.ha \
   1401 		arithm.ha \
   1402 		conv.ha \
   1403 		types.ha
   1404 	gen_ssa -pfreebsd time \
   1405 		math
   1406 }
   1407 
   1408 time_chrono() {
   1409 	gen_srcs -plinux time::chrono \
   1410 		arithmetic.ha \
   1411 		+linux.ha \
   1412 		chronology.ha \
   1413 		error.ha \
   1414 		leapsec.ha \
   1415 		timescale.ha \
   1416 		timezone.ha \
   1417 		tzdb.ha
   1418 	gen_ssa -plinux time::chrono \
   1419 		bufio bytes encoding::utf8 endian errors fmt fs io os strconv strings time path
   1420 	gen_srcs -pfreebsd time::chrono \
   1421 		arithmetic.ha \
   1422 		+freebsd.ha \
   1423 		chronology.ha \
   1424 		error.ha \
   1425 		leapsec.ha \
   1426 		timescale.ha \
   1427 		timezone.ha \
   1428 		tzdb.ha
   1429 	gen_ssa -pfreebsd time::chrono \
   1430 		bufio bytes encoding::utf8 endian errors fmt fs io os strconv strings time path
   1431 }
   1432 
   1433 time_date() {
   1434 	gen_srcs -plinux time::date \
   1435 		date.ha \
   1436 		daydate.ha \
   1437 		daytime.ha \
   1438 		error.ha \
   1439 		format.ha \
   1440 		locality.ha \
   1441 		observe.ha \
   1442 		parithm.ha \
   1443 		parse.ha \
   1444 		period.ha \
   1445 		reckon.ha \
   1446 		tarithm.ha \
   1447 		virtual.ha
   1448 	gen_ssa -plinux time::date \
   1449 		ascii errors fmt io strconv strings memio time time::chrono
   1450 	gen_srcs -pfreebsd time::date \
   1451 		date.ha \
   1452 		daydate.ha \
   1453 		daytime.ha \
   1454 		error.ha \
   1455 		format.ha \
   1456 		locality.ha \
   1457 		observe.ha \
   1458 		parithm.ha \
   1459 		parse.ha \
   1460 		period.ha \
   1461 		reckon.ha \
   1462 		tarithm.ha \
   1463 		virtual.ha
   1464 	gen_ssa -pfreebsd time::date \
   1465 		ascii errors fmt io strconv strings memio time time::chrono
   1466 }
   1467 
   1468 types() {
   1469 	gen_srcs types \
   1470 		limits.ha \
   1471 		classes.ha \
   1472 		'arch+$(ARCH).ha'
   1473 	gen_ssa types
   1474 }
   1475 
   1476 types_c() {
   1477 	if [ $testing -eq 1 ]
   1478 	then
   1479 		gen_srcs types::c +test.ha strings.ha types.ha 'arch+$(ARCH).ha'
   1480 	else
   1481 		gen_srcs types::c strings.ha types.ha 'arch+$(ARCH).ha'
   1482 	fi
   1483 	gen_ssa types::c encoding::utf8 types
   1484 }
   1485 
   1486 unix() {
   1487 	gen_srcs -plinux unix \
   1488 		+linux/nice.ha \
   1489 		+linux/pipe.ha \
   1490 		+linux/umask.ha \
   1491 		+linux/getuid.ha \
   1492 		+linux/setuid.ha \
   1493 		+linux/groups.ha
   1494 	gen_ssa -plinux unix errors fs io
   1495 
   1496 	gen_srcs -pfreebsd unix \
   1497 		+freebsd/nice.ha \
   1498 		+freebsd/pipe.ha \
   1499 		+freebsd/umask.ha \
   1500 		+freebsd/getuid.ha \
   1501 		+freebsd/setuid.ha \
   1502 		+freebsd/groups.ha
   1503 	gen_ssa -pfreebsd unix errors fs io
   1504 }
   1505 
   1506 unix_hosts() {
   1507 	if [ $testing -eq 0 ]
   1508 	then
   1509     		gen_srcs -plinux unix::hosts \
   1510     			+linux.ha \
   1511     			hosts.ha
   1512     		gen_ssa -plinux unix::hosts bufio encoding::utf8 fs io \
   1513     			net::ip os strings memio
   1514 
   1515     		gen_srcs -pfreebsd unix::hosts \
   1516     			+freebsd.ha \
   1517     			hosts.ha
   1518     		gen_ssa -pfreebsd unix::hosts bufio encoding::utf8 fs io \
   1519     			net::ip os strings memio
   1520 	else
   1521     		gen_srcs -plinux unix::hosts \
   1522     			+linux.ha \
   1523     			test+test.ha \
   1524     			hosts.ha
   1525     		gen_ssa -plinux unix::hosts bufio encoding::utf8 fs io \
   1526     			net::ip os strings memio
   1527 
   1528     		gen_srcs -pfreebsd unix::hosts \
   1529     			+freebsd.ha \
   1530     			test+test.ha \
   1531     			hosts.ha
   1532     		gen_ssa -pfreebsd unix::hosts bufio encoding::utf8 fs io \
   1533     			net::ip os strings memio
   1534 	fi
   1535 }
   1536 
   1537 unix_passwd() {
   1538 	gen_srcs unix::passwd \
   1539 		group.ha \
   1540 		passwd.ha \
   1541 		types.ha
   1542 	gen_ssa unix::passwd bufio io os strconv strings memio
   1543 }
   1544 
   1545 unix_poll() {
   1546 	gen_srcs -plinux unix::poll +linux.ha types.ha
   1547 	gen_ssa -plinux unix::poll rt errors time io
   1548 
   1549 	gen_srcs -pfreebsd unix::poll +freebsd.ha types.ha
   1550 	gen_ssa -pfreebsd unix::poll rt errors time io
   1551 }
   1552 
   1553 unix_resolvconf() {
   1554 	gen_srcs -plinux unix::resolvconf \
   1555 		+linux.ha \
   1556 		load.ha
   1557 	gen_ssa -plinux unix::resolvconf os io bufio memio net::ip strings
   1558 
   1559 	gen_srcs -pfreebsd unix::resolvconf \
   1560 		+freebsd.ha \
   1561 		load.ha
   1562 	gen_ssa -pfreebsd unix::resolvconf os io bufio memio net::ip strings
   1563 }
   1564 
   1565 unix_signal() {
   1566 	gen_srcs -plinux unix::signal \
   1567 		types.ha \
   1568 		+linux.ha
   1569 	gen_ssa -plinux unix::signal io errors rt
   1570 
   1571 	gen_srcs -pfreebsd unix::signal \
   1572 		types.ha \
   1573 		+freebsd.ha
   1574 	gen_ssa -pfreebsd unix::signal io errors rt
   1575 }
   1576 
   1577 unix_tty() {
   1578 	gen_srcs -plinux unix::tty \
   1579 		types.ha \
   1580 		pty_common.ha \
   1581 		+linux/isatty.ha \
   1582 		+linux/open.ha \
   1583 		+linux/pty.ha \
   1584 		+linux/termios.ha \
   1585 		+linux/winsize.ha
   1586 	gen_ssa -plinux unix::tty bufio errors fmt fs io os rt strings
   1587 
   1588 	gen_srcs -pfreebsd unix::tty \
   1589 		types.ha \
   1590 		pty_common.ha \
   1591 		+freebsd/isatty.ha \
   1592 		+freebsd/open.ha \
   1593 		+freebsd/pty.ha \
   1594 		+freebsd/winsize.ha
   1595 	gen_ssa -pfreebsd unix::tty bufio errors fmt fs io os rt strings \
   1596 		types::c
   1597 }
   1598 
   1599 uuid() {
   1600 	gen_srcs uuid \
   1601 		uuid.ha
   1602 	gen_ssa uuid crypto::random fmt endian io bytes memio strings strconv
   1603 }
   1604 
   1605 # List of modules and their supported platforms. Place a tab between the module
   1606 # and its platform list, and spaces between each supported platform. Omitting
   1607 # the platform list implies all platforms are supported.
   1608 modules="ascii
   1609 bufio
   1610 bytes
   1611 crypto
   1612 crypto::aes
   1613 crypto::aes::xts
   1614 crypto::argon2
   1615 crypto::bcrypt
   1616 crypto::blake2b
   1617 crypto::blowfish
   1618 crypto::bigint
   1619 crypto::chacha
   1620 crypto::chachapoly
   1621 crypto::cipher
   1622 crypto::hkdf
   1623 crypto::hmac
   1624 crypto::mac
   1625 crypto::math
   1626 crypto::random	linux freebsd
   1627 crypto::rsa
   1628 crypto::poly1305
   1629 crypto::salsa
   1630 crypto::sha1
   1631 crypto::sha256
   1632 crypto::sha512
   1633 crypto::curve25519
   1634 crypto::ed25519
   1635 crypto::x25519
   1636 dirs
   1637 encoding::base64
   1638 encoding::base32
   1639 encoding::hex
   1640 encoding::pem
   1641 encoding::utf8
   1642 endian
   1643 errors
   1644 fmt
   1645 fnmatch
   1646 format::elf
   1647 format::ini
   1648 format::tar
   1649 fs
   1650 getopt
   1651 glob
   1652 hare::ast
   1653 hare::lex
   1654 hare::module
   1655 hare::parse
   1656 hare::types
   1657 hare::unit
   1658 hare::unparse
   1659 hash
   1660 hash::adler32
   1661 hash::crc16
   1662 hash::crc32
   1663 hash::crc64
   1664 hash::fnv
   1665 hash::siphash
   1666 io			linux freebsd
   1667 linux			linux
   1668 linux::keyctl		linux
   1669 linux::timerfd	linux
   1670 linux::vdso		linux
   1671 log	linux freebsd
   1672 math
   1673 math::checked
   1674 math::complex
   1675 math::random
   1676 memio
   1677 net			linux freebsd
   1678 net::dial
   1679 net::dns
   1680 net::ip			linux freebsd
   1681 net::tcp		linux freebsd
   1682 net::udp		linux freebsd
   1683 net::unix		linux freebsd
   1684 net::uri
   1685 os			linux freebsd
   1686 os::exec		linux freebsd
   1687 path
   1688 regex
   1689 shlex
   1690 sort
   1691 strconv
   1692 strings
   1693 strings::template
   1694 temp			linux freebsd
   1695 test
   1696 time			linux freebsd
   1697 time::chrono	linux freebsd
   1698 time::date	linux freebsd
   1699 types
   1700 types::c
   1701 unix			linux freebsd
   1702 unix::hosts	linux freebsd
   1703 unix::passwd
   1704 unix::poll		linux freebsd
   1705 unix::resolvconf	linux freebsd
   1706 unix::signal		linux freebsd
   1707 unix::tty		linux freebsd
   1708 uuid"
   1709 stdlib() {
   1710 	rt
   1711 	IFS="
   1712 "
   1713 	for module in $modules; do
   1714 		unset IFS
   1715 		if [ -z "$(echo "$module" | cut -sf1)" ]
   1716 		then
   1717 			gen_lib "$module"
   1718 		else
   1719 			platforms="$(echo "$module" | cut -sf2-)"
   1720 			module="$(echo "$module" | cut -sf1)"
   1721 			for platform in $platforms
   1722 			do
   1723 				gen_lib -p "$platform" "$module"
   1724 			done
   1725 		fi
   1726 		IFS="
   1727 "
   1728 	done
   1729 	IFS="
   1730 "
   1731 	for module in $modules; do
   1732 		unset IFS
   1733 		if [ -n "$(echo "$module" | cut -sf1)" ]
   1734 		then
   1735 			module="$(echo "$module" | cut -sf1)"
   1736 		fi
   1737 		"$(mod_file "$module")"
   1738 		IFS="
   1739 "
   1740 	done
   1741 	unset IFS
   1742 }
   1743 
   1744 if [ ${DOCS:-0} -ne 1 ]
   1745 then
   1746 	printf '# This file is generated by the gen-stdlib script, do not edit it by hand\n\n'
   1747 	genrules
   1748 	genrules test
   1749 fi