Add files from parent branch HEAD:
[pkgsrc.git] / pkgtools / x11-links / xfree-version.mk
1 # $NetBSD: version.mk,v 1.2 2005/06/20 22:13:10 jlam Exp $
2 #
3 # This Makefile fragment is included by Makefiles that need to access
4 # the X11_TYPE and version number of a XFree86 distribution.
5 #
6 # The following variables are provided by this file:
7 #
8 #    BUILTIN_X11_TYPE.XFree86 is the X11_TYPE of the XFree86 distribution
9 #       and is simply "XFree86".
10 #
11 #    BUILTIN_X11_VERSION.XFree86 is the version number of the XFree86
12 #       distribution detected on the system.
13 #
14
15 BUILTIN_X11_TYPE.XFree86=       XFree86
16
17 BUILTIN_FIND_FILES_VAR:=                CF_XFREE86 CF_XFREE86_VERSION
18 BUILTIN_FIND_FILES.CF_XFREE86=          ${X11BASE}/lib/X11/config/xfree86.cf
19 BUILTIN_FIND_FILES.CF_XFREE86_VERSION=  ${X11BASE}/lib/X11/config/version.def
20 .include "../../mk/buildlink3/find-files.mk"
21
22 .if !defined(BUILTIN_X11_VERSION.XFree86) && \
23     exists(${CF_XFREE86}) && exists(${CF_XFREE86_VERSION})
24 BUILTIN_X11_VERSION.XFree86!=                                           \
25         ${AWK} '/\#define[      ]*XF86_VERSION_MAJOR/ { M = $$3 }       \
26                 /\#define[      ]*XF86_VERSION_MINOR/ { m = "."$$3 }    \
27                 /\#define[      ]*XF86_VERSION_PATCH/ { p = "."$$3 }    \
28                 /\#define[      ]*XF86_VERSION_SNAP/ { s = "."$$3 }     \
29                 /\#define[      ]*XFree86Version/ {                     \
30                         V = $$3;                                        \
31                         if (M == "") M = int(V / 1000) % 10;            \
32                         if (m == "") m = "."(int(V / 100) % 10);        \
33                         if (p == "") p = "."(int(V / 10) % 10);         \
34                         if (s == "") s = "."(V % 10);                   \
35                 }                                                       \
36                 END { if (s == ".0") s = "";                            \
37                       if (p == ".0" && s == "") p = "";                 \
38                       printf "%s%s%s%s\n", M, m, p, s }'                \
39                 ${CF_XFREE86_VERSION}
40 .endif
41 MAKEVARS+=      BUILTIN_X11_VERSION.XFree86