Blame musl.lzy

860627
# lazy mark: project recipe
860627
lz_project_rules()
860627
{
860627
	lz_rules="all install install_no_complex \
860627
		libc libc_shared libc_static \
860627
		libc_no_complex libc_shared_no_complex libc_static_no_complex"
860627
}
860627
860627
860627
lz_project_definitions()
860627
{
860627
	lz_cflags_common="-std=c99 -pipe -ffreestanding -nostdinc -D_XOPEN_SOURCE=700 -fomit-frame-pointer"
860627
860627
	lz_cflags_include_common="-I$lz_project_dir/src/internal \
860627
				-I$lz_project_dir/arch/$lz_arch \
860627
				-I$lz_project_dir/include \
860627
				-I$lz_build_dir/arch/$lz_arch \
860627
				-I$lz_build_dir/include"
860627
860627
	musl_empty_lib_names="m rt pthread crypt util xnet resolv dl"
860627
	musl_cflags_crt="-fPIC"
5085e9
	musl_cflags_shared="-fPIC"
860627
860627
	if [ "$lz_pecoff_winnt"x = yesx ]; then
e43f5a
		pe_excluded_symbols="_dlstart"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__syscall_vtbl"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__ldso_vtbl"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__psx_vtbl"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__teb_sys_idx"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__teb_libc_idx"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__vm_lock_impl"
860627
		pe_excluded_symbols="$pe_excluded_symbols,__vm_unlock_impl"
860627
e43f5a
		musl_libc_so_ldflags="-shared -e _dlstart \
682299
					-Bsymbolic-functions \
860627
					--subsystem windows \
860627
					--output-def $lz_build_dir/lib/libc.so.def \
860627
					--out-implib $lz_build_dir/lib/libc.lib.a \
860627
					--exclude-symbols=$pe_excluded_symbols"
860627
	else
7d14e0
		musl_libc_so_ldflags="-shared -e _dlstart -Bsymbolic-functions"
5085e9
		musl_cflags_shared="$musl_cflags_shared -DSHARED"
860627
	fi
860627
860627
	musl_libc_src_dirs="src arch/$lz_arch/src arch/$lz_arch/weak"
860627
	musl_libc_mem_files="src/string/memcpy.c src/string/memmove.c src/string/memcmp.c src/string/memset.c"
860627
860627
860627
	lz_flag_tests_begin
860627
860627
	for musl_test_flag in "-frounding-math" "-fexcess-precision=standard"; do
860627
		lz_compiler_supports_flag $lz_c_compiler "$musl_test_flag" \
860627
			&& lz_cflags_common="$lz_cflags_common $musl_test_flag"
860627
	done
860627
860627
	for musl_test_flag in "-fno-tree-loop-distribute-patterns"; do
860627
		lz_compiler_supports_flag $lz_c_compiler "$musl_test_flag" \
860627
			&& musl_cflags_memops="$musl_cflags_memops $musl_test_flag"
860627
	done
860627
860627
	for musl_test_flag in "--hash-style=both"; do
860627
		lz_linker_supports_flag $lz_c_compiler $lz_ld "$musl_test_flag" \
860627
			&& musl_libc_so_ldflags="$musl_libc_so_ldflags $musl_test_flag"
860627
	done
860627
860627
	lz_flag_tests_end
860627
860627
860627
	if [ "$lz_debug"x = yesx ]; then
860627
		lz_cflags_debug="$lz_toolchain_cflags_debug"
860627
	else
860627
		lz_cflags_common="$lz_cflags_common -Os"
860627
	fi
860627
860627
	# names of binary files and/or utilities
860627
	musl_libc_a_name="$lz_build_dir/lib/libc$lz_stlib_ext"
860627
	musl_libc_so_name="$lz_build_dir/lib/libc$lz_dylib_ext"
860627
860627
	# temporary files to store meta information
860627
	musl_libc_so_obj_list=libc.so.objs
860627
	musl_libc_so_src_list=libc.so.src.lst
860627
860627
	musl_libc_a_obj_list=libc.a.objs
860627
	musl_libc_a_src_list=libc.a.src.lst
860627
860627
	musl_crt_obj_list=crt.objs
860627
	musl_crt_src_list=crt.src.lst
860627
860627
	musl_install_sh=$lz_project_dir/tools/install.sh
860627
	musl_ldso="$lz_syslibdir/ld-musl-$lz_arch$lz_subarch.so.1"
860627
}
860627
860627
860627
musl_headers()
860627
{
860627
	if [ -f $lz_build_dir/headers.tag ]; then
860627
		lz_ok && return
860627
	fi
860627
860627
	mkdir -p $lz_build_dir/include
Shiz 4bebc3
	cp -R $lz_project_dir/arch/$lz_arch/bits $lz_build_dir/include
860627
860627
	touch $lz_build_dir/headers.tag
860627
}
860627
860627
860627
musl_alltypes()
860627
{
860627
	if [ -f $lz_build_dir/alltypes.tag ]; then
860627
		lz_ok && return
860627
	fi
860627
860627
	sed -f $lz_project_dir/tools/mkalltypes.sed \
860627
		$lz_build_dir/include/bits/alltypes.h.in \
860627
		$lz_project_dir/include/alltypes.h.in > \
860627
			$lz_build_dir/include/bits/alltypes.h
860627
860627
	touch $lz_build_dir/alltypes.tag
860627
}
860627
860627
860627
musl_version()
860627
{
860627
	if [ -f $lz_build_dir/version.tag ]; then
860627
		lz_ok && return
860627
	fi
860627
860627
	lz_pushd $lz_project_dir
860627
	lzp_version=`sh tools/version.sh`
860627
	lz_popd
860627
860627
	printf '#define VERSION "%s"\n' $lzp_version \
860627
		> $lz_build_dir/include/version.h
860627
860627
	touch $lz_build_dir/version.tag
860627
}
860627
860627
860627
musl_empty_libs()
860627
{
860627
	if [ -f $lz_build_dir/empty_libs.tag ]; then
860627
		lz_ok && return
860627
	fi
860627
860627
	for lzp_lib_name in $musl_empty_lib_names; do
860627
		lzp_lib_file_name=$lz_build_dir/lib/lib$lzp_lib_name.a
860627
		rm -f $lzp_lib_file_name
860627
		$lz_ar rc $lzp_lib_file_name
860627
	done
860627
860627
	touch $lz_build_dir/empty_libs.tag
860627
}
860627
860627
musl_crt()
860627
{
860627
	musl_headers
860627
	musl_alltypes
860627
860627
	lz_cflags_extra="$musl_cflags_crt"
860627
	lz_src_dirs="crt"
860627
860627
        lz_compile "$musl_crt_obj_list" "$musl_crt_src_list" "$lz_stobj_ext"
860627
}
860627
860627
860627
musl_libc_common()
860627
{
860627
	musl_headers
860627
	musl_alltypes
860627
	musl_version
860627
}
860627
860627
860627
musl_libc_shared()
860627
{
860627
        musl_libc_common
860627
	musl_crt
860627
860627
	# memory functions
682299
	lz_cflags_extra="$musl_cflags_shared $musl_cflags_no_complex"
860627
	lz_cflags_special="$musl_cflags_memops"
860627
	lz_src_files="$musl_libc_mem_files"
860627
	lz_src_dirs=$lz_ignore_src_dirs
860627
860627
        lz_compile "$musl_libc_so_obj_list" "$musl_libc_so_src_list" "$lz_dyobj_ext"
860627
860627
	lz_src_files=
860627
	lz_cflags_special=
860627
860627
	# regular source files
860627
	lz_cumulative_obj_list=yes
860627
	lz_src_dirs=$musl_libc_src_dirs
860627
	lz_exclude_src_files="$musl_libc_mem_files"
860627
	lz_compiler_rt_libs="$lz_compiler_rt_libs $lz_link_libgcc"
860627
860627
	if [ "$lz_pecoff_winnt"x = yesx ]; then
860627
		musl_crti_objs="musl_crti_objs.lst"
860627
		musl_crtn_objs="musl_crtn_objs.lst"
860627
		echo 'crt/crti.o' > $musl_crti_objs
860627
		echo 'crt/crtn.o' > $musl_crtn_objs
860627
	else
860627
		musl_crti_objs=
860627
		musl_crtn_objs=
860627
	fi
860627
860627
	rm -f "$musl_libc_so_name"
860627
860627
        lz_compile "$musl_libc_so_obj_list" "$musl_libc_so_src_list" "$lz_dyobj_ext"
860627
        lz_link    "$musl_crti_objs $musl_libc_so_obj_list $musl_crtn_objs" \
860627
			"$musl_libc_so_src_list" \
860627
			"$musl_libc_so_name" \
860627
			"$musl_libc_so_ldflags" \
860627
			"$lz_compiler_rt_libs"   \
860627
			"$lz_arch_dynamic_syscall_libs"
860627
}
860627
860627
860627
musl_libc_static()
860627
{
860627
        musl_libc_common
860627
860627
	# memory functions
860627
	lz_cflags_special="$musl_cflags_memops"
860627
	lz_src_files="$musl_libc_mem_files"
860627
	lz_src_dirs=$lz_ignore_src_dirs
860627
860627
        lz_compile "$musl_libc_a_obj_list" "$musl_libc_a_src_list" "$lz_stobj_ext"
860627
	lz_src_files=
860627
	lz_cflags_special=
860627
860627
	# regular source files
860627
	lz_cumulative_obj_list=yes
860627
	lz_src_dirs=$musl_libc_src_dirs
860627
	lz_exclude_src_files="$musl_libc_mem_files"
860627
860627
	rm -f "$musl_libc_a_name"
860627
860627
        lz_compile "$musl_libc_a_obj_list" "$musl_libc_a_src_list" "$lz_stobj_ext"
860627
        lz_archive "$musl_libc_a_obj_list" "$musl_libc_a_src_list" "$musl_libc_a_name"
860627
860627
	if [ "$lz_pecoff_winnt"x = yesx ]; then
860627
		if [ "$lz_arch_dynamic_syscall_libs"x != x ]; then
860627
			$lz_ar rc "$musl_libc_a_name" "$lz_arch_static_syscall_libs"
860627
		fi
860627
	fi
860627
}
860627
860627
860627
musl_libc_shared_no_complex()
860627
{
860627
	lz_link_libgcc=
860627
	lz_exclude_src_dirs="src/complex"
682299
	musl_cflags_no_complex="-DLIBC_NO_COMPLEX"
860627
	musl_libc_shared
860627
}
860627
860627
860627
musl_libc_static_no_complex()
860627
{
860627
	lz_exclude_src_dirs="src/complex"
860627
	musl_libc_static
860627
}
860627
860627
860627
musl_libc()
860627
{
860627
	lz_link_libgcc="--as-needed `$lz_c_compiler -print-file-name=libgcc.a`"
860627
	lz_step musl_crt
860627
	lz_step musl_libc_shared
860627
	lz_step musl_libc_static
860627
	lz_step musl_empty_libs
860627
}
860627
860627
860627
musl_libc_no_complex()
860627
{
860627
	lz_step musl_crt
860627
	lz_step musl_libc_shared_no_complex
860627
	lz_step musl_libc_static_no_complex
860627
	lz_step musl_empty_libs
860627
}
860627
860627
860627
musl_all()
860627
{
860627
	lz_step musl_libc
860627
}
860627
860627
860627
musl_install_crt()
860627
{
860627
	lz_pushd $lz_build_dir/crt
860627
860627
	musl_crt_files=`cat $lz_build_dir/crt.objs`
860627
860627
	for lzp_crt_file in $musl_crt_files; do
860627
		lzp_crt_obj_file=`basename $lzp_crt_file`
ee93f3
		$musl_install_sh -D -m 644 $lzp_crt_obj_file $lz_libdir/$lzp_crt_obj_file
860627
	done
860627
860627
	lz_popd
860627
}
860627
860627
860627
musl_install_libs()
860627
{
860627
	lz_pushd $lz_build_dir/lib
860627
860627
	for lzp_lib_file in "c" $musl_empty_lib_names; do
860627
		$musl_install_sh -D -m 644 lib$lzp_lib_file$lz_stlib_ext $lz_libdir/lib$lzp_lib_file$lz_stlib_ext
860627
	done
860627
860627
	$musl_install_sh -D -m 755 libc$lz_dylib_ext $lz_libdir/libc$lz_dylib_ext
860627
860627
	if [ "$lz_pecoff_winnt"x = yesx ]; then
860627
		# also install the import library
860627
		$musl_install_sh -D -m 644 libc$lz_implib_ext  $lz_libdir/libc$lz_implib_ext
860627
	fi
860627
860627
	lz_popd
860627
}
860627
860627
860627
musl_install_ldso()
860627
{
860627
	$musl_install_sh -D -l $lz_libdir/libc$lz_dylib_ext $musl_ldso
860627
}
860627
860627
860627
musl_install_headers()
860627
{
860627
	lz_pushd $lz_project_dir/include
860627
860627
	musl_include_files=`find . -type f`
860627
860627
	for lzp_include_file in $musl_include_files; do
860627
		$musl_install_sh -D -m 644 $lzp_include_file $lz_includedir/$lzp_include_file
860627
	done
860627
860627
	lz_popd
860627
}
860627
860627
860627
musl_install_arch_headers()
860627
{
860627
	lz_pushd $lz_build_dir/include
860627
860627
	musl_include_files=`find ./bits -type f ! -name *.h.in`
860627
860627
	for lzp_include_file in $musl_include_files; do
860627
		$musl_install_sh -D -m 644 $lzp_include_file $lz_includedir/$lzp_include_file
860627
	done
860627
860627
	lz_popd
860627
}
860627
860627
860627
musl_install_specs()
860627
{
860627
	sh $lz_project_dir/tools/musl-gcc.specs.sh \
860627
			$(readlink -f "$lz_includedir") \
860627
			$(readlink -f "$lz_libdir") \
860627
			$(readlink -f "$musl_ldso") \
860627
		> $lz_libdir/musl-gcc.specs
860627
}
860627
860627
860627
musl_install_common()
860627
{
860627
	lz_step musl_install_crt
860627
	lz_step musl_install_libs
860627
	lz_step musl_install_ldso
860627
	lz_step musl_install_headers
860627
	lz_step musl_install_arch_headers
860627
	lz_step musl_install_specs
860627
}
860627
860627
860627
musl_install()
860627
{
860627
	lz_step musl_all
860627
	lz_step musl_install_common
860627
}
860627
860627
860627
musl_install_no_complex()
860627
{
860627
	lz_step musl_libc_no_complex
860627
	lz_step musl_install_common
860627
}
860627