UserExtensions: bakefile-presets.m4

File bakefile-presets.m4, 5.4 KB (added by Vaclav Slavik, 4 years ago)
Line 
1dnl ---------------------------------------------------------------------------
2dnl Support macros for makefiles generated with Bakefile presets
3dnl ---------------------------------------------------------------------------
4
5
6dnl ---------------------------------------------------------------------------
7dnl AM_YESNO_OPTCHECK([name of the boolean variable to set],
8dnl                   [name of the variable with yes/no values],
9dnl                   [name of the --enable/--with option])
10dnl
11dnl Converts the $3 variable, supposed to contain a yes/no value to a 1/0
12dnl boolean variable and saves the result into $1.
13dnl Outputs also the standard checking-option message.
14dnl Used by the m4 macros of the presets.
15dnl ---------------------------------------------------------------------------
16AC_DEFUN([AC_BAKEFILE_YESNO_OPTCHECK],
17[
18    AC_MSG_CHECKING([for the $3 option])
19    if [[ "x$$2" = "xyes" ]]; then
20        AC_MSG_RESULT([yes])
21        $1=1
22    else
23        AC_MSG_RESULT([no])
24        $1=0
25    fi
26])
27
28dnl ---------------------------------------------------------------------------
29dnl AC_BAKEFILE_UNICODEOPT([default value for the --enable-unicode option])
30dnl
31dnl Adds the --enable-unicode option to the configure script and sets the
32dnl UNICODE=0/1 variable accordingly to the value of the option.
33dnl To be used with unicodeopt.bkl preset.
34dnl ---------------------------------------------------------------------------
35AC_DEFUN([AC_BAKEFILE_UNICODEOPT],
36[
37    default="$1"
38    if [[ -z "$default" ]]; then
39        default="no"
40    fi
41
42    AC_ARG_ENABLE([unicode],
43            AC_HELP_STRING([--enable-unicode], [Builds in Unicode mode]),
44            [], [enableval="$default"])
45
46    AC_BAKEFILE_YESNO_OPTCHECK([UNICODE], [enableval], [--enable-unicode])
47])
48
49dnl ---------------------------------------------------------------------------
50dnl AC_BAKEFILE_DEBUGOPT([default value for the --enable-debug option])
51dnl
52dnl Adds the --enable-debug option to the configure script and sets the
53dnl DEBUG=0/1 variable accordingly to the value of the option.
54dnl To be used with debugopt.bkl preset.
55dnl ---------------------------------------------------------------------------
56AC_DEFUN([AC_BAKEFILE_DEBUGOPT],
57[
58    default="$1"
59    if [[ -z "$default" ]]; then
60        default="no"
61    fi
62
63    AC_ARG_ENABLE([debug],
64            AC_HELP_STRING([--enable-debug], [Builds in debug mode]),
65            [], [enableval="$default"])
66
67    AC_BAKEFILE_YESNO_OPTCHECK([DEBUG], [enableval], [--enable-debug])
68
69    dnl add the optimize/debug flags
70    if [[ "x$DEBUG" = "x1" ]]; then
71
72        dnl NOTE: the -Wundef and -Wno-ctor-dtor-privacy are not enabled automatically by -Wall
73        dnl NOTE2: the '-Wno-ctor-dtor-privacy' has sense only when compiling C++ source files
74        dnl        and thus we must be careful to add it only to CXXFLAGS and not to CFLAGS
75        dnl        (remember that CPPFLAGS is reserved for both C and C++ compilers while
76        dnl         CFLAGS is intended as flags for C compiler only and CXXFLAGS for C++ only)
77        CXXFLAGS="$CXXFLAGS -g -O0 -Wall -Wundef -Wno-ctor-dtor-privacy"
78        CFLAGS="$CFLAGS -g -O0 -Wall -Wundef"
79    else
80        CXXFLAGS="$CXXFLAGS -O2"
81        CFLAGS="$CFLAGS -O2"
82    fi
83])
84
85dnl ---------------------------------------------------------------------------
86dnl AC_BAKEFILE_SHAREDOPT([default value for the --enable-shared option])
87dnl
88dnl Adds the --enable-shared option to the configure script and sets the
89dnl SHARED=0/1 variable accordingly to the value of the option.
90dnl To be used with sharedopt.bkl preset.
91dnl ---------------------------------------------------------------------------
92AC_DEFUN([AC_BAKEFILE_SHAREDOPT],
93[
94    default="$1"
95    if [[ -z "$default" ]]; then
96        default="no"
97    fi
98
99    AC_ARG_ENABLE([shared],
100            AC_HELP_STRING([--enable-shared], [Builds in shared mode]),
101            [], [enableval="$default"])
102
103    AC_BAKEFILE_YESNO_OPTCHECK([SHARED], [enableval], [--enable-shared])
104])
105
106dnl ---------------------------------------------------------------------------
107dnl AC_BAKEFILE_SHOW_DEBUGOPT
108dnl
109dnl Prints a message on stdout about the value of the DEBUG variable.
110dnl This macro is useful to show summary messages at the end of the configure scripts.
111dnl ---------------------------------------------------------------------------
112AC_DEFUN([AC_BAKEFILE_SHOW_DEBUGOPT],
113[
114    if [[ "$DEBUG" = "1" ]]; then
115        echo "  - DEBUG build"
116    else
117        echo "  - RELEASE build"
118    fi
119])
120
121dnl ---------------------------------------------------------------------------
122dnl AC_BAKEFILE_SHOW_SHAREDOPT
123dnl
124dnl Prints a message on stdout about the value of the SHARED variable.
125dnl This macro is useful to show summary messages at the end of the configure scripts.
126dnl ---------------------------------------------------------------------------
127AC_DEFUN([AC_BAKEFILE_SHOW_SHAREDOPT],
128[
129    if [[ "$SHARED" = "1" ]]; then
130        echo "  - SHARED mode"
131    else
132        echo "  - STATIC mode"
133    fi
134])
135
136dnl ---------------------------------------------------------------------------
137dnl AC_BAKEFILE_SHOW_UNICODEOPT
138dnl
139dnl Prints a message on stdout about the value of the UNICODE variable.
140dnl This macro is useful to show summary messages at the end of the configure scripts.
141dnl ---------------------------------------------------------------------------
142AC_DEFUN([AC_BAKEFILE_SHOW_UNICODEOPT],
143[
144    if [[ "$UNICODE" = "1" ]]; then
145        echo "  - UNICODE mode"
146    else
147        echo "  - ANSI mode"
148    fi
149])
150
151