libk  cc-invoke.m4 at tip

File global/cc-invoke.m4 from the latest check-in


_libk_shebang_
define(quot,"'"'$1'"'")dnl
# generated from /global/cc-invoke.m4 by install.sh

if test "$(echo -n)" = "-n"; then
	say() { echo $@' \c'; }
else
	say() { echo -n $@' '; }
fi

libk_libs() {
	if test "$static" != 1; then
		say quot(_libk_libdir_/kboot.o) quot(-L`'_libk_libdir_) -lk
	else
		say quot(_libk_libdir_/libk.a)
	fi
}

libk_cflags() {
	say quot(-I`'_libk_incdir_)
}

libk_static() {
	say _libk_libdir_/libk.a
}

libk_gcc() {
	say -ffreestanding -nostdlib 
}

libk_clang() {
	say -ffreestanding -nostdlibinc
}

usage() {
	echo "usage: $0 [flags]"
	echo "    $0 prints compiler flags necessary to compile libk programs."
	echo "    in general, you will need three kinds of flag sets:"
	echo "        linkage flags tell the compiler where to find libk binary libraries"
	echo "        for the final linking stage."
	echo "            --libs -l  : emit linkage flags"
	echo "            --static -s: modify emitted flags for static linking"
	echo "        compilation flags tell the compiler where to find headers."
	echo "            --cflags -c: emit compilation flags"
	echo "        compatibility flags set various compiler-specific options needed to"
	echo "        compile programs without the traditional C standard library."
	echo "            --gcc -g  : emit gcc-style compat flags"
	echo "            --clang -C: emit clang-style compat flags"
	echo "    $0 handles quoting automatically."
	exit 64
}

for a in $@; do
	case $a in
		*help|-h) usage ;;
		*newlines|-n)
			say() {
				for l in $@; do
					echo $l
				done
			};;
		*libs|-l)   fns="$fns libk_libs"   ;;
		*cflags|-c) fns="$fns libk_cflags" ;;
		*gcc|-g)    fns="$fns libk_gcc" ;;
		*clang|-C)  fns="$fns libk_clang" ;;
		*static|-s) static=1 ;;
	esac
done

for f in $fns; do
	$f
done