2017-11-24 01:34:16 +00:00
|
|
|
CONFIG_DEFINES=''
|
2019-02-08 20:28:15 +00:00
|
|
|
INCLUDE_DIRS=''
|
|
|
|
LIBRARY_DIRS=''
|
|
|
|
MAKEFILE_DEFINES=''
|
|
|
|
PKG_CONF_USED=''
|
2012-06-12 20:16:16 +00:00
|
|
|
|
2019-02-08 20:28:15 +00:00
|
|
|
ASFLAGS="${ASFLAGS:-}"
|
|
|
|
CFLAGS="${CFLAGS:-}"
|
|
|
|
CXXFLAGS="${CXXFLAGS:-}"
|
|
|
|
LDFLAGS="${LDFLAGS:-}"
|
2018-02-04 21:06:58 +00:00
|
|
|
PREFIX="${PREFIX:-/usr/local}"
|
|
|
|
SHARE_DIR="${SHARE_DIR:-${PREFIX}/share}"
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2019-01-25 22:10:14 +00:00
|
|
|
# add_define:
|
|
|
|
# $1 = MAKEFILE or CONFIG
|
2019-01-25 15:00:28 +00:00
|
|
|
# $2 = define
|
|
|
|
# $3 = value
|
2019-01-25 22:10:14 +00:00
|
|
|
add_define()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ eval "${1}_DEFINES=\"\${${1}_DEFINES} $2=$3\""; }
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# add_dirs:
|
|
|
|
# $1 = INCLUDE or LIBRARY
|
|
|
|
# $@ = include or library paths
|
|
|
|
add_dirs()
|
2017-11-24 17:57:07 +00:00
|
|
|
{ ADD="$1"; LINK="${1%"${1#?}"}"; shift
|
2019-02-08 19:59:28 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2017-11-24 17:57:07 +00:00
|
|
|
eval "${ADD}_DIRS=\"\${${ADD}_DIRS} -${LINK}${1}\""
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
eval "${ADD}_DIRS=\"\${${ADD}_DIRS# }\""
|
2020-01-15 04:06:09 +00:00
|
|
|
BUILD_DIRS="$INCLUDE_DIRS $LIBRARY_DIRS"
|
2017-10-21 03:44:28 +00:00
|
|
|
}
|
2012-06-12 20:16:16 +00:00
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_compiler:
|
|
|
|
# $1 = language
|
|
|
|
# $2 = function in lib
|
|
|
|
check_compiler()
|
2017-11-24 15:20:42 +00:00
|
|
|
{ if [ "$1" = cxx ]; then
|
2017-10-27 20:01:04 +00:00
|
|
|
COMPILER="$CXX"
|
2019-02-12 19:54:34 +00:00
|
|
|
FLAGS="$CXXFLAGS"
|
2017-10-27 20:01:04 +00:00
|
|
|
TEMP_CODE="$TEMP_CXX"
|
2017-11-24 15:20:42 +00:00
|
|
|
TEST_C="extern \"C\" { void $2(void); } int main() { $2(); }"
|
2012-06-12 20:16:16 +00:00
|
|
|
else
|
2017-10-27 20:01:04 +00:00
|
|
|
COMPILER="$CC"
|
2019-02-12 19:54:34 +00:00
|
|
|
FLAGS="$CFLAGS"
|
2017-10-27 20:01:04 +00:00
|
|
|
TEMP_CODE="$TEMP_C"
|
2017-11-24 15:20:42 +00:00
|
|
|
TEST_C="void $2(void); int main(void) { $2(); return 0; }"
|
2012-06-12 20:16:16 +00:00
|
|
|
fi
|
2017-11-24 15:20:42 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_enabled:
|
2019-06-20 05:19:30 +00:00
|
|
|
# $1 = HAVE_$1 [Disabled 'feature' or 'feature feature1 feature2', $1 = name]
|
2019-01-30 00:17:06 +00:00
|
|
|
# $2 = USER_$2 [Enabled feature]
|
|
|
|
# $3 = lib
|
|
|
|
# $4 = feature
|
2019-07-21 22:06:20 +00:00
|
|
|
# $5 = enable lib when true, disable errors with 'user' [checked only if non-empty]
|
2020-09-20 14:43:05 +00:00
|
|
|
# if any HAVE_$1 is true, HAVE_$2 is enabled
|
|
|
|
# if USER_$2 is false, HAVE_$2 is disabled
|
|
|
|
# if neither of the above, it's an error
|
2019-01-24 23:38:37 +00:00
|
|
|
check_enabled()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ add_opt "$2"
|
|
|
|
setval="$(eval "printf %s \"\$HAVE_$2\"")"
|
2019-01-30 19:51:21 +00:00
|
|
|
|
2019-06-20 05:19:30 +00:00
|
|
|
for val in $(printf %s "$1"); do
|
|
|
|
tmpvar="$(eval "printf %s \"\$HAVE_$val\"")"
|
|
|
|
if [ "$tmpvar" != 'no' ]; then
|
2019-07-21 22:06:20 +00:00
|
|
|
if [ "$setval" != 'no' ] && match "${5:-}" true user; then
|
2019-06-20 05:19:30 +00:00
|
|
|
eval "HAVE_$2=yes"
|
|
|
|
fi
|
|
|
|
return 0
|
2019-01-30 19:51:21 +00:00
|
|
|
fi
|
2019-06-20 05:19:30 +00:00
|
|
|
done
|
2019-01-30 19:51:21 +00:00
|
|
|
|
2019-01-30 00:17:06 +00:00
|
|
|
tmpval="$(eval "printf %s \"\$USER_$2\"")"
|
2018-05-02 16:15:20 +00:00
|
|
|
|
|
|
|
if [ "$tmpval" != 'yes' ]; then
|
2019-01-30 01:26:25 +00:00
|
|
|
if [ "$setval" != 'no' ]; then
|
|
|
|
eval "HAVE_$2=no"
|
2019-07-21 22:06:20 +00:00
|
|
|
if ! match "${5:-}" true user; then
|
2019-01-30 19:51:21 +00:00
|
|
|
die : "Notice: $4 disabled, $3 support will also be disabled."
|
|
|
|
fi
|
2019-01-30 01:26:25 +00:00
|
|
|
fi
|
2018-05-02 16:15:20 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2019-07-21 22:06:20 +00:00
|
|
|
if [ "${5:-}" != 'user' ]; then
|
|
|
|
die 1 "Error: $4 disabled and forced to build with $3 support."
|
|
|
|
fi
|
2018-05-02 16:15:20 +00:00
|
|
|
}
|
|
|
|
|
2019-05-14 03:11:52 +00:00
|
|
|
# check_platform:
|
2019-07-12 16:23:36 +00:00
|
|
|
# $1 = OS ['OS' or 'OS OS2 OS3', $1 = name]
|
2019-05-14 03:11:52 +00:00
|
|
|
# $2 = HAVE_$2
|
|
|
|
# $3 = feature
|
2019-07-12 16:23:36 +00:00
|
|
|
# $4 = enable feature when 'true', disable errors with 'user' [checked only if non-empty]
|
2019-05-14 03:11:52 +00:00
|
|
|
check_platform()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ add_opt "$2"
|
|
|
|
tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
|
2019-05-14 03:11:52 +00:00
|
|
|
[ "$tmpval" = 'no' ] && return 0
|
|
|
|
|
2019-07-12 16:23:36 +00:00
|
|
|
error=
|
|
|
|
newval=
|
2019-05-14 03:11:52 +00:00
|
|
|
setval="$(eval "printf %s \"\$USER_$2\"")"
|
|
|
|
|
2019-07-12 16:23:36 +00:00
|
|
|
for platform in $(printf %s "$1"); do
|
|
|
|
if [ "$setval" = 'yes' ]; then
|
|
|
|
if [ "$error" != 'no' ] && [ "${4:-}" != 'user' ] &&
|
|
|
|
{ { [ "$platform" != "$OS" ] &&
|
|
|
|
match "${4:-}" true user; } ||
|
|
|
|
{ [ "$platform" = "$OS" ] &&
|
|
|
|
! match "${4:-}" true user; }; }; then
|
|
|
|
error='yes'
|
|
|
|
elif match "${4:-}" true user; then
|
|
|
|
error='no'
|
|
|
|
fi
|
|
|
|
elif [ "$platform" = "$OS" ]; then
|
|
|
|
if match "${4:-}" true user; then
|
|
|
|
newval=yes
|
|
|
|
break
|
|
|
|
else
|
|
|
|
newval=no
|
|
|
|
fi
|
|
|
|
elif match "${4:-}" true user; then
|
|
|
|
newval=auto
|
2019-05-14 03:11:52 +00:00
|
|
|
fi
|
2019-07-12 16:23:36 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ "${error}" = 'yes' ]; then
|
|
|
|
die 1 "Error: $3 not supported for $OS."
|
|
|
|
else
|
|
|
|
eval "HAVE_$2=\"${newval:-$tmpval}\""
|
2019-05-14 03:11:52 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_lib:
|
|
|
|
# Compiles a simple test program to check if a library is available.
|
|
|
|
# $1 = language
|
|
|
|
# $2 = HAVE_$2
|
|
|
|
# $3 = lib
|
2019-01-31 20:55:07 +00:00
|
|
|
# $4 = function in lib [checked only if non-empty]
|
|
|
|
# $5 = extralibs [checked only if non-empty]
|
2019-01-25 07:07:43 +00:00
|
|
|
# $6 = headers [checked only if non-empty]
|
2019-02-10 18:15:33 +00:00
|
|
|
# $7 = include directory [checked only if non-empty]
|
|
|
|
# $8 = critical error message [checked only if non-empty]
|
2019-01-24 23:38:37 +00:00
|
|
|
check_lib()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ add_opt "$2"
|
|
|
|
tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
|
2017-11-24 15:20:42 +00:00
|
|
|
[ "$tmpval" = 'no' ] && return 0
|
|
|
|
|
|
|
|
check_compiler "$1" "$4"
|
2014-01-26 11:05:36 +00:00
|
|
|
|
2017-10-27 20:01:04 +00:00
|
|
|
if [ "$4" ]; then
|
2019-02-11 21:48:06 +00:00
|
|
|
MSG="Checking function $4 in"
|
2017-10-27 20:01:04 +00:00
|
|
|
if [ "$6" ]; then
|
|
|
|
printf %s\\n "$6" "int main(void) { void *p = (void*)$4; return 0; }" > "$TEMP_CODE"
|
|
|
|
else
|
2017-11-24 15:14:38 +00:00
|
|
|
printf %s\\n "$TEST_C" > "$TEMP_CODE"
|
2017-10-27 20:01:04 +00:00
|
|
|
fi
|
2012-06-12 20:16:16 +00:00
|
|
|
else
|
2019-02-11 21:48:06 +00:00
|
|
|
MSG='Checking existence of'
|
2017-11-24 15:14:38 +00:00
|
|
|
printf %s\\n 'int main(void) { return 0; }' > "$TEMP_CODE"
|
2012-06-12 20:16:16 +00:00
|
|
|
fi
|
2017-11-27 02:23:10 +00:00
|
|
|
|
2019-02-11 21:48:06 +00:00
|
|
|
lib="${3% }"
|
2019-02-10 18:15:33 +00:00
|
|
|
include="${7:-}"
|
|
|
|
error="${8:-}"
|
2012-06-12 20:16:16 +00:00
|
|
|
answer='no'
|
2020-01-14 22:07:13 +00:00
|
|
|
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s "$MSG $lib ... "
|
2020-01-14 22:07:13 +00:00
|
|
|
|
|
|
|
$(printf %s "$COMPILER") -o "$TEMP_EXE" "$TEMP_CODE" \
|
|
|
|
$(printf %s "$BUILD_DIRS $5 $FLAGS $LDFLAGS $lib") \
|
2020-01-13 17:17:00 +00:00
|
|
|
>>config.log 2>&1 && answer='yes'
|
2020-01-14 22:07:13 +00:00
|
|
|
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s\\n "$answer"
|
2019-02-10 18:15:33 +00:00
|
|
|
|
|
|
|
if [ "$answer" = 'yes' ] && [ "$include" ]; then
|
2019-02-11 21:48:06 +00:00
|
|
|
answer='no'
|
2020-01-14 22:07:13 +00:00
|
|
|
for dir in $(printf %s "$INCLUDES"); do
|
2019-02-11 21:48:06 +00:00
|
|
|
[ "$answer" = 'yes' ] && break
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s "Checking existence of /$dir/$include ... "
|
2019-02-11 21:48:06 +00:00
|
|
|
if [ -d "/$dir/$include" ]; then
|
2020-01-14 22:07:13 +00:00
|
|
|
eval "${2}_CFLAGS=\"-I/$dir/$include\""
|
2019-02-11 21:48:06 +00:00
|
|
|
answer='yes'
|
|
|
|
fi
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s\\n "$answer"
|
2019-02-10 18:15:33 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2020-01-14 22:07:13 +00:00
|
|
|
eval "HAVE_$2=\"$answer\""
|
2017-11-06 15:17:52 +00:00
|
|
|
rm -f -- "$TEMP_CODE" "$TEMP_EXE"
|
2017-10-27 20:01:04 +00:00
|
|
|
|
2017-11-25 21:12:31 +00:00
|
|
|
if [ "$answer" = 'no' ]; then
|
2017-11-27 02:23:10 +00:00
|
|
|
[ "$error" ] && die 1 "$error"
|
2020-01-14 22:07:13 +00:00
|
|
|
setval="$(eval "printf %s \"\$USER_$2\"")"
|
2019-02-10 18:15:33 +00:00
|
|
|
if [ "$setval" = 'yes' ]; then
|
2017-11-27 02:23:10 +00:00
|
|
|
die 1 "Forced to build with library $lib, but cannot locate. Exiting ..."
|
2019-02-10 18:15:33 +00:00
|
|
|
fi
|
2017-11-25 21:12:31 +00:00
|
|
|
else
|
2020-01-14 22:07:13 +00:00
|
|
|
eval "${2}_LIBS=\"$lib\""
|
|
|
|
PKG_CONF_USED="$PKG_CONF_USED $2"
|
2017-11-25 21:12:31 +00:00
|
|
|
fi
|
2014-01-26 11:05:36 +00:00
|
|
|
|
2017-10-24 07:18:23 +00:00
|
|
|
return 0
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_pkgconf:
|
|
|
|
# If available uses $PKG_CONF_PATH to find a library.
|
|
|
|
# $1 = HAVE_$1
|
2019-02-11 23:56:39 +00:00
|
|
|
# $2 = package ['package' or 'package package1 package2', $1 = name]
|
2019-01-24 23:38:37 +00:00
|
|
|
# $3 = version [checked only if non-empty]
|
|
|
|
# $4 = critical error message [checked only if non-empty]
|
2019-02-13 15:42:21 +00:00
|
|
|
# $5 = force check_lib when true [checked only if non-empty, set by check_val]
|
2019-01-24 23:38:37 +00:00
|
|
|
check_pkgconf()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ add_opt "$1"
|
|
|
|
tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
|
2017-12-30 16:08:08 +00:00
|
|
|
eval "TMP_$1=\$tmpval"
|
2012-06-12 20:16:16 +00:00
|
|
|
[ "$tmpval" = 'no' ] && return 0
|
|
|
|
|
2019-02-11 21:48:06 +00:00
|
|
|
ECHOBUF=''
|
|
|
|
[ "${3:-}" ] && ECHOBUF=" >= ${3##* }"
|
|
|
|
|
2019-02-11 23:56:39 +00:00
|
|
|
pkg="${2%% *}"
|
2019-02-11 21:48:06 +00:00
|
|
|
MSG='Checking presence of package'
|
2015-04-19 12:31:08 +00:00
|
|
|
|
|
|
|
[ "$PKG_CONF_PATH" = "none" ] && {
|
2017-11-26 21:54:53 +00:00
|
|
|
eval "HAVE_$1=no"
|
2019-01-25 22:10:14 +00:00
|
|
|
eval "${1#HAVE_}_VERSION=0.0"
|
2019-02-11 23:56:39 +00:00
|
|
|
printf %s\\n "$MSG $pkg$ECHOBUF ... no"
|
2015-04-19 12:31:08 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-02-11 23:56:39 +00:00
|
|
|
ver="${3:-0.0}"
|
|
|
|
err="${4:-}"
|
2019-02-13 15:42:21 +00:00
|
|
|
lib="${5:-}"
|
2012-06-12 20:16:16 +00:00
|
|
|
answer='no'
|
2015-04-19 11:34:37 +00:00
|
|
|
version='no'
|
2019-01-25 22:10:14 +00:00
|
|
|
|
2020-01-14 22:07:13 +00:00
|
|
|
for pkgnam in $(printf %s "${2#* }"); do
|
2019-02-11 23:56:39 +00:00
|
|
|
[ "$answer" = 'yes' ] && break
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s "$MSG $pkgnam$ECHOBUF ... "
|
2020-01-14 22:07:13 +00:00
|
|
|
for pkgver in $(printf %s "$ver"); do
|
2019-02-12 01:49:43 +00:00
|
|
|
if "$PKG_CONF_PATH" --atleast-version="$pkgver" "$pkgnam"; then
|
2019-02-11 23:56:39 +00:00
|
|
|
answer='yes'
|
|
|
|
version="$("$PKG_CONF_PATH" --modversion "$pkgnam")"
|
2020-01-14 22:07:13 +00:00
|
|
|
eval "${1}_CFLAGS=\"$("$PKG_CONF_PATH" --cflags "$pkgnam")\""
|
|
|
|
eval "${1}_LIBS=\"$("$PKG_CONF_PATH" --libs "$pkgnam")\""
|
|
|
|
eval "${1}_VERSION=\"$pkgver\""
|
2019-02-11 23:56:39 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s\\n "$version"
|
2019-01-25 22:10:14 +00:00
|
|
|
done
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2020-01-14 22:07:13 +00:00
|
|
|
eval "HAVE_$1=\"$answer\""
|
2019-02-11 21:48:06 +00:00
|
|
|
|
2017-11-25 20:19:22 +00:00
|
|
|
if [ "$answer" = 'no' ]; then
|
2019-02-13 15:42:21 +00:00
|
|
|
[ "$lib" != 'true' ] || return 0
|
2019-01-25 22:10:14 +00:00
|
|
|
[ "$err" ] && die 1 "$err"
|
2020-01-14 22:07:13 +00:00
|
|
|
setval="$(eval "printf %s \"\$USER_$1\"")"
|
2019-02-10 18:15:33 +00:00
|
|
|
if [ "$setval" = 'yes' ]; then
|
2019-01-25 22:10:14 +00:00
|
|
|
die 1 "Forced to build with package $pkg, but cannot locate. Exiting ..."
|
2019-02-10 18:15:33 +00:00
|
|
|
fi
|
2017-11-25 20:19:22 +00:00
|
|
|
else
|
2020-01-14 22:07:13 +00:00
|
|
|
PKG_CONF_USED="$PKG_CONF_USED $1"
|
2017-11-25 20:19:22 +00:00
|
|
|
fi
|
2012-06-12 20:16:16 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_header:
|
2020-02-01 23:40:43 +00:00
|
|
|
# $1 = language
|
|
|
|
# $2 = HAVE_$2
|
2019-01-24 23:38:37 +00:00
|
|
|
# $@ = header files
|
|
|
|
check_header()
|
2020-02-01 23:40:43 +00:00
|
|
|
{ add_opt "$2"
|
|
|
|
check_compiler "$1" ''
|
|
|
|
tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
|
2012-06-12 20:16:16 +00:00
|
|
|
[ "$tmpval" = 'no' ] && return 0
|
2018-12-14 22:37:21 +00:00
|
|
|
rm -f -- "$TEMP_C"
|
2020-02-01 23:40:43 +00:00
|
|
|
val="$2"
|
|
|
|
header="$3"
|
|
|
|
shift 2
|
2018-12-14 22:37:21 +00:00
|
|
|
for head do
|
|
|
|
CHECKHEADER="$head"
|
2020-02-01 23:40:43 +00:00
|
|
|
printf %s\\n "#include <$head>" >> "$TEMP_CODE"
|
2018-12-14 22:37:21 +00:00
|
|
|
done
|
2020-02-01 23:40:43 +00:00
|
|
|
printf %s\\n "int main(void) { return 0; }" >> "$TEMP_CODE"
|
2018-12-14 22:37:21 +00:00
|
|
|
answer='no'
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s "Checking presence of header file $CHECKHEADER ... "
|
2020-02-01 23:40:43 +00:00
|
|
|
$(printf %s "$COMPILER") -o "$TEMP_EXE" "$TEMP_CODE" \
|
|
|
|
$(printf %s "$BUILD_DIRS $FLAGS $LDFLAGS") >>config.log 2>&1 &&
|
2020-01-13 17:17:00 +00:00
|
|
|
answer='yes'
|
2017-11-27 18:03:13 +00:00
|
|
|
eval "HAVE_$val=\"$answer\""
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s\\n "$answer"
|
2017-11-06 15:17:52 +00:00
|
|
|
rm -f -- "$TEMP_C" "$TEMP_EXE"
|
2019-02-10 18:15:33 +00:00
|
|
|
setval="$(eval "printf %s \"\$USER_$val\"")"
|
|
|
|
if [ "$setval" = 'yes' ] && [ "$answer" = 'no' ]; then
|
2017-11-27 18:03:13 +00:00
|
|
|
die 1 "Build assumed that $header exists, but cannot locate. Exiting ..."
|
2019-02-10 18:15:33 +00:00
|
|
|
fi
|
2012-06-12 20:16:16 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_macro:
|
|
|
|
# $1 = HAVE_$1
|
|
|
|
# $2 = macro name
|
|
|
|
# $3 = header name [included only if non-empty]
|
|
|
|
check_macro()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ add_opt "$1"
|
|
|
|
tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
|
2012-12-09 15:28:49 +00:00
|
|
|
[ "$tmpval" = 'no' ] && return 0
|
2019-02-11 21:48:06 +00:00
|
|
|
header_include=''
|
|
|
|
ECHOBUF=''
|
|
|
|
if [ "${3:-}" ]; then
|
2018-12-21 15:43:40 +00:00
|
|
|
header_include="#include <$3>"
|
2019-02-11 21:48:06 +00:00
|
|
|
ECHOBUF=" in $3"
|
2018-12-21 14:15:30 +00:00
|
|
|
fi
|
2012-12-09 15:28:49 +00:00
|
|
|
cat << EOF > "$TEMP_C"
|
2018-12-21 14:15:30 +00:00
|
|
|
$header_include
|
2012-12-09 15:28:49 +00:00
|
|
|
#ifndef $2
|
|
|
|
#error $2 is not defined
|
|
|
|
#endif
|
|
|
|
int main(void) { return 0; }
|
|
|
|
EOF
|
|
|
|
answer='no'
|
2017-11-27 18:03:13 +00:00
|
|
|
val="$1"
|
|
|
|
macro="$2"
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s "Checking presence of predefined macro $macro$ECHOBUF ... "
|
2020-01-14 22:07:13 +00:00
|
|
|
$(printf %s "$CC") -o "$TEMP_EXE" "$TEMP_C" \
|
|
|
|
$(printf %s "$BUILD_DIRS $CFLAGS $LDFLAGS") >>config.log 2>&1 &&
|
2020-01-13 17:17:00 +00:00
|
|
|
answer='yes'
|
2017-11-27 18:03:13 +00:00
|
|
|
eval "HAVE_$val=\"$answer\""
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s\\n "$answer"
|
2017-11-06 15:17:52 +00:00
|
|
|
rm -f -- "$TEMP_C" "$TEMP_EXE"
|
2019-02-10 18:15:33 +00:00
|
|
|
setval="$(eval "printf %s \"\$USER_$val\"")"
|
|
|
|
if [ "$setval" = 'yes' ] && [ "$answer" = 'no' ]; then
|
2017-11-27 18:03:13 +00:00
|
|
|
die 1 "Build assumed that $macro is defined, but it's not. Exiting ..."
|
2019-02-10 18:15:33 +00:00
|
|
|
fi
|
2012-12-09 15:28:49 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_switch:
|
|
|
|
# $1 = language
|
|
|
|
# $2 = HAVE_$2
|
|
|
|
# $3 = switch
|
|
|
|
# $4 = critical error message [checked only if non-empty]
|
|
|
|
check_switch()
|
2019-07-27 16:58:17 +00:00
|
|
|
{ add_opt "$2"
|
|
|
|
check_compiler "$1" ''
|
2012-06-12 20:16:16 +00:00
|
|
|
|
2017-11-24 16:09:14 +00:00
|
|
|
printf %s\\n 'int main(void) { return 0; }' > "$TEMP_CODE"
|
2012-06-12 20:16:16 +00:00
|
|
|
answer='no'
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s "Checking for availability of switch $3 in $COMPILER ... "
|
2020-01-15 04:17:15 +00:00
|
|
|
$(printf %s "$COMPILER") -o "$TEMP_EXE" "$TEMP_CODE" \
|
|
|
|
$(printf %s "$BUILD_DIRS $CFLAGS $3 -Werror $LDFLAGS") \
|
2020-01-13 17:17:00 +00:00
|
|
|
>>config.log 2>&1 && answer='yes'
|
2017-11-24 16:09:14 +00:00
|
|
|
eval "HAVE_$2=\"$answer\""
|
2019-11-01 15:37:07 +00:00
|
|
|
printf %s\\n "$answer"
|
2017-11-24 16:09:14 +00:00
|
|
|
rm -f -- "$TEMP_CODE" "$TEMP_EXE"
|
2020-01-15 04:17:15 +00:00
|
|
|
if [ "$answer" = 'yes' ]; then
|
|
|
|
eval "${2}_CFLAGS=\"$3\""
|
|
|
|
PKG_CONF_USED="$PKG_CONF_USED $2"
|
|
|
|
elif [ "${4:-}" ]; then
|
2019-02-11 21:48:06 +00:00
|
|
|
die 1 "$4"
|
|
|
|
fi
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:38:37 +00:00
|
|
|
# check_val:
|
|
|
|
# Uses check_pkgconf to find a library and falls back to check_lib if false.
|
|
|
|
# $1 = language
|
|
|
|
# $2 = HAVE_$2
|
|
|
|
# $3 = lib
|
|
|
|
# $4 = include directory [checked only if non-empty]
|
|
|
|
# $5 = package
|
|
|
|
# $6 = version [checked only if non-empty]
|
|
|
|
# $7 = critical error message [checked only if non-empty]
|
2019-01-28 14:34:30 +00:00
|
|
|
# $8 = force check_lib when true [checked only if non-empty]
|
2019-01-24 23:38:37 +00:00
|
|
|
check_val()
|
2019-02-13 15:42:21 +00:00
|
|
|
{ check_pkgconf "$2" "$5" "${6:-}" "${7:-}" "${8:-}"
|
2019-01-28 14:34:30 +00:00
|
|
|
[ "$PKG_CONF_PATH" = "none" ] || [ "${8:-}" = true ] || return 0
|
2019-01-24 23:38:37 +00:00
|
|
|
tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
|
2017-12-30 16:08:08 +00:00
|
|
|
oldval="$(eval "printf %s \"\$TMP_$2\"")"
|
|
|
|
if [ "$tmpval" = 'no' ] && [ "$oldval" != 'no' ]; then
|
2017-11-26 01:09:26 +00:00
|
|
|
eval "HAVE_$2=auto"
|
2019-02-13 15:42:21 +00:00
|
|
|
check_lib "$1" "$2" "$3" '' '' '' "${4:-}" "${7:-}"
|
2017-11-26 01:09:26 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2010-12-30 01:52:02 +00:00
|
|
|
create_config_header()
|
2012-06-12 20:16:16 +00:00
|
|
|
{ outfile="$1"; shift
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2017-11-23 21:57:32 +00:00
|
|
|
printf %s\\n "Creating config header: $outfile"
|
|
|
|
name="$(printf %s "QB_${outfile}__" | tr '.[a-z]' '_[A-Z]')"
|
|
|
|
|
|
|
|
{ printf %s\\n "#ifndef $name" "#define $name" '' \
|
|
|
|
"#define PACKAGE_NAME \"$PACKAGE_NAME\""
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2019-02-08 19:59:28 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2017-11-23 21:57:32 +00:00
|
|
|
case "$(eval "printf %s \"\$HAVE_$1\"")" in
|
2015-09-22 14:39:50 +00:00
|
|
|
'yes')
|
2019-02-07 22:34:37 +00:00
|
|
|
n='0'
|
|
|
|
c89_build="$(eval "printf %s \"\$C89_$1\"")"
|
|
|
|
cxx_build="$(eval "printf %s \"\$CXX_$1\"")"
|
|
|
|
|
|
|
|
if [ "$c89_build" = 'no' ]; then
|
|
|
|
n=$(($n+1))
|
|
|
|
printf %s\\n '#if __cplusplus || __STDC_VERSION__ >= 199901L'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$cxx_build" = 'no' ]; then
|
|
|
|
n=$(($n+1))
|
|
|
|
printf %s\\n '#ifndef CXX_BUILD'
|
2017-11-23 21:57:32 +00:00
|
|
|
fi
|
2019-02-07 22:34:37 +00:00
|
|
|
|
|
|
|
printf %s\\n "#define HAVE_$1 1"
|
|
|
|
|
|
|
|
while [ $n != '0' ]; do
|
|
|
|
n=$(($n-1))
|
|
|
|
printf %s\\n '#endif'
|
|
|
|
done
|
2017-11-23 21:57:32 +00:00
|
|
|
;;
|
|
|
|
'no') printf %s\\n "/* #undef HAVE_$1 */";;
|
2012-06-12 20:16:16 +00:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2020-01-14 22:07:13 +00:00
|
|
|
for VAR in $(printf %s "$CONFIG_DEFINES"); do
|
2017-11-24 01:34:16 +00:00
|
|
|
printf %s\\n "#define ${VAR%%=*} ${VAR#*=}"
|
|
|
|
done
|
2010-12-30 01:52:02 +00:00
|
|
|
|
2017-11-23 21:57:32 +00:00
|
|
|
printf %s\\n '#endif'
|
2012-06-12 20:16:16 +00:00
|
|
|
} > "$outfile"
|
2010-12-30 01:52:02 +00:00
|
|
|
}
|
|
|
|
|
2012-06-12 20:16:16 +00:00
|
|
|
create_config_make()
|
|
|
|
{ outfile="$1"; shift
|
|
|
|
|
2017-11-23 17:39:22 +00:00
|
|
|
printf %s\\n "Creating make config: $outfile"
|
2012-06-12 20:16:16 +00:00
|
|
|
|
2018-12-19 18:14:16 +00:00
|
|
|
{ if [ "$HAVE_CC" = 'yes' ]; then
|
|
|
|
printf %s\\n "CC = $CC"
|
|
|
|
|
|
|
|
if [ "${CFLAGS}" ]; then
|
|
|
|
printf %s\\n "CFLAGS = $CFLAGS"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$HAVE_CXX" = 'yes' ]; then
|
|
|
|
printf %s\\n "CXX = $CXX"
|
|
|
|
|
|
|
|
if [ "${CXXFLAGS}" ]; then
|
|
|
|
printf %s\\n "CXXFLAGS = $CXXFLAGS"
|
|
|
|
fi
|
|
|
|
fi
|
2017-11-23 17:39:22 +00:00
|
|
|
|
|
|
|
printf %s\\n "WINDRES = $WINDRES" \
|
2018-04-30 18:33:05 +00:00
|
|
|
"MOC = $MOC" \
|
2017-11-23 17:39:22 +00:00
|
|
|
"ASFLAGS = $ASFLAGS" \
|
|
|
|
"LDFLAGS = $LDFLAGS" \
|
|
|
|
"INCLUDE_DIRS = $INCLUDE_DIRS" \
|
|
|
|
"LIBRARY_DIRS = $LIBRARY_DIRS" \
|
|
|
|
"PACKAGE_NAME = $PACKAGE_NAME" \
|
|
|
|
"BUILD = $BUILD" \
|
|
|
|
"PREFIX = $PREFIX"
|
2012-06-12 20:16:16 +00:00
|
|
|
|
2019-02-08 19:59:28 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2017-11-23 17:39:22 +00:00
|
|
|
case "$(eval "printf %s \"\$HAVE_$1\"")" in
|
2015-09-22 14:39:50 +00:00
|
|
|
'yes')
|
2019-02-07 22:34:37 +00:00
|
|
|
n='0'
|
|
|
|
c89_build="C89_$1"
|
|
|
|
cxx_build="CXX_$1"
|
|
|
|
|
|
|
|
for build in "$c89_build" "$cxx_build"; do
|
|
|
|
if [ "$(eval "printf %s \"\$$build\"")" = 'no' ]; then
|
|
|
|
n=$(($n+1))
|
|
|
|
printf %s\\n "ifneq (\$(${build%%_*}_BUILD),1)"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
printf %s\\n "HAVE_$1 = 1"
|
|
|
|
|
|
|
|
while [ $n != '0' ]; do
|
|
|
|
n=$(($n-1))
|
|
|
|
printf %s\\n 'endif'
|
|
|
|
done
|
2017-11-23 17:39:22 +00:00
|
|
|
;;
|
|
|
|
'no') printf %s\\n "HAVE_$1 = 0";;
|
2012-06-12 20:16:16 +00:00
|
|
|
esac
|
2019-02-03 23:49:35 +00:00
|
|
|
|
2012-06-12 20:16:16 +00:00
|
|
|
case "$PKG_CONF_USED" in
|
|
|
|
*$1*)
|
2017-11-27 02:23:10 +00:00
|
|
|
FLAG="$(eval "printf %s \"\$$1_CFLAGS\"")"
|
2017-11-23 17:39:22 +00:00
|
|
|
LIBS="$(eval "printf %s \"\$$1_LIBS\"")"
|
2017-11-27 02:23:10 +00:00
|
|
|
[ "${FLAG}" ] && printf %s\\n "$1_CFLAGS = ${FLAG%"${FLAG##*[! ]}"}"
|
2017-11-25 21:12:31 +00:00
|
|
|
[ "${LIBS}" ] && printf %s\\n "$1_LIBS = ${LIBS%"${LIBS##*[! ]}"}"
|
2012-06-12 20:16:16 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2020-01-14 22:07:13 +00:00
|
|
|
|
|
|
|
for VAR in $(printf %s "$MAKEFILE_DEFINES"); do
|
2017-11-23 22:48:02 +00:00
|
|
|
printf %s\\n "${VAR%%=*} = ${VAR#*=}"
|
|
|
|
done
|
2012-06-12 20:16:16 +00:00
|
|
|
|
|
|
|
} > "$outfile"
|
|
|
|
}
|
|
|
|
|
|
|
|
. qb/config.libs.sh
|