From fad4050998e35d89f86e673563e3b91ac7078a16 Mon Sep 17 00:00:00 2001 From: midipix Date: Jan 02 2020 22:21:17 +0000 Subject: build system: configure, ccenv.sh: provide informative output. --- diff --git a/configure b/configure index fd82db9..607a974 100755 --- a/configure +++ b/configure @@ -46,6 +46,32 @@ warning_msg() printf '%s\n' "$@" >&2 } +output_step_prolog() +{ + mb_line_dots='..................................' + mb_line_dots="${mb_line_dots}${mb_line_dots}" + mb_step_desc="${mb_package} : ${1##*/} : ${2}() " + mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))" + printf "%s%${mb_step_dlen}.${mb_step_dlen}s " "${mb_step_desc}" "${mb_line_dots}" +} + +output_step_epilog() +{ + printf 'OK.\n' +} + +output_script_status() +{ + mb_step_name="${1##*/} : ${2}" + mb_step_desc="${mb_package} : ${mb_step_name}" + printf "%s\n" "${mb_step_desc}" +} + +output_section_break() +{ + printf '...\n' +} + verify_safe_path() { case "$mb_safe_path_name" in @@ -121,6 +147,9 @@ init_vars() . "$mb_config" fi + # step prolog + output_step_prolog ${mb_script} 'init_vars' + # project mb_nickname=$NICKNAME mb_source_dir=$SOURCE_DIR @@ -208,11 +237,16 @@ init_vars() mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE + + # step epilog + output_step_epilog } verify_build_directory() { + output_step_prolog ${mb_script} 'verify_build_directory' + if [ "$mb_project_dir" = "$mb_pwd" ]; then if [ _$mb_require_out_of_tree = _yes ]; then error_msg "$mb_package: out-of-tree builds are required." @@ -224,11 +258,15 @@ verify_build_directory() fi rm -f Makefile Makefile.host Makefile.tmp Makefile.failed + + output_step_epilog } verify_source_directory() { + output_step_prolog ${mb_script} 'verify_source_directory' + if [ -z "$mb_source_dir" ]; then if [ _$mb_require_source_dir = _yes ]; then error_msg "$mb_package: specifying an external source directory is required." @@ -237,11 +275,16 @@ verify_source_directory() exit 1 fi fi + + output_step_epilog } common_defaults() { + # step prolog + output_step_prolog ${mb_script} 'common_defaults' + # project-specific config definitions if [ _$mb_use_custom_cfgdefs = _yes ]; then cat $sfrt_cfgdefs_in > cfgdefs.mk @@ -386,11 +429,17 @@ common_defaults() # inherited cflags & ldflags mb_cflags_cmdline="$mb_cflags_cmdline $mb_cflags" mb_ldflags_cmdline="$mb_ldflags_cmdline $mb_ldflags" + + # step epilog + output_step_epilog } config_flags() { + # step prolog + output_step_prolog ${mb_script} 'config_flags' + mb_ldflags_tmp=" $mb_ldflags " mb_ldflags_libs=$(printf '%s' "$mb_ldflags_tmp" | sed 's/ -static / /g') @@ -408,11 +457,16 @@ config_flags() if [ _$mb_ldstrict = _yes ]; then mb_ldflags_strict='-Wl,--no-undefined' fi + + # step epilog + output_step_epilog } config_copy() { + output_step_prolog ${mb_script} 'config_copy' + mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \ | grep -v '^#') @@ -426,6 +480,8 @@ config_copy() $mb_project_dir/Makefile.in \ | sed -e 's/[[:blank:]]*$//g' \ > $mb_pwd/Makefile.tmp + + output_step_epilog } @@ -435,28 +491,45 @@ config_ccenv() touch ./ccenv/host.mk touch ./ccenv/native.mk + output_section_break ccenv_set_host_variables + + output_section_break ccenv_set_native_variables + output_section_break config_copy } config_custom() { if [ _$mb_use_custom_cfgdefs = _yes ]; then + output_section_break + output_script_status ${mb_script} \ + 'invoking project-specific cfgdefs.sh ==>' + eval . $mb_project_dir/project/config/cfgdefs.sh \ "$mb_custom_cfgdefs_args" + + output_section_break config_copy fi if [ _$mb_use_custom_usrdefs = _yes ]; then + output_section_break + output_script_status ${mb_scirpt} \ + 'invoking project-specific usrdefs.sh ==>' + . $mb_project_dir/project/usrdefs.sh + output_section_break fi } config_cfghost() { + output_step_prolog ${mb_script} 'config_cfghost' + if [ -z "$mb_cfghost" ]; then mb_cfghost=$mb_cchost fi @@ -467,12 +540,18 @@ config_cfghost() rm $mb_pwd/Makefile.tmp mv $mb_pwd/Makefile.host $mb_pwd/Makefile + + output_step_epilog } config_host() { - make -s host.tag && return 0 + output_step_prolog ${mb_script} 'config_host' + + make -s host.tag \ + && output_step_epilog \ + && return 0 error_msg "configure was able to generate a Makefile for the selected host," error_msg "however the host-targeting compiler was found to be missing" @@ -483,9 +562,9 @@ config_host() config_status() { - printf '\n\n' - make -j1 .display - printf '\nconfiguration completed successfully.\n\n' + output_script_status ${mb_script} \ + 'configuration completed successfully.' + printf '\n' } diff --git a/sofort/ccenv/ccenv.sh b/sofort/ccenv/ccenv.sh index f69bb9c..df353df 100644 --- a/sofort/ccenv/ccenv.sh +++ b/sofort/ccenv/ccenv.sh @@ -48,6 +48,44 @@ ccenv_comment() } +ccenv_tool_prolog() +{ + ccenv_line_dots='......................................' + ccenv_tool_desc="=== checking for ${1}" + ccenv_tool_dlen="${#ccenv_line_dots}" + + printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s" \ + "${ccenv_tool_desc} ${mb_line_dots}" +} + + +ccenv_tool_epilog() +{ + ccenv_line_dots='................................' + ccenv_tool_dlen="$((${#ccenv_line_dots} - ${#1}))" + + printf "%${ccenv_tool_dlen}.${ccenv_tool_dlen}s %s.\n" \ + "${ccenv_line_dots}" "${1}" +} + + +ccenv_attr_prolog() +{ + ccenv_line_dots='......................................' + ccenv_attr_desc="=== detect ${ccenv_cfgtype} ${1}" + ccenv_attr_dlen="${#ccenv_line_dots}" + + printf "%${ccenv_attr_dlen}.${ccenv_attr_dlen}s" \ + "${ccenv_attr_desc} ${ccenv_line_dots}" +} + + +ccenv_attr_epilog() +{ + ccenv_tool_epilog "${1}" +} + + ccenv_find_tool() { if [ -z "$ccenv_prefixes" ]; then @@ -102,6 +140,8 @@ ccenv_set_primary_tools() ccenv_peep_tools="perk mdso dlltool windmc windres" for __tool in $(printf '%s' "$ccenv_core_tools $ccenv_hack_tools $ccenv_peep_tools"); do + ccenv_tool_prolog "$__tool" + if [ -n "$mb_agnostic" ]; then ccenv_candidates=" $__tool" @@ -146,6 +186,8 @@ ccenv_set_primary_tools() ccenv_find_tool eval ccenv_$__tool="$ccenv_tool" fi + + ccenv_tool_epilog "$ccenv_tool" done # windrc @@ -155,6 +197,7 @@ ccenv_set_primary_tools() ccenv_set_tool_variants() { # as (asm) + ccenv_tool_prolog 'as (asm)' ccenv_candidates=as ccenv_find_tool @@ -165,7 +208,10 @@ ccenv_set_tool_variants() || ccenv_as_asm="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_as_asm" + # as (ll) + ccenv_tool_prolog 'as (ll)' ccenv_candidates=llvm-as ccenv_find_tool @@ -173,7 +219,10 @@ ccenv_set_tool_variants() ccenv_as_ll="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_as_ll" + # as (mc) + ccenv_tool_prolog 'as (mc)' ccenv_candidates=llvm-mc ccenv_find_tool @@ -181,7 +230,10 @@ ccenv_set_tool_variants() ccenv_as_mc="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_as_mc" + # ld (bfd) + ccenv_tool_prolog 'ld (bfd)' ccenv_candidates=ld.bfd ccenv_find_tool @@ -189,7 +241,10 @@ ccenv_set_tool_variants() ccenv_ld_bfd="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_ld_bfd" + # ld (gold) + ccenv_tool_prolog 'ld (gold)' ccenv_candidates=ld.gold ccenv_find_tool @@ -197,7 +252,10 @@ ccenv_set_tool_variants() ccenv_ld_gold="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_ld_gold" + # ld (lld) + ccenv_tool_prolog 'ld (lld)' ccenv_candidates=lld ccenv_find_tool @@ -205,7 +263,10 @@ ccenv_set_tool_variants() ccenv_ld_lld="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_ld_lld" + # objdump (bfd) + ccenv_tool_prolog 'objdump (bfd)' ccenv_candidates=objdump ccenv_find_tool @@ -213,7 +274,10 @@ ccenv_set_tool_variants() ccenv_objdump_bfd="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_objdump_bfd" + # objdump (llvm) + ccenv_tool_prolog 'objdump (llvm)' ccenv_candidates=llvm-objdump ccenv_find_tool @@ -221,7 +285,10 @@ ccenv_set_tool_variants() ccenv_objdump_llvm="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_objdump_llvm" + # readelf (bfd) + ccenv_tool_prolog 'readelf (bfd)' ccenv_candidates=readelf ccenv_find_tool @@ -229,7 +296,10 @@ ccenv_set_tool_variants() ccenv_readelf_bfd="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_readelf_bfd" + # readelf (llvm) + ccenv_tool_prolog 'readelf (llvm)' ccenv_candidates=llvm-readelf ccenv_find_tool @@ -237,6 +307,8 @@ ccenv_set_tool_variants() ccenv_readelf_llvm="$ccenv_tool" fi + ccenv_tool_epilog "$ccenv_readelf_llvm" + # as if [ -n "$ccenv_cc" ]; then ccenv_as='$('"$ccenv_makevar_prefix"'CC) -c -x assembler' @@ -289,6 +361,8 @@ ccenv_set_c_compiler_candidates() ccenv_set_cc() { + ccenv_tool_prolog 'C compiler' + if [ -z "$ccenv_cc" ]; then ccenv_set_c_compiler_candidates ccenv_find_tool -dumpmachine @@ -304,6 +378,7 @@ ccenv_set_cc() if [ "$ccenv_cfgtype" = 'native' ]; then ccenv_host=$($ccenv_cc $(printf '%s' "$ccenv_cflags") -dumpmachine 2>/dev/null) ccenv_cchost=$ccenv_host + ccenv_tool_epilog "$ccenv_cc" return 0 fi @@ -365,10 +440,14 @@ ccenv_set_cc() return 2 fi + + ccenv_tool_epilog "$ccenv_cc" } ccenv_set_cpp() { + ccenv_tool_prolog 'C pre-processor' + case "$ccenv_cc_cmd" in cc | c99 | c11 | gcc) ccenv_cpp_prefix= @@ -400,6 +479,7 @@ ccenv_set_cpp() * ) ccenv_cpp="$ccenv_cc -E" + ccenv_tool_epilog "$ccenv_cpp" return 0 esac @@ -412,10 +492,14 @@ ccenv_set_cpp() else ccenv_cpp="$ccenv_tool" fi + + ccenv_tool_epilog "$ccenv_cpp" } ccenv_set_cxx() { + ccenv_tool_prolog 'C++ compiler' + case "$ccenv_cc_cmd" in cc | c99 | c11 ) ccenv_cxx_prefix= @@ -443,6 +527,7 @@ ccenv_set_cxx() * ) ccenv_cxx="$ccenv_cc -xc++" + ccenv_tool_epilog "$ccenv_cxx" return 0 esac @@ -455,15 +540,21 @@ ccenv_set_cxx() else ccenv_cxx="$ccenv_tool" fi + + ccenv_tool_epilog "$ccenv_cxx" } ccenv_set_cc_host() { + ccenv_attr_prolog 'name' ccenv_cc_host="$ccenv_cchost" + ccenv_attr_epilog "$ccenv_cc_host" } ccenv_set_cc_bits() { + ccenv_attr_prolog 'bits' + ccenv_internal_size= ccenv_internal_type='void *' ccenv_internal_test='char x[(sizeof(%s) == %s/8) ? 1 : -1];' @@ -483,10 +574,14 @@ ccenv_set_cc_bits() done ccenv_cc_bits=$ccenv_internal_size + + ccenv_attr_epilog "$ccenv_cc_bits" } ccenv_set_cc_underscore() { + ccenv_attr_prolog 'prepended underscores' + ccenv_fn_name='ZmYaXyWbVe_UuTnSdReQrPsOcNoNrLe' ccenv_fn_code='int %s(void){return 0;}' @@ -495,8 +590,11 @@ ccenv_set_cc_underscore() | grep "^_$ccenv_fn_name:" \ > /dev/null; then ccenv_cc_underscore='_' + ccenv_attr_epilog 'yes' fi + ccenv_attr_epilog 'no' + return 0 } @@ -540,6 +638,11 @@ ccenv_create_freestanding_executable() return 0 } +ccenv_set_cc_binfmt_error() +{ + ccenv_attr_epilog '(unable to create executable)' +} + ccenv_set_cc_binfmt() { ccenv_use_perk= @@ -549,8 +652,11 @@ ccenv_set_cc_binfmt() ccenv_use_bfd_objdump= ccenv_use_llvm_objdump= + ccenv_attr_prolog 'binary format' + ccenv_create_framework_executable \ || ccenv_create_freestanding_executable \ + || ccenv_set_cc_binfmt_error \ || return 0 # PE / perk @@ -674,6 +780,8 @@ ccenv_set_cc_binfmt() ccenv_use_bfd_objdump=yes fi fi + + ccenv_attr_epilog "$ccenv_cc_binfmt" } ccenv_set_os_pe() @@ -738,6 +846,8 @@ ccenv_set_os_macho() ccenv_set_os() { + ccenv_attr_prolog 'os name' + case "$ccenv_cc_binfmt" in PE ) ccenv_set_os_pe ;; @@ -746,6 +856,7 @@ ccenv_set_os() esac if [ -n "$ccenv_os" ]; then + ccenv_attr_epilog "$ccenv_os" return 0 fi @@ -769,6 +880,8 @@ ccenv_set_os() if [ -z "$ccenv_os" ]; then ccenv_os='anyos' fi + + ccenv_attr_epilog "$ccenv_os" } ccenv_set_os_flags() @@ -801,6 +914,8 @@ ccenv_set_os_semantics() { # binary_format - core_api - ex_api - dependency_resolution + ccenv_attr_prolog 'os semantics' + case "$ccenv_os" in linux ) ccenv_os_semantics='elf-posix-linux-ldso' @@ -826,6 +941,7 @@ ccenv_set_os_semantics() esac if [ -n "$ccenv_os_semantics" ]; then + ccenv_attr_epilog "$ccenv_os_semantics" return 0 fi @@ -838,10 +954,14 @@ ccenv_set_os_semantics() else ccenv_os_semantics='unknown-posix-anyos-unknown' fi + + ccenv_attr_epilog "$ccenv_os_semantics" } ccenv_set_os_dso_exrules() { + ccenv_attr_prolog 'os dso exrules' + case "$ccenv_os" in midipix ) ccenv_os_dso_exrules='pe-mdso' @@ -853,12 +973,16 @@ ccenv_set_os_dso_exrules() ccenv_os_dso_exrules='default' fi esac + + ccenv_attr_epilog "$ccenv_os_dso_exrules" } ccenv_set_os_dso_linkage() { # todo: PIC, PIE, and friends + ccenv_attr_prolog 'os linkage' ccenv_os_dso_linkage='default' + ccenv_attr_epilog "$ccenv_os_dso_linkage" } ccenv_set_os_dso_patterns_darwin() @@ -1112,8 +1236,8 @@ ccenv_set_characteristics() { ccenv_set_cc_host ccenv_set_cc_bits - ccenv_set_cc_underscore ccenv_set_cc_binfmt + ccenv_set_cc_underscore } ccenv_set_toolchain_variables() @@ -1140,12 +1264,18 @@ ccenv_set_toolchain_variables() ccenv_set_host_variables() { + output_script_status ${mb_script} \ + 'detect and query host toolchain ==>' + ccenv_set_toolchain_variables 'host' ccenv_dso_verify } ccenv_set_native_variables() { + output_script_status ${mb_script} \ + 'detect and query native toolchain ==>' + if [ _$mb_ccenv_skip_native != _yes ]; then ccenv_set_toolchain_variables 'native' fi