The following code will pull the version number out of ap_release.h:
cat include/ap_release.h | grep "define AP_SERVER_MAJORVERSION" | cut -d' ' -f3 | tr -d '\"'
Is it portable?
FWIW, I'd use:
grep "^#define AP_SERVER_MAJORVERSION" include/ap_release.h | cut -d' ' -f3 | tr -d '\"'
POSIX grep has limited regexp capabilities. The ^ is one of the supported features, so that should be safe.
However, note that Greg used sed in APR's build/get-version.sh (which prints out the version number for APR - similar task to what you need). So, you may be able to do it like this:
major_sed="/#define.*$3_MAJOR_VERSION/s/^.*\([0-9][0-9]*\).*$/\1/p" minor_sed="/#define.*$3_MINOR_VERSION/s/^.*\([0-9][0-9]*\).*$/\1/p" patch_sed="/#define.*$3_PATCH_VERSION/s/^.*\([0-9][0-9]*\).*$/\1/p" major="`sed -n $major_sed $2`" minor="`sed -n $minor_sed $2`" patch="`sed -n $patch_sed $2`"
echo ${major}.${minor}.${patch}
From a quick glance, the only thing you'd need to do is replaceMAJOR_VERSION's with MAJORVERSION's and invoke with:
./get-version.sh all include/ap_release.h AP_SERVER
That should work. You should also be able to tweak the script to respond to an mmn request 'get-version.sh mmn include/ap_release.h AP_SERVER' or something like that that spits out the current MMN. -- justin