windres-options 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. escape=
  10. if test "$1" = "--escape"; then
  11. escape=yes
  12. shift
  13. fi
  14. version="$1" # something like 2.0 or 2.17 or 2.17.3 or 2.17.3-pre3
  15. sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;}
  16. i\
  17. 0
  18. q
  19. '
  20. sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;}
  21. i\
  22. 0
  23. q
  24. '
  25. sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;}
  26. i\
  27. 0
  28. q
  29. '
  30. {
  31. echo "-DPACKAGE_VERSION_STRING=\"${version}\""
  32. echo "-DPACKAGE_VERSION_MAJOR="`echo "${version}" | sed -n -e "$sed_extract_major"`
  33. echo "-DPACKAGE_VERSION_MINOR="`echo "${version}" | sed -n -e "$sed_extract_minor"`
  34. echo "-DPACKAGE_VERSION_SUBMINOR="`echo "${version}" | sed -n -e "$sed_extract_subminor"`
  35. } |
  36. {
  37. if test -n "$escape"; then
  38. sed -e 's,\(["\\]\),\\\1,g'
  39. else
  40. cat
  41. fi
  42. }