summaryrefslogtreecommitdiffhomepage
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure368
1 files changed, 327 insertions, 41 deletions
diff --git a/configure b/configure
index 62c2b11..839d8b3 100755
--- a/configure
+++ b/configure
@@ -33,7 +33,12 @@ usage()
" ___________________________________________" \
"__________________________________"
- cat "$mb_project_dir"/project/config/cfgdefs.usage
+ if [ -f "$mb_project_dir"/project/config/cfgdefs.usage ]; then
+ cat "$mb_project_dir"/project/config/cfgdefs.usage
+ else
+ printf '%s\n\n' \
+ "[ info: this project does not provide a project-specific cfgdefs.usage file. ]"
+ fi
fi
exit 0
@@ -53,10 +58,10 @@ output_step_prolog()
{
mb_line_dots='.................................'
mb_line_dots="${mb_line_dots}.${mb_line_dots}"
- mb_step_desc="${mb_package} : ${1##*/} : ${2}() "
+ mb_step_desc="${mb_package} : ${1##*/} : ${2} "
mb_step_dlen="$((${#mb_line_dots} - ${#mb_step_desc}))"
- printf "configure step: ${2}()\n" >&3
+ printf "configure step: ${2}\n" >&3
printf "%s%${mb_step_dlen}.${mb_step_dlen}s " "${mb_step_desc}" "${mb_line_dots}"
}
@@ -100,12 +105,6 @@ init_log()
printf "This is config.log, generated by sofort's configure script.\n\n" >&3
printf '$ %s' "$mb_script" >&3
-
- for arg in $mb_args; do
- printf ' %s' "$arg" >&3
- done
-
- printf '\n\n' >&3
}
init_vars()
@@ -135,6 +134,7 @@ init_vars()
sfrt_core_dir=$sfrt_impl_dir/core
sfrt_config_vars=$sfrt_config_dir/config.vars
sfrt_flag_vars=$sfrt_config_dir/flag.vars
+ sfrt_opt_vars=$sfrt_config_dir/opt.vars
sfrt_cfgdefs_in=$sfrt_config_dir/cfgdefs.in
mb_make_vars=$(< "$sfrt_config_vars" \
@@ -156,6 +156,9 @@ init_vars()
eval "$mb_expr"
done
+ # cfgtest
+ . $mb_project_dir/sofort/cfgtest/cfgtest.sh
+
# ccenv
. $mb_project_dir/sofort/ccenv/ccenv.sh
@@ -169,9 +172,57 @@ init_vars()
# config.project
if [ -z "$mb_config" ]; then
- . $mb_project_dir/config.project
- else
- . "$mb_config"
+ mb_config="$mb_project_dir/config.project"
+ fi
+
+ . "$mb_config"
+
+ # config.project make preferences
+ if [ -z "${MAKE}" ]; then
+ MAKE="$mb_make"
+ fi
+
+ if [ -z "${MAKEMODE}" ]; then
+ MAKEMODE="$mb_makemode"
+ fi
+
+
+ if [ -z "$mb_makefile" ]; then
+ mb_makefile='Makefile'
+ fi
+
+ # pkgconf (host)
+ if [ -z "${PKGCONF}" ]; then
+ PKGCONF="$mb_pkgconf"
+ fi
+
+ if [ -z "${PKGCONF}" ]; then
+ PKGCONF="${PKGCONFIG}"
+ fi
+
+ # pkgconf (native)
+ if [ -z "${NATIVE_PKGCONF}" ]; then
+ NATIVE_PKGCONF="$mb_native_pkgconf"
+ fi
+
+ if [ -z "${NATIVE_PKGCONF}" ]; then
+ NATIVE_PKGCONF="${NATIVE_PKGCONFIG}"
+ fi
+
+ # project-specific initialization
+ if [ _$mb_use_custom_cfginit = _yes ]; then
+ . "$mb_project_dir/project/config/cfginit.sh"
+ fi
+
+ # package
+ if [ -z "$mb_package" ]; then
+ error_msg "$mb_script: incomplete information in $mb_config."
+ error_msg "$mb_script: \$mb_package not set."
+ exit 1
+ fi
+
+ if [ -z "${NICKNAME}" ]; then
+ NICKNAME="$mb_nickname"
fi
# srcinfo
@@ -179,6 +230,11 @@ init_vars()
mb_source_dir_set=yes
fi
+ # cchost
+ if [ -n "$CCHOST" ]; then
+ mb_cchost_set=yes
+ fi
+
# step prolog
output_step_prolog ${mb_script} 'init_vars'
@@ -211,6 +267,9 @@ init_vars()
mb_pdfdir=$PDFDIR
mb_psdir=$PSDIR
+ # make
+ mb_make=$MAKE
+ mb_makemode=$MAKEMODE
# build
mb_build=$BUILD
@@ -221,7 +280,10 @@ init_vars()
mb_toolchain=$TOOLCHAIN
mb_sysroot=$SYSROOT
mb_cross_compile=$CROSS_COMPILE
- mb_shell=$SHELL
+ mb_shell=$CONFIG_SHELL
+
+ # pkgconf
+ mb_pkgconf=$PKGCONF
# switches
mb_cflags=$CFLAGS
@@ -267,6 +329,8 @@ init_vars()
mb_native_cflags=$NATIVE_CFLAGS
mb_native_ldflags=$NATIVE_LDFLAGS
+ mb_native_pkgconf=$NATIVE_PKGCONF
+
mb_native_pe_subsystem=$NATIVE_PE_SUBSYSTEM
mb_native_pe_image_base=$NATIVE_PE_IMAGE_BASE
@@ -289,7 +353,14 @@ verify_build_directory()
fi
fi
- rm -f Makefile Makefile.host Makefile.tmp Makefile.failed
+ if [ -f "$mb_pwd/Makefile.common" ]; then
+ error_msg
+ error_msg "$mb_package: the file-name Makefile.common is reserved for bootstrapping projects."
+ error_msg "$mb_package: please remove or rename the file manually and then re-run configure."
+ exit 1
+ fi
+
+ rm -f Makefile Makefile.host Makefile.tmp Makefile.failed $mb_makefile
output_step_epilog
}
@@ -526,7 +597,7 @@ common_defaults()
[ -n "$mb_oldincludedir" ] || mb_oldincludedir=$mb_prefix/include
[ -n "$mb_datarootdir" ] || mb_datarootdir=$mb_prefix/share
[ -n "$mb_mandir" ] || mb_mandir=$mb_datarootdir/man
- [ -n "$mb_docdir" ] || mb_docdir=$mb_datarootdir/doc
+ [ -n "$mb_docdir" ] || mb_docdir=$mb_datarootdir/doc/'$(PACKAGE)'
[ -n "$mb_libexecdir" ] || mb_libexecdir=$mb_exec_prefix/libexec
[ -n "$mb_sysconfdir" ] || mb_sysconfdir=$mb_exec_prefix/etc
@@ -585,21 +656,39 @@ common_defaults()
# sysroot
if [ -n "$mb_sysroot" ]; then
if [ -z "$mb_cflags_sysroot" ]; then
- mb_cflags_sysroot="--sysroot=$mb_sysroot"
+ mb_cflags_sysroot='$(_CFLAGS_SYSROOT)'
fi
if [ -z "$mb_ldflags_sysroot" ]; then
- mb_ldflags_sysroot="--sysroot=$mb_sysroot"
+ mb_ldflags_sysroot='$(_LDFLAGS_SYSROOT)'
fi
fi
# debug
if [ _$mb_debug = _yes ]; then
if [ -z "$mb_cflags_debug" ]; then
- mb_cflags_debug='-g3 -O0'
+ mb_cflags_debug='$(_CFLAGS_g3) $(_CFLAGS_O0)'
fi
fi
+ # make
+ if [ -z "$mb_make" ]; then
+ mb_make='make'
+ fi
+
+ if [ -z "$mb_makemode" ]; then
+ mb_makemode='posix'
+
+ printf '%s\n%s\n%s\n\n%s\n\n' \
+ 'ifeq (a,b)' \
+ 'VAR = val' \
+ 'endif' \
+ 'all:' \
+ | ${mb_make} -s -f - 2>/dev/null \
+ && mb_makemode='modern'
+
+ fi
+
# shell
if [ -z "$mb_shell" ]; then
mb_shell='/bin/sh'
@@ -629,12 +718,12 @@ config_flags()
# ccstrict
if [ _$mb_ccstrict = _yes ]; then
- mb_cflags_strict='-Wall -Werror -Wextra -Wundef'
+ mb_cflags_strict='$(_CFLAGS_Wall) $(_CFLAGS_Werror) $(_CFLAGS_Wextra) $(_CFLAGS_Wundef) $(_CFLAGS_Wpedantic)'
fi
# ldstrict
if [ _$mb_ldstrict = _yes ]; then
- mb_ldflags_strict='-Wl,--no-undefined'
+ mb_ldflags_strict='$(_CFLAGS_Wl___no_undefined)'
fi
# step epilog
@@ -642,23 +731,76 @@ config_flags()
}
+config_opts()
+{
+ if [ "$mb_avoid_version" = 'yes' ]; then
+ mb_version_opt='none'
+ else
+ mb_version_opt='used'
+ fi
+
+ if [ "$mb_custom_install_headers" = 'yes' ]; then
+ mb_install_headers_opt='custom'
+ else
+ mb_install_headers_opt='default'
+ fi
+
+ if [ "$mb_disable_static" = 'yes' ]; then
+ mb_static_library_opt='disabled'
+ else
+ mb_static_library_opt='enabled'
+ fi
+
+ if [ "$mb_disable_shared" = 'yes' ]; then
+ mb_shared_library_opt='disabled'
+ else
+ mb_shared_library_opt='enabled'
+ fi
+
+ if [ "$mb_disable_frontend" = 'yes' ]; then
+ mb_app_frontend_opt='disabled'
+ else
+ mb_app_frontend_opt='enabled'
+ fi
+
+ if [ "$mb_all_static" = 'yes' ]; then
+ mb_app_linking_opt='all_static'
+
+ elif [ "$mb_all_shared" = 'yes' ]; then
+ mb_app_linking_opt='all_shared'
+
+ else
+ mb_app_linking_opt='default'
+ fi
+}
+
config_copy()
{
output_step_prolog ${mb_script} 'config_copy'
- mb_vars=$(cut -d'=' -f1 $sfrt_config_vars \
- | grep -v '^#')
+ mb_var_defs=
+ mb_sed_substs=
+ mb_template="${1:-$mb_project_dir/Makefile.in}"
+
+ mb_vars=$(cut -d'=' -f1 "$sfrt_config_vars" "$sfrt_opt_vars" \
+ | grep -v '^#');
+
+ for __var in $(printf '%s' "$mb_vars"); do
+ mb_sed_subst=$(printf '%s %s%s%s' \
+ '-e' "'s^@$__var@" \
+ "^___${__var}___" \
+ "^g'")
- mb_sed_substs=" \
- $(for __var in $(printf '%s' "$mb_vars"); do \
- printf '%s"$%s"%s' "-e 's^@$__var@^'" \
- "mb_$__var" "'^g' "; \
- done)"
+ mb_sed_substs="$mb_sed_substs $mb_sed_subst"
- eval sed $mb_sed_substs \
- $mb_project_dir/Makefile.in \
- | sed -e 's/[[:blank:]]*$//g' \
- > $mb_pwd/Makefile.tmp
+ mb_var_def=$(printf '%s%s="${%s}"' "-D" "___${__var}___" "mb_${__var}")
+ eval mb_var_defs='"$mb_var_defs "$mb_var_def'
+ done
+
+ eval sed $mb_sed_substs $mb_template \
+ | eval m4 $mb_var_defs - \
+ | sed -e 's/[[:blank:]]*$//g' \
+ > $mb_pwd/Makefile.tmp
output_step_epilog
}
@@ -676,6 +818,36 @@ config_ccenv()
output_section_break
ccenv_set_native_variables
+ # implicit --sysroot for use with pkgconf and friends
+ if [ -z "$mb_sysroot" ]; then
+ mb_sysroot="$ccenv_host_sysroot"
+ fi
+
+ # require --sysroot when cross-compiling
+ if [ "$mb_cchost" != "$mb_native_cchost" ] \
+ && [ "$ccenv_host_cc" != "$ccenv_native_cc" ] \
+ && [ -z "$mb_sysroot" ]; then
+ mb_pretty=$(printf "%-${#mb_package}s" '')
+
+ error_msg ' !!'
+ error_msg "$mb_package: host machine: $mb_cchost"
+ error_msg "$mb_package: host compiler: $ccenv_host_cc"
+
+ error_msg ' !!'
+ error_msg "$mb_package: native machine: $mb_native_cchost"
+ error_msg "$mb_package: native compiler: $ccenv_native_cc"
+
+ error_msg ' !!'
+ error_msg "$mb_package: detected host machine and native machine differ, assuming cross-compilation."
+
+ error_msg ' !!'
+ error_msg "$mb_package: native compilation mode can be forced via --cchost=$mb_native_cchost"
+ error_msg "${mb_pretty} or otherwise by setting the NATIVE_CC environment variable to '$ccenv_host_cc',"
+ error_msg "${mb_pretty} however that should almost never be necessary; then again,"
+ error_msg "${mb_pretty} forcing native mode when cross-building is strictly prohibited."
+ fi
+
+ # re-generate Makefile.tmp
output_section_break
config_copy
}
@@ -695,6 +867,12 @@ config_custom()
eval config_custom_cfgdefs "$mb_custom_cfgdefs_args"
output_section_break
+
+ if [ -f "$mb_project_dir/project/config/Makefile.in" ]; then
+ config_copy "$mb_project_dir/project/config/Makefile.in"
+ mv $mb_pwd/Makefile.tmp Makefile
+ fi
+
config_copy
fi
@@ -722,7 +900,7 @@ config_cfghost()
$mb_pwd/Makefile.tmp > $mb_pwd/Makefile.host
rm $mb_pwd/Makefile.tmp
- mv $mb_pwd/Makefile.host $mb_pwd/Makefile
+ mv $mb_pwd/Makefile.host $mb_pwd/$mb_makefile
output_step_epilog
}
@@ -730,12 +908,70 @@ config_cfghost()
config_host()
{
+ # init
output_step_prolog ${mb_script} 'config_host'
- make -s host.tag \
- && output_step_epilog \
- && return 0
+ mb_cfghost_cc="$ccenv_host_cc"
+ mb_cfghost_tmpname='ccenv/c3RyaWN0X21vZGUK.c'
+
+ mb_cfghost_cflags=$(${mb_make} -n -f "$mb_makefile" \
+ .cflags-host)
+
+ mb_cfghost_cflags="${mb_cfghost_cflags#*: }"
+
+ if [ "$mb_cc_environment" = 'freestanding' ]; then
+ if [ -z "mb_cc_underscore" ]; then
+ mb_cfghost_start_fn='_start'
+ else
+ mb_cfghost_start_fn='start'
+ fi
+
+ printf 'int %s(void){return 0;}' "$mb_cfghost_start_fn" \
+ > "$mb_cfghost_tmpname"
+
+ mb_cfghost_cflags="$mb_cfghost_cflags -ffreestanding"
+ mb_cfghost_cflags="$mb_cfghost_cflags -nostdlib"
+ else
+ printf 'int main(void){return 0;}\n' \
+ > "$mb_cfghost_tmpname"
+ fi
+
+ # log
+ printf '\n' >&3
+
+ printf '%s\n' \
+ '#' \
+ '# verify that that following combination of' \
+ '# host compiler and host cflags is working.' \
+ '#' \
+ >&3
+
+ printf '\n%s' "$mb_cfghost_cc $ccenv_tmpname -o a.out" >&3
+
+ for mb_cfghost_cflag in $(printf '%s' "$mb_cfghost_cflags"); do
+ printf ' \\\n\t%s' "$mb_cfghost_cflag" >&3
+ done
+
+ printf '\n\n' >&3
+
+ # execute
+ if eval $mb_cfghost_cc "$ccenv_tmpname" -o a.out \
+ $(printf '%s' "$mb_cfghost_cflags") \
+ 2>&3; then
+ rm a.out
+ rm $mb_cfghost_tmpname
+ mb_cfghost_ret=0
+ else
+ mb_cfghost_ret=1
+ fi
+ if [ $mb_cfghost_ret = 0 ]; then
+ output_step_epilog
+ return 0
+ fi
+
+ # should never happen
+ error_msg
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"
error_msg "at least one of the required headers or features."
@@ -743,6 +979,15 @@ config_host()
}
+config_fini()
+{
+ # project-specific post-configuration steps
+ if [ _$mb_use_custom_cfgfini = _yes ]; then
+ . "$mb_project_dir/project/config/cfgfini.sh"
+ fi
+}
+
+
config_status()
{
output_script_status ${mb_script} \
@@ -772,16 +1017,37 @@ config_success()
# one: init
-mb_args=
-mb_args_space=
+mb_args_defs=
+mb_args_text=
+mb_args_idx=0
+
+init_log
for arg ; do
- mb_escaped_arg=\'$(printf '%s\n' "$arg" | sed -e "s/'/'\\\\''/g")\'
- mb_args="$mb_args$mb_args_space$mb_escaped_arg"
- mb_args_space=' '
+ mb_args_idx=$((mb_args_idx+1))
+
+ mb_arg_def=$(printf '%s%s="${%s}"' "-D_" "${mb_args_idx}" "${mb_args_idx}")
+ eval mb_args_defs='"$mb_args_defs "$mb_arg_def'
+
+ mb_args_text="$mb_args_text '_$((mb_args_idx))'"
done
-init_log
+printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
+
+if [ $mb_args_idx -gt 1 ]; then
+ printf '$ %s' "$mb_script" >&3
+
+ mb_args_idx=0
+ mb_args_text=
+
+ for arg; do
+ mb_args_idx=$((mb_args_idx+1))
+ mb_args_text="$mb_args_text"$(printf ' \\\\\n\t%s_%d%s' "'" "$mb_args_idx" "'")
+ done
+
+ printf "$mb_args_text\n\n" | eval m4 $mb_args_defs - >&3
+fi
+
init_vars
verify_build_directory
@@ -887,6 +1153,23 @@ for arg ; do
mb_psdir=${arg#*=}
;;
+ #make
+ --make=*)
+ mb_make=${arg#*=}
+ ;;
+
+ --makemode=*)
+ mb_makemode=${arg#*=}
+ ;;
+
+ #pkgconf[ig]
+ --pkgconf=*)
+ mb_pkgconf=${arg#*=}
+ ;;
+
+ --pkgconfig=*)
+ mb_pkgconf=${arg#*=}
+ ;;
# build
--build=*)
@@ -897,6 +1180,7 @@ for arg ; do
;;
--cchost=*)
mb_cchost=${arg#*=}
+ mb_cchost_set=yes
;;
--cfghost=*)
mb_cfghost=${arg#*=}
@@ -1118,11 +1402,13 @@ common_defaults
# five: config
config_flags
+config_opts
config_copy
config_ccenv
config_custom
config_cfghost
config_host
+config_fini
config_status