diff --git a/Makefile b/Makefile index 37ed83e416..8c9498cdb9 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,11 @@ export TAR export PATCH export SED export NM +export FIND +export BASENAME +export DIRNAME +export XMLLINT +export XMLSTARLET # makeopts is required unless the goal is just {dist{-}}clean ifeq ($(MAKECMDGOALS),clean) diff --git a/build_tools/get_sourceable_makeopts b/build_tools/get_sourceable_makeopts deleted file mode 100755 index fbf4c38fc6..0000000000 --- a/build_tools/get_sourceable_makeopts +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -PROGNAME="${0##*/}" - -if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then - cat <<-EOF - Usage: ${PROGNAME}: [ ] [ ] - - This script takes an Asterisk makeopts file, or any file containing - "make" style variable assignments, and converts it into a format - that can be directly 'sourced' by shell scripts. - - * Any spaces around the equals sign are removed. - * The variable value is quoted. - * The "make" "or" command is evaluated. - - Both input and output files are optional and will default to - stdin and stdout respectively. - - NOTE: This script relies on NO external commands and only POSIX - constructs. It should be runnable by any shell. - EOF - exit 1 -fi - -input_file="/dev/stdin" -if [ "$1" != "" ] ; then - input_file="$1" -fi - -output_file="/dev/stdout" -if [ "$2" != "" ] ; then - output_file="$2" -fi - -# orfunc is a code fragment to be added to the outp[ut file. -# We don't WANT the variables evaluated. -# shellcheck disable=SC2016 -orfunc='or (){ before="${1%,*}" ; after="${1#*,}" ; if [ "$before" = "" ] ; then echo "${after}" ; else echo "${before}" ; fi ; }' -echo "${orfunc}" >"${output_file}" - -while read -r LINE ; do - var="${LINE%%=*}" - if [ "${var}" != "" ] ; then - val="${LINE#*=}" - if [ "${val}" != "${var}" ] ; then - if [ "${val%% *}" = "" ] ; then - echo "${var% *}=\"${val#* }\"" - else - echo "${var% *}=\"${val}\"" - fi - fi - fi -done <"${input_file}" >>"${output_file}" - diff --git a/build_tools/make_xml_documentation b/build_tools/make_xml_documentation index 54144ce8a7..3446fff0c8 100755 --- a/build_tools/make_xml_documentation +++ b/build_tools/make_xml_documentation @@ -1,10 +1,7 @@ #!/bin/sh -# The GREP, SED, FIND, etc variables are all set at run time from -# makeopts. # shellcheck disable=SC2154 PROGNAME="${0##*/}" -PROGDIR="${0%/*}" # Fail on errors set -e @@ -111,36 +108,25 @@ if [ ! -d "${source_tree}" ] ; then exit 1 fi -if [ ! -f "${source_tree}/Makefile" ] ; then - echo "There's no 'Makefile' in '${source_tree}'." - exit 1 -fi - if [ ! -f "${source_tree}/makeopts" ] ; then echo "There's no 'makeopts' in '${source_tree}'. Maybe you need to run ./configure?" exit 1 fi -# This will get the paths to the utilities we need, all -# of which will be in makeopts. We need to convert the -# format so it's sourceable. -tmpname="/tmp/ast_makeopts.$$.env" -trap 'rm "$tmpname" >/dev/null 2>&1' INT QUIT TERM EXIT -"${PROGDIR}/get_sourceable_makeopts" "${source_tree}/makeopts" >"${tmpname}" -# The file to be sourced is generated at run time and can't be checked. -# shellcheck disable=SC1090 -. "${tmpname}" -rm "${tmpname}" > /dev/null 2>&1 || : -trap - INT QUIT TERM EXIT - -# Make sure we have everything we need. -for c in GREP FIND AWK DIRNAME BASENAME SED CAT ; do - bin=$(eval "echo \${${c}}") - if [ "${bin}" = "" ] ; then - echo "The '${c}' utility was not found." - exit 1 - fi -done +# This script is normally run from the top-level Makefile which +# will set the tools variables to actual paths, or ':' if +# the tool isn't found. If this script is run from the +# command line for testing purposes however, we'll need to +# set some sane defaults. +if [ "${GREP}" = "" ] ; then GREP="grep" ; fi +if [ "${FIND}" = "" ] ; then FIND="find" ; fi +if [ "${AWK}" = "" ] ; then AWK="awk" ; fi +if [ "${DIRNAME}" = "" ] ; then DIRNAME="dirname" ; fi +if [ "${BASENAME}" = "" ] ; then BASENAME="basename" ; fi +if [ "${SED}" = "" ] ; then SED="sed" ; fi +if [ "${CAT}" = "" ] ; then CAT="cat" ; fi +if [ "${XMLLINT}" = "" ] ; then XMLLINT="xmllint" ; fi +if [ "${XMLSTARLET}" = "" ] ; then XMLSTARLET="xmlstarlet" ; fi if [ "${for_wiki}" -eq "1" ] || [ "${validate}" -eq "1" ]; then if [ "${XMLLINT}${XMLSTARLET}" = "::" ] ; then