Ignore:
Timestamp:
May 20, 2014, 9:00:16 AM (9 years ago)
Author:
Peter
Message:

translate variables when PACKAGE is not suitable as shell variable or a C #define.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/m4/my_version.m4

    r2853 r3229  
    11## $Id$
    22#
    3 # Copyright (C) 2012 Peter Johansson
     3# Copyright (C) 2012, 2014 Peter Johansson
    44#
    55# This file is part of the yat library, http://dev.thep.lu.se/yat
     
    1919#
    2020
    21 # serial 0
     21# serial 1 (yat 0.13)
    2222
    2323# How to use this file
    2424# ====================
    25 # In 'configure.ac', include this file and call 'MY_VERSION_early'
    26 # before 'AC_INIT'.  After AC_INIT you can call MY_VERSION in order to
    27 # AC_SUBST and AC_DEFINE variables MAJOR_VERSION, MINOR_VERSION etc.
    28 #   m4_include([m4/version.m4])
     25#
     26# Copy this file to your project, e.g. directory 'm4/'. Aclocal will
     27# not do that du to limitations.  In 'configure.ac', include this file
     28# and call 'MY_VERSION_early' before 'AC_INIT'.  After AC_INIT you can
     29# call MY_VERSION in order to AC_SUBST and AC_DEFINE variables
     30# FOO_MAJOR_VERSION, FOO_MINOR_VERSION etc., where FOO has been
     31# replaced with PACKAGE_NAME after appropriate translation (to suit a
     32# Make variable or PP #define):
     33#
     34#   m4_include([m4/my_version.m4])
    2935#   MY_VERSION_early([3],[1],[4],[true])
    3036#   AC_INIT([foo], [my_VERSION])
     
    5157m4_ifndef([my_VERSION],
    5258          [m4_fatal([MY_VERSION_early must be expanded before MY_VERSION])])
    53 AC_SUBST(m4_toupper(AC_PACKAGE_NAME)[_MAJOR_VERSION], [my_MAJOR_VERSION])
    54 AC_SUBST(m4_toupper(AC_PACKAGE_NAME)[_MINOR_VERSION], [my_MINOR_VERSION])
    55 AC_SUBST(m4_toupper(AC_PACKAGE_NAME)[_PATCH_VERSION], [my_PATCH_VERSION])
    5659
     60AS_VAR_PUSHDEF([my_PACKAGE_SH], [m4_toupper(AC_PACKAGE_NAME)])
     61AC_SUBST(my_PACKAGE_SH[_MAJOR_VERSION], [my_MAJOR_VERSION])
     62AC_SUBST(my_PACKAGE_SH[_MINOR_VERSION], [my_MINOR_VERSION])
     63AC_SUBST(my_PACKAGE_SH[_PATCH_VERSION], [my_PATCH_VERSION])
     64AS_VAR_POPDEF([my_PACKAGE_SH])
     65
     66m4_pushdef([my_PACKAGE_CPP], [AS_TR_CPP([m4_toupper(AC_PACKAGE_NAME)])])
    5767AC_DEFINE([DEV_BUILD],[my_DEV_BUILD],
    5868          [true if dev build (version ends with pre)])
    59 AC_DEFINE(m4_toupper(AC_PACKAGE_NAME)[_MAJOR_VERSION], [my_MAJOR_VERSION],
     69AC_DEFINE(my_PACKAGE_CPP[_MAJOR_VERSION], [my_MAJOR_VERSION],
    6070                    [Define to major version])
    61 AC_DEFINE(m4_toupper(AC_PACKAGE_NAME)[_MINOR_VERSION], [my_MINOR_VERSION],
     71AC_DEFINE(my_PACKAGE_CPP[_MINOR_VERSION], [my_MINOR_VERSION],
    6272                    [Define to minor version])
    63 AC_DEFINE(m4_toupper(AC_PACKAGE_NAME)[_PATCH_VERSION], [my_PATCH_VERSION],
     73AC_DEFINE(my_PACKAGE_CPP[_PATCH_VERSION], [my_PATCH_VERSION],
    6474                    [Define to patch version])
     75m4_popdef([my_PACKAGE_CPP])
    6576]) # MY_VERSION
Note: See TracChangeset for help on using the changeset viewer.