• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# Copyright (C) 2007 Free Software Foundation, Inc.
4# Written by Bruno Haible <bruno@clisp.org>, 2007.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
19# Usage: windres-options [--escape] PACKAGE_VERSION
20# Outputs a set of command-line options for 'windres', containing definitions
21# for the preprocessor variables
22#   PACKAGE_VERSION_STRING
23#   PACKAGE_VERSION_MAJOR
24#   PACKAGE_VERSION_MINOR
25#   PACKAGE_VERSION_SUBMINOR
26
27escape=
28if test "$1" = "--escape"; then
29  escape=yes
30  shift
31fi
32version="$1" # something like 2.0 or 2.17 or 2.17.3 or 2.17.3-pre3
33
34sed_extract_major='/^[0-9]/{
35s/^\([0-9]*\).*/\1/p
36q
37}
38c\
390
40q
41'
42sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{
43s/^[0-9]*[.]\([0-9]*\).*/\1/p
44q
45}
46c\
470
48q
49'
50sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{
51s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p
52q
53}
54c\
550
56q
57'
58
59{
60  echo "-DPACKAGE_VERSION_STRING=\"${version}\""
61  echo "-DPACKAGE_VERSION_MAJOR="`echo "${version}" | sed -n -e "$sed_extract_major"`
62  echo "-DPACKAGE_VERSION_MINOR="`echo "${version}" | sed -n -e "$sed_extract_minor"`
63  echo "-DPACKAGE_VERSION_SUBMINOR="`echo "${version}" | sed -n -e "$sed_extract_subminor"`
64} |
65{
66  if test -n "$escape"; then
67    sed -e 's,\(["\\]\),\\\1,g'
68  else
69    cat
70  fi
71}
72