shithub: femtolisp

ref: c164ffe64f6cff88a8115acf62dd0d9d64581982
dir: /meson.build/

View raw version
project(
	'femtolisp',
	'c',
	version: '0.999',
	meson_version: '>=1.1.0',
	default_options: [
		'c_std=c2x',
		'warning_level=3',
		'buildtype=debugoptimized',
		#'b_coverage=true',
	],
)

add_project_arguments(
	#'-Wconversion',
	#'-Wsign-conversion',
	'-Wmissing-prototypes',
	'-Werror=odr',
	'-Werror=strict-aliasing',
	'-Wno-parentheses',
	'-Wno-overlength-strings',
	'-D_DEFAULT_SOURCE',
	language: 'c',
)

src = [
	'3rd/mt19937-64.c',
	'3rd/mp/mpadd.c',
	'3rd/mp/mpaux.c',
	'3rd/mp/mpcmp.c',
	'3rd/mp/mpdigdiv.c',
	'3rd/mp/mpdiv.c',
	'3rd/mp/mpfmt.c',
	'3rd/mp/mpleft.c',
	'3rd/mp/mplogic.c',
	'3rd/mp/mpmul.c',
	'3rd/mp/mpright.c',
	'3rd/mp/mpsub.c',
	'3rd/mp/mptobe.c',
	'3rd/mp/mptober.c',
	'3rd/mp/mptod.c',
	'3rd/mp/mptoi.c',
	'3rd/mp/mptoui.c',
	'3rd/mp/mptouv.c',
	'3rd/mp/mptov.c',
	'3rd/mp/mpvecadd.c',
	'3rd/mp/mpveccmp.c',
	'3rd/mp/mpvecdigmuladd.c',
	'3rd/mp/mpvecsub.c',
	'3rd/mp/mpvectscmp.c',
	'3rd/mp/strtomp.c',
	'3rd/mp/u16.c',
	'3rd/mp/u32.c',
	'3rd/mp/u64.c',
	'3rd/utf/rune.c',
	'3rd/utf/runeistype.c',
	'3rd/utf/runetotype.c',
	'3rd/utf/utfnlen.c',
	'bitvector-ops.c',
	'bitvector.c',
	'builtins.c',
	'cvalues.c',
	'dump.c',
	'equal.c',
	'equalhash.c',
	'flisp.c',
	'flmain.c',
	'hashing.c',
	'htable.c',
	'ios.c',
	'iostream.c',
	'main_posix.c',
	'operators.c',
	'print.c',
	'ptrhash.c',
	'random.c',
	'read.c',
	'string.c',
	'table.c',
	'time_posix.c',
	'types.c',
	'utf8.c',
]

cc = meson.get_compiler('c')

bitreverse32_code = '''#include <stdio.h>
int main(int argc, char **argv) { return __builtin_bitreverse32(argc); }
'''
have_bitreverse32 = cc.links(bitreverse32_code, name: '__builtin_bitreverse32')

if have_bitreverse32
	add_project_arguments(
		'-DHAVE_BITREVERSE32',
		language: 'c',
	)
else
	src += ['bitreverse.c']
endif

if cc.get_id() == 'clang'
	add_project_arguments(
		'-D__wchar_t=__please_no_wchar_t_thank_you',
		language: 'c',
	)
else
	add_project_arguments(
		'-Werror=lto-type-mismatch',
		language: 'c',
	)
endif

sixel = get_option('sixel')

if sixel.disabled()
	libsixel_dep = []
	src += ['sixel_disabled.c']
else
	libsixel = dependency('libsixel', required: sixel)
	if libsixel.found()
		src += ['sixel.c']
		libsixel_dep = [libsixel]
	elif
		src += ['sixel_disabled.c']
	endif
endif

math = cc.find_library('m', required: false)

boot = custom_target(
	'boot',
	capture: true,
	input: [
		'flisp.boot',
	],
	output: [
		'flisp.boot.h',
	],
	command: [
		'boot2h.sh', '@INPUT@',
	],
)

builtins = custom_target(
	'builtins',
	capture: true,
	input: [
		src,
	],
	output: [
		'builtin_fns.h',
	],
	command: [
		'builtins2h.sh', '@INPUT@',
	],
)

flisp = executable(
	'flisp',
	sources: [
		src,
		boot,
		builtins,
	],
	dependencies: [
		math,
	] + libsixel_dep,
	include_directories: include_directories(
		'3rd',
		'3rd/mp',
		'3rd/utf',
		'posix',
	),
)

tests_dir = join_paths(meson.current_source_dir(), 'test')

test('argv', flisp, args: ['argv.lsp'], workdir: tests_dir)
test('hash', flisp, args: ['hashtest.lsp'], workdir: tests_dir)
test('perf', flisp, args: ['perf.lsp'], workdir: tests_dir)
test('tme', flisp, args: ['tme.lsp'], workdir: tests_dir)
test('torture', flisp, args: ['torture.scm'], workdir: tests_dir)
test('torus', flisp, args: ['torus.lsp'], workdir: tests_dir)
test('unit', flisp, args: ['unittest.lsp'], workdir: tests_dir)