File: wxcodecheck.m4

package info (click to toggle)
wxsqlite3 3.4.1~dfsg-9.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,008 kB
  • sloc: cpp: 7,915; sh: 5,507; makefile: 367; ansic: 229; php: 9
file content (172 lines) | stat: -rw-r--r-- 7,772 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
dnl ---------------------------------------------------------------------------
dnl Author:          Francesco Montorsi
dnl Creation date:   14/9/2005
dnl RCS-ID:          $Id$
dnl Purpose:         Contains M4 macros intended to be used also by external
dnl                  projects which depends from a wxCode component
dnl ---------------------------------------------------------------------------


dnl ---------------------------------------------------------------------------
dnl WXCODE_SAVE_COREVAR()
dnl
dnl Saves the CPPFLAGS, CXXFLAGS, CFLAGS and LIBS variables in some helper
dnl variables which are used to restore them later (see AM_RESTORE_COREVAR)
dnl ---------------------------------------------------------------------------
AC_DEFUN([WXCODE_SAVE_COREVAR],
        [
        SAVED_CPPFLAGS="$CPPFLAGS"
        SAVED_CXXFLAGS="$CXXFLAGS"
        SAVED_CFLAGS="$CFLAGS"
        SAVED_LIBS="$LIBS"
    ])


dnl ---------------------------------------------------------------------------
dnl WXCODE_RESTORE_COREVAR()
dnl
dnl Loads into the CPPFLAGS, CXXFLAGS, CFLAGS and LIBS variables the values
dnl of the helper variables set by AM_SAVE_COREVAR
dnl ---------------------------------------------------------------------------
AC_DEFUN([WXCODE_RESTORE_COREVAR],
        [
        CPPFLAGS="$SAVED_CPPFLAGS"
        CXXFLAGS="$SAVED_CXXFLAGS"
        CFLAGS="$SAVED_CFLAGS"
        LIBS="$SAVED_LIBS"
    ])



dnl ---------------------------------------------------------------------------
dnl WXCODE_CHECKFOR_COMPONENT(
dnl         [name (mixed case) of the component to check],
dnl         [name of a header of the component to check (with 'wx/' prefix and '.h' suffix)],
dnl         [name of the library of the component to check (without 'lib' prefix and without .a/.so suffix)],
dnl         [a C++ line of code that forces the test program to be linked against the component in order to work],
dnl         [action if found],
dnl         [action if not found])
dnl
dnl Creates a little test program to check for presence of a wxCode component.
dnl Note that this macro does not automatically adds anything to the CPPFLAGS,
dnl CFLAGS or LIBS variables.
dnl ---------------------------------------------------------------------------
AC_DEFUN([WXCODE_CHECKFOR_COMPONENT],
        [
            dnl save original flags into support variables
            WXCODE_SAVE_COREVAR()

            dnl add to the compilation & link flags the wxWidgets flags
            dnl (we assume they have been set by AM_WXPRESETS)
            dnl
            dnl NOTE: this is very important since the test program
            dnl       we will compile needs to be linked against wx
            dnl       and the configure script will use these *FLAGS
            dnl       variables and it cannot be told to use other flags.
            dnl
            dnl NOTE2: we don't want to put into *FLAGS variables the
            dnl        WX_* variable values since the Makefile.in for
            dnl        a wxpresets-based application already merges
            dnl        the *FLAGS contents with WX_* vars
            dnl
            dnl NOTE3: the CXXFLAGS are merged with CPPFLAGS and
            dnl        thus we don't need to add the WX_CPPFLAGS to both
            CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
            CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"

            dnl before WX_LIBS we want the lib of the component to check
            LIBS="$LIBS -l$3 $WX_LIBS"

            dnl check for this component presence
            if test -z "$COMPCHECK_MSG"; then
                dnl allow customized messages
                COMPCHECK_MSG="if $1 is available"
            fi
            AC_MSG_CHECKING([$COMPCHECK_MSG])
            AC_LINK_IFELSE([
                            AC_LANG_PROGRAM([#include <$2>],
                                            [$4])
                           ],
                            [$1_PRESENCE=1], [$1_PRESENCE=0])

            if test "$$1_PRESENCE" = "1"; then
               AC_MSG_RESULT([yes])
               $5
            else
               AC_MSG_RESULT([no])
               $6
            fi

            dnl restore the original flags
            WXCODE_RESTORE_COREVAR()
        ])


dnl ---------------------------------------------------------------------------
dnl WXCODE_CHECKFOR_COMPONENT_VERSION(
dnl         [name (mixed case) of the component to check],
dnl         [name of a header of the component to check (with 'wx/' prefix and '.h' suffix)],
dnl         [name of the library of the component to check (without 'lib' prefix and without .a/.so suffix)],
dnl         [a C++ line of code that forces the test program to be linked against the component in order to work],
dnl    *    [major-version.minor-version],
dnl    *    [versionsym-prefix],
dnl    *    [versionsym-postfix],
dnl         [action if found],
dnl         [action if not found])
dnl
dnl Like AM_WXCODE_CHECKFOR_COMPONENT (the only new arguments it takes are marked
dnl with *) but also includes a version check against the component to check for.
dnl Note that the given version MUST be composed of three digits separed by a dot,
dnl i.e. a string in form "1.2.3" which will be checked against the string
dnl
dnl     [versionsym-prefix]MAJOR[versionsym-postfix].\
dnl           [versionsym-prefix]MINOR[versionsym-postfix].\
dnl               [versionsym-prefix]RELEASE[versionsym-postfix]
dnl
dnl where *MAJOR*, *MINOR* and *RELEASE* are three symbols which should have
dnl been #defined in the compdef.h header file (see template/include/wx/mycompdef.h).
dnl ---------------------------------------------------------------------------
AC_DEFUN([WXCODE_CHECKFOR_COMPONENT_VERSION],
        [
            dnl break version string in single digits
            major=`echo $5 | sed 's/\([[0-9]]\).\([[0-9]]\).\([[0-9]]\)/\1/'`
            minor=`echo $5 | sed 's/\([[0-9]]\).\([[0-9]]\).\([[0-9]]\)/\2/'`
            release=`echo $5 | sed 's/\([[0-9]]\).\([[0-9]]\).\([[0-9]]\)/\3/'`

            dnl cache the symbol names
            majsym="$6""MAJOR""$7"
            minsym="$6""MINOR""$7"
            relsym="$6""RELEASE""$7"

            dnl call our base macro adding the version check
            COMPCHECK_MSG="if $1 (version >= $5) is available"
            WXCODE_CHECKFOR_COMPONENT([$1], [$2], [$3],
                [
                    $4

                    // version check
                    #if defined($majsym) && defined($minsym) && defined($relsym)
                        #if ($majsym > ($major) || \
                            ($majsym == ($major) && $minsym > ($minor)) || \
                            ($majsym == ($major) && $minsym == ($minor) && $relsym >= ($release)))
                            // this component is recent enough
                        #else
                            #error $1 is too old ! At least version $5 is required
                        #endif
                    #else
                        #error $1 does not define its version symbols $majsym, $minsym, $relsym
                    #endif
                ],
                [$8], [$9])
        ])


dnl ---------------------------------------------------------------------------
dnl Deprecated macro wrappers
dnl ---------------------------------------------------------------------------

AC_DEFUN([AM_SAVE_COREVAR], [WXCODE_SAVE_COREVAR])
AC_DEFUN([AM_RESTORE_COREVAR], [WXCODE_RESTORE_COREVAR])
AC_DEFUN([AM_WXCODE_CHECKFOR_COMPONENT], [WXCODE_CHECKFOR_COMPONENT])
AC_DEFUN([AM_WXCODE_CHECKFOR_COMPONENT_VERSION], [WXCODE_CHECKFOR_COMPONENT_VERSION])