Imported Upstream version 0.9.3
[platform/upstream/libunistring.git] / build-aux / windres-options
1 #!/bin/sh
2 # Usage: windres-options [--escape] PACKAGE_VERSION
3 # Outputs a set of command-line options for 'windres', containing definitions
4 # for the preprocessor variables
5 #   PACKAGE_VERSION_STRING
6 #   PACKAGE_VERSION_MAJOR
7 #   PACKAGE_VERSION_MINOR
8 #   PACKAGE_VERSION_SUBMINOR
9
10 escape=
11 if test "$1" = "--escape"; then
12   escape=yes
13   shift
14 fi
15 version="$1" # something like 2.0 or 2.17 or 2.17.3 or 2.17.3-pre3
16
17 sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;}
18 i\
19 0
20 q
21 '
22 sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;}
23 i\
24 0
25 q
26 '
27 sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;}
28 i\
29 0
30 q
31 '
32
33 {
34   echo "-DPACKAGE_VERSION_STRING=\"${version}\""
35   echo "-DPACKAGE_VERSION_MAJOR="`echo "${version}" | sed -n -e "$sed_extract_major"`
36   echo "-DPACKAGE_VERSION_MINOR="`echo "${version}" | sed -n -e "$sed_extract_minor"`
37   echo "-DPACKAGE_VERSION_SUBMINOR="`echo "${version}" | sed -n -e "$sed_extract_subminor"`
38 } |
39 {
40   if test -n "$escape"; then
41     sed -e 's,\(["\\]\),\\\1,g'
42   else
43     cat
44   fi
45 }