ansi_sources = files(
	'generic/stdlib.cpp',
	'generic/assert.cpp',
	'generic/complex.c',

	'generic/complex/csqrt.c',
	'generic/complex/csinhf.c',
	'generic/complex/ccoshf.c',
	'generic/complex/cacosh.c',
	'generic/complex/casinf.c',
	'generic/complex/clogf.c',
	'generic/complex/csqrtf.c',
	'generic/complex/cimag.c',
	'generic/complex/catanh.c',
	'generic/complex/carg.c',
	'generic/complex/cproj.c',
	'generic/complex/cephes_subr.c',
	'generic/complex/ccos.c',
	'generic/complex/cexp.c',
	'generic/complex/crealf.c',
	'generic/complex/cabs.c',
	'generic/complex/csinh.c',
	'generic/complex/casinhf.c',
	'generic/complex/cephes_subrf.c',
	'generic/complex/creal.c',
	'generic/complex/casin.c',
	'generic/complex/conjf.c',
	'generic/complex/cpowf.c',
	'generic/complex/cacosf.c',
	'generic/complex/csinf.c',
	'generic/complex/ctanh.c',
	'generic/complex/ctanhf.c',
	'generic/complex/cargf.c',
	'generic/complex/cabsf.c',
	'generic/complex/cpow.c',
	'generic/complex/csin.c',
	'generic/complex/cprojf.c',
	'generic/complex/catan.c',
	'generic/complex/ctanf.c',
	'generic/complex/ctan.c',
	'generic/complex/clog.c',
	'generic/complex/catanf.c',
	'generic/complex/cacos.c',
	'generic/complex/cexpf.c',
	'generic/complex/ccosh.c',
	'generic/complex/cimagf.c',
	'generic/complex/cacoshf.c',
	'generic/complex/conj.c',
	'generic/complex/catanhf.c',
	'generic/complex/ccosf.c',
	'generic/complex/casinh.c',

	'generic/ctype.cpp',
	'generic/environment.cpp',
	'generic/errno.cpp',
	'generic/fenv.cpp',
	'generic/file-io.cpp',
	'generic/inttypes.cpp',
	'generic/locale.cpp',
	'generic/signal.cpp',
	'generic/stdio.cpp',
	'generic/stdlib.cpp',
	'generic/string.cpp',
	'generic/threads.cpp',
	'generic/time.cpp',
	'generic/uchar.cpp',
	'generic/wchar.cpp',
	'generic/wctype.cpp',
)

if not no_headers
	install_headers(
		'include/alloca.h',
		'include/assert.h',
		'include/complex.h',
		'include/ctype.h',
		'include/errno.h',
		'include/fenv.h',
		'include/inttypes.h',
		'include/limits.h',
		'include/locale.h',
		'include/math.h',
		'include/setjmp.h',
		'include/signal.h',
		'include/stdc-predef.h',
		'include/stdio.h',
		'include/stdlib.h',
		'include/string.h',
		'include/threads.h',
		'include/time.h',
		'include/uchar.h',
		'include/wchar.h',
		'include/wctype.h',
	)
	install_headers(
		'include/bits/ansi/timespec.h',
		'include/bits/ansi/time_t.h',
		'include/bits/ansi/fenv.h',
		subdir: 'bits/ansi'
	)
endif

if not headers_only
	c_compiler = meson.get_compiler('c')

	if c_compiler.get_id() == 'gcc'
		compiler_c_args = ['-Wno-unused', '-Wno-maybe-uninitialized']
	elif c_compiler.get_id() == 'clang'
		compiler_c_args = ['-Wno-unused-parameter', '-Wno-unused-but-set-variable']
	endif

	libc_sublibs += static_library('mlibc-musl-math',
		'musl-generic-math/acos.c',
		'musl-generic-math/acosf.c',
		'musl-generic-math/acosh.c',
		'musl-generic-math/acoshf.c',
		'musl-generic-math/acoshl.c',
		'musl-generic-math/acosl.c',
		'musl-generic-math/asin.c',
		'musl-generic-math/asinf.c',
		'musl-generic-math/asinh.c',
		'musl-generic-math/asinhf.c',
		'musl-generic-math/asinhl.c',
		'musl-generic-math/asinl.c',
		'musl-generic-math/atan2.c',
		'musl-generic-math/atan2f.c',
		'musl-generic-math/atan2l.c',
		'musl-generic-math/atan.c',
		'musl-generic-math/atanf.c',
		'musl-generic-math/atanh.c',
		'musl-generic-math/atanhf.c',
		'musl-generic-math/atanhl.c',
		'musl-generic-math/atanl.c',
		'musl-generic-math/cbrt.c',
		'musl-generic-math/cbrtf.c',
		'musl-generic-math/cbrtl.c',
		'musl-generic-math/ceil.c',
		'musl-generic-math/ceilf.c',
		'musl-generic-math/ceill.c',
		'musl-generic-math/copysign.c',
		'musl-generic-math/copysignf.c',
		'musl-generic-math/copysignl.c',
		'musl-generic-math/__cos.c',
		'musl-generic-math/cos.c',
		'musl-generic-math/__cosdf.c',
		'musl-generic-math/cosf.c',
		'musl-generic-math/cosh.c',
		'musl-generic-math/coshf.c',
		'musl-generic-math/coshl.c',
		'musl-generic-math/__cosl.c',
		'musl-generic-math/cosl.c',
		'musl-generic-math/erf.c',
		'musl-generic-math/erff.c',
		'musl-generic-math/erfl.c',
		'musl-generic-math/exp10.c',
		'musl-generic-math/exp10f.c',
		'musl-generic-math/exp10l.c',
		'musl-generic-math/exp2.c',
		'musl-generic-math/exp2f.c',
		'musl-generic-math/exp2l.c',
		'musl-generic-math/exp.c',
		'musl-generic-math/expf.c',
		'musl-generic-math/expl.c',
		'musl-generic-math/expm1.c',
		'musl-generic-math/expm1f.c',
		'musl-generic-math/expm1l.c',
		'musl-generic-math/__expo2.c',
		'musl-generic-math/__expo2f.c',
		'musl-generic-math/fabs.c',
		'musl-generic-math/fabsf.c',
		'musl-generic-math/fabsl.c',
		'musl-generic-math/fdim.c',
		'musl-generic-math/fdimf.c',
		'musl-generic-math/fdiml.c',
		'musl-generic-math/finite.c',
		'musl-generic-math/finitef.c',
		'musl-generic-math/floor.c',
		'musl-generic-math/floorf.c',
		'musl-generic-math/floorl.c',
		'musl-generic-math/fma.c',
		'musl-generic-math/fmaf.c',
		'musl-generic-math/fmal.c',
		'musl-generic-math/fmax.c',
		'musl-generic-math/fmaxf.c',
		'musl-generic-math/fmaxl.c',
		'musl-generic-math/fmin.c',
		'musl-generic-math/fminf.c',
		'musl-generic-math/fminl.c',
		'musl-generic-math/fmod.c',
		'musl-generic-math/fmodf.c',
		'musl-generic-math/fmodl.c',
		'musl-generic-math/__fpclassify.c',
		'musl-generic-math/__fpclassifyf.c',
		'musl-generic-math/__fpclassifyl.c',
		'musl-generic-math/frexp.c',
		'musl-generic-math/frexpf.c',
		'musl-generic-math/frexpl.c',
		'musl-generic-math/hypot.c',
		'musl-generic-math/hypotf.c',
		'musl-generic-math/hypotl.c',
		'musl-generic-math/ilogb.c',
		'musl-generic-math/ilogbf.c',
		'musl-generic-math/ilogbl.c',
		'musl-generic-math/__invtrigl.c',
		'musl-generic-math/j0.c',
		'musl-generic-math/j0f.c',
		'musl-generic-math/j1.c',
		'musl-generic-math/j1f.c',
		'musl-generic-math/jn.c',
		'musl-generic-math/jnf.c',
		'musl-generic-math/ldexp.c',
		'musl-generic-math/ldexpf.c',
		'musl-generic-math/ldexpl.c',
		'musl-generic-math/lgamma.c',
		'musl-generic-math/lgammaf.c',
		'musl-generic-math/lgammaf_r.c',
		'musl-generic-math/lgammal.c',
		'musl-generic-math/lgamma_r.c',
		'musl-generic-math/llrint.c',
		'musl-generic-math/llrintf.c',
		'musl-generic-math/llrintl.c',
		'musl-generic-math/llround.c',
		'musl-generic-math/llroundf.c',
		'musl-generic-math/llroundl.c',
		'musl-generic-math/log10.c',
		'musl-generic-math/log10f.c',
		'musl-generic-math/log10l.c',
		'musl-generic-math/log1p.c',
		'musl-generic-math/log1pf.c',
		'musl-generic-math/log1pl.c',
		'musl-generic-math/log2.c',
		'musl-generic-math/log2f.c',
		'musl-generic-math/log2l.c',
		'musl-generic-math/logb.c',
		'musl-generic-math/logbf.c',
		'musl-generic-math/logbl.c',
		'musl-generic-math/log.c',
		'musl-generic-math/logf.c',
		'musl-generic-math/logl.c',
		'musl-generic-math/lrint.c',
		'musl-generic-math/lrintf.c',
		'musl-generic-math/lrintl.c',
		'musl-generic-math/lround.c',
		'musl-generic-math/lroundf.c',
		'musl-generic-math/lroundl.c',
		'musl-generic-math/modf.c',
		'musl-generic-math/modff.c',
		'musl-generic-math/modfl.c',
		'musl-generic-math/nan.c',
		'musl-generic-math/nanf.c',
		'musl-generic-math/nanl.c',
		'musl-generic-math/nearbyint.c',
		'musl-generic-math/nearbyintf.c',
		'musl-generic-math/nearbyintl.c',
		'musl-generic-math/nextafter.c',
		'musl-generic-math/nextafterf.c',
		'musl-generic-math/nextafterl.c',
		'musl-generic-math/nexttoward.c',
		'musl-generic-math/nexttowardf.c',
		'musl-generic-math/nexttowardl.c',
		'musl-generic-math/__polevll.c',
		'musl-generic-math/pow.c',
		'musl-generic-math/powf.c',
		'musl-generic-math/powl.c',
		'musl-generic-math/remainder.c',
		'musl-generic-math/remainderf.c',
		'musl-generic-math/remainderl.c',
		'musl-generic-math/__rem_pio2.c',
		'musl-generic-math/__rem_pio2f.c',
		'musl-generic-math/__rem_pio2_large.c',
		'musl-generic-math/__rem_pio2l.c',
		'musl-generic-math/remquo.c',
		'musl-generic-math/remquof.c',
		'musl-generic-math/remquol.c',
		'musl-generic-math/rint.c',
		'musl-generic-math/rintf.c',
		'musl-generic-math/rintl.c',
		'musl-generic-math/round.c',
		'musl-generic-math/roundf.c',
		'musl-generic-math/roundl.c',
		'musl-generic-math/scalb.c',
		'musl-generic-math/scalbf.c',
		'musl-generic-math/scalbln.c',
		'musl-generic-math/scalblnf.c',
		'musl-generic-math/scalblnl.c',
		'musl-generic-math/scalbn.c',
		'musl-generic-math/scalbnf.c',
		'musl-generic-math/scalbnl.c',
		'musl-generic-math/__signbit.c',
		'musl-generic-math/__signbitf.c',
		'musl-generic-math/__signbitl.c',
		'musl-generic-math/signgam.c',
		'musl-generic-math/significand.c',
		'musl-generic-math/significandf.c',
		'musl-generic-math/__sin.c',
		'musl-generic-math/sin.c',
		'musl-generic-math/sincos.c',
		'musl-generic-math/sincosf.c',
		'musl-generic-math/sincosl.c',
		'musl-generic-math/__sindf.c',
		'musl-generic-math/sinf.c',
		'musl-generic-math/sinh.c',
		'musl-generic-math/sinhf.c',
		'musl-generic-math/sinhl.c',
		'musl-generic-math/__sinl.c',
		'musl-generic-math/sinl.c',
		'musl-generic-math/sqrt.c',
		'musl-generic-math/sqrtf.c',
		'musl-generic-math/sqrtl.c',
		'musl-generic-math/__tan.c',
		'musl-generic-math/tan.c',
		'musl-generic-math/__tandf.c',
		'musl-generic-math/tanf.c',
		'musl-generic-math/tanh.c',
		'musl-generic-math/tanhf.c',
		'musl-generic-math/tanhl.c',
		'musl-generic-math/__tanl.c',
		'musl-generic-math/tanl.c',
		'musl-generic-math/tgamma.c',
		'musl-generic-math/tgammaf.c',
		'musl-generic-math/tgammal.c',
		'musl-generic-math/trunc.c',
		'musl-generic-math/truncf.c',
		'musl-generic-math/truncl.c',
		pic: true,
		include_directories: libc_include_dirs,
		dependencies: libc_deps,
		c_args: [compiler_c_args, '-Wno-implicit', '-Wno-parentheses', '-Wno-sign-compare', '-Wno-attributes', '-Wno-unknown-pragmas'])
endif
