Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[cascardo/ovs.git] / m4 / nx-build.m4
1 # -*- autoconf -*-
2
3 # Copyright (c) 2008 Nicira Networks.
4 #
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17 dnl NX_BUILDNR
18 dnl
19 dnl If --with-build-number=NUMBER is used, substitutes a Makefile
20 dnl variable BUILDNR with NUMBER, and sets a C preprocessor variable
21 dnl BUILDNR to "+buildNUMBER".
22 dnl
23 dnl Otherwise, if --with-build-number is not used, substitutes BUILDNR
24 dnl with 0 and sets C preprocessor variable BUILDNR to "".
25 AC_DEFUN([NX_BUILDNR],
26   [AC_ARG_WITH(
27      [build-number],
28      [AS_HELP_STRING([--with-build-number=NUMBER],
29                      [Official build number (default is none)])])
30    AC_MSG_CHECKING([build number])
31    case $with_build_number in # (
32      [[0-9]] | \
33      [[0-9]][[0-9]] | \
34      [[0-9]][[0-9]][[0-9]] | \
35      [[0-9]][[0-9]][[0-9]][[0-9]] | \
36      [[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
37        BUILDNR=$with_build_number
38        buildnr='"+build'$BUILDNR'"'
39        AC_MSG_RESULT([$with_build_number])
40        ;; # (
41      ''|no)
42        BUILDNR=0
43        buildnr='""'
44        AC_MSG_RESULT([none])
45        ;; # (
46      *)
47        AC_MSG_ERROR([invalid build number $with_build_number])
48        ;;
49    esac
50    AC_SUBST([BUILDNR])
51    AC_DEFINE_UNQUOTED([BUILDNR], [$buildnr],
52      [Official build number as a VERSION suffix string, e.g. "+build123",
53       or "" if this is not an official build.])])