1# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the
5# "Software"), to deal in the Software without restriction, including
6# without limitation the rights to use, copy, modify, merge, publish,
7# distribute, sub license, and/or sell copies of the Software, and to
8# permit persons to whom the Software is furnished to do so, subject to
9# the following conditions:
10#
11# The above copyright notice and this permission notice (including the
12# next paragraph) shall be included in all copies or substantial portions
13# of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
19# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23#!/bin/sh
24
25libva_topdir="$1"
26version_h_in="$2"
27
28parse_configure_ac() {
29    sed -n "/^m4_define.*${1}.*\[\([0-9]*\)\].*/s//\1/p" ${libva_topdir}/configure.ac
30}
31
32parse_configure() {
33    sed -n "/^${1}=\([0-9]*\)/s//\1/p" ${libva_topdir}/configure
34}
35
36if test -f "${libva_topdir}/configure.ac"; then
37    va_api_major_version=`parse_configure_ac va_api_major_version`
38    va_api_minor_version=`parse_configure_ac va_api_minor_version`
39    va_api_micro_version=`parse_configure_ac va_api_micro_version`
40elif test -f "${libva_topdir}/configure"; then
41    va_api_major_version=`parse_configure VA_API_MAJOR_VERSION`
42    va_api_minor_version=`parse_configure VA_API_MINOR_VERSION`
43    va_api_micro_version=`parse_configure VA_API_MICRO_VERSION`
44else
45    echo "ERROR: configure or configure.ac file not found in $libva_topdir/"
46    exit 1
47fi
48va_api_version="$va_api_major_version.$va_api_minor_version.$va_api_micro_version"
49
50sed -e "s/@VA_API_MAJOR_VERSION@/${va_api_major_version}/" \
51    -e "s/@VA_API_MINOR_VERSION@/${va_api_minor_version}/" \
52    -e "s/@VA_API_MICRO_VERSION@/${va_api_micro_version}/" \
53    -e "s/@VA_API_VERSION@/${va_api_version}/" \
54    $version_h_in
55