# Files which are compiled once
src += files([
	'dilithium_consts_rvv.c',
	'dilithium_zetas_riscv64.c'
	])

# Files which are compiled for each Dilithium implementation separately
dilithium_riscv64_asm = files([
	'ntt_8l_dualissue_plant_rv64im.S'
])

if get_option('dilithium_keygen').enabled()
	dilithium_riscv64_asm += files([ 'dilithium_signature_keygen_riscv64.c' ])
endif
if get_option('dilithium_siggen').enabled()
	dilithium_riscv64_asm += files([ 'dilithium_signature_siggen_riscv64.c' ])
endif
if get_option('dilithium_sigver').enabled()
	dilithium_riscv64_asm += files([ 'dilithium_signature_sigver_riscv64.c' ])
endif

dilithium_riscv64_rvv_asm = files([
	'ntt_rvv.S'
])

if get_option('dilithium_keygen').enabled()
	dilithium_riscv64_rvv_asm += files([
		'dilithium_signature_keygen_riscv64_rvv.c'
	])
endif
if get_option('dilithium_siggen').enabled()
	dilithium_riscv64_rvv_asm += files([
		'dilithium_signature_siggen_riscv64_rvv.c'
	])
endif
if get_option('dilithium_sigver').enabled()
	dilithium_riscv64_rvv_asm += files([
		'dilithium_signature_sigver_riscv64_rvv.c'
	])
endif

if get_option('dilithium_87').enabled()
	leancrypto_dilithium_87_riscv64_lib = static_library(
		'leancrypto_dilithium_87_riscv64_lib',
		[ dilithium_riscv64_asm ],
		include_directories: [
			'../',
			include_dirs,
			include_internal_dirs
		],
		c_args: cc_riscv64_asm_args,
	)

	leancrypto_support_libs += leancrypto_dilithium_87_riscv64_lib

	leancrypto_dilithium_87_riscv64_rvv_lib = static_library(
		'leancrypto_dilithium_87_riscv64_rvv_lib',
		[ dilithium_riscv64_rvv_asm ],
		include_directories: [
			'../',
			include_dirs,
			include_internal_dirs
		],
		c_args: [ cc_riscv64_asm_rvv_args, '-DLC_DILITHIUM_RISCV64_RVV' ]
	)

	leancrypto_support_libs += leancrypto_dilithium_87_riscv64_rvv_lib
endif

if get_option('dilithium_65').enabled()
	leancrypto_dilithium_65_riscv64_lib = static_library(
		'leancrypto_dilithium_65_riscv64_lib',
		[ dilithium_riscv64_asm ],
		include_directories: [
			'../',
			include_dirs,
			include_internal_dirs
		],
		c_args: [ cc_riscv64_asm_args, '-DLC_DILITHIUM_TYPE_65' ]
	)

	leancrypto_support_libs += leancrypto_dilithium_65_riscv64_lib

	leancrypto_dilithium_65_riscv64_rvv_lib = static_library(
		'leancrypto_dilithium_65_riscv64_rvv_lib',
		[ dilithium_riscv64_rvv_asm ],
		include_directories: [
			'../',
			include_dirs,
			include_internal_dirs
		],
		c_args: [ cc_riscv64_asm_rvv_args, '-DLC_DILITHIUM_RISCV64_RVV',
			  '-DLC_DILITHIUM_TYPE_65' ]
	)

	leancrypto_support_libs += leancrypto_dilithium_65_riscv64_rvv_lib
endif

if get_option('dilithium_44').enabled()
	leancrypto_dilithium_44_riscv64_lib = static_library(
		'leancrypto_dilithium_44_riscv64_lib',
		[ dilithium_riscv64_asm ],
		include_directories: [
			'../',
			include_dirs,
			include_internal_dirs
		],
		c_args: [ cc_riscv64_asm_args, '-DLC_DILITHIUM_TYPE_44' ]
	)

	leancrypto_support_libs += leancrypto_dilithium_44_riscv64_lib

	leancrypto_dilithium_44_riscv64_rvv_lib = static_library(
		'leancrypto_dilithium_44_riscv64_rvv_lib',
		[ dilithium_riscv64_rvv_asm ],
		include_directories: [
			'../',
			include_dirs,
			include_internal_dirs
		],
		c_args: [ cc_riscv64_asm_rvv_args, '-DLC_DILITHIUM_RISCV64_RVV',
			  '-DLC_DILITHIUM_TYPE_44' ]
	)

	leancrypto_support_libs += leancrypto_dilithium_44_riscv64_rvv_lib
endif
