dnl kcore/def.h.m → <k/def.h>
dnl ~ lexi hale <lexi@hale.su>
dnl this file gathers information on the environment it's
dnl being compiled in, setting macros that other headers
dnl need. it will be emitted as <k/def.h>.
dnl vim: ft=c
#ifndef KIdef
#define KIdef
define(`def',`#define $1 $2')

ifdef(`atom_target_bits',`
	define(`target',`atom_target_arch.atom_target_os.atom_target_bits')
	def(KVbits,atom_target_bits)',`
	define(`target',atom_target_arch.atom_target_os)')

def(KVtarget,target)
def(KVos,atom_target_os)
def(KVarch,atom_target_arch)

ifelse(target_unix,`yes',
		`def(`KFenv_unix',)
		def(`KFenv_posix',)',`
		ifelse(target_posix,`yes',
			`def(KFenv_posix)')')

#define Kpragma(p) _Pragma(#p)
#if defined(__GNUC__) || defined(__clang__)
#   define Kerror(msg) Kpragma(GCC error #msg) 
#else
#   define Kerror(msg) Kpragma(message #msg)
#endif
#define Knoimpl(fn) Kerror(no implementation of fn for platform [target])

#endif
