2 dnl These are the facilities for generating Makefile.am.features and
3 dnl Makefile.win32.features files.
6 dnl ===========================================================================
9 dnl Define cr_feature_tag ala other cr_feature_* macros
10 dnl Expands to CAIRO_HAS_FEATURE_ID
12 m4_define([_CAIRO_BUILD_FEATURE_TAG_NORMALIZED],
13 [CAIRO_HAS_[$1]m4_bmatch([$1],[$2$],,[$2])])dnl
14 m4_define([_CAIRO_BUILD_FEATURE_TAG],
15 [_CAIRO_BUILD_FEATURE_TAG_NORMALIZED(AS_TR_CPP([$1]),AS_TR_CPP(m4_ifval([$2],[ $2])))])dnl
16 m4_define([cr_feature_tag],
17 [_CAIRO_BUILD_FEATURE_TAG(cr_feature,cr_feature_what)])dnl
20 dnl ===========================================================================
22 dnl CAIRO_INIT_MAKEFILES([AUX-DIR])
24 dnl Sets up automake and win32 conditionals for all features
26 AC_DEFUN([CAIRO_INIT_MAKEFILES],
28 dnl Allow feature tags in the output
29 m4_pattern_allow(^CAIRO_HAS_)dnl
31 dnl Automake conditionals for non-builtin features
32 CAIRO_FEATURE_HOOK_REGISTER(*,!always,*,
34 AM_CONDITIONAL(cr_feature_tag, [test "x$use_]cr_feature[" = xyes])dnl
37 CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32([_],[$1],[],[[# Generated by configure. Modify to customize.]])dnl
38 CAIRO_MAKEFILE_ACCUMULATE_FEATURE([_],*,!always,*,[cr_feature_tag=m4_if(cr_feature_default,[yes],1,[m4_bmatch(cr_feature,[win32],1,0)])])dnl
41 dnl ===========================================================================
43 m4_define([_CAIRO_MAKEFILES])dnl
46 dnl CAIRO_CONFIG_MAKEFILE(TAG, DIR, [SUFFIX], [HEADER])
48 dnl Create DIR/Makefile.{am,win32}.SUFFIX files
49 dnl TAG is a TAG used by other CAIRO_MAKEFILE_* macros to append to these
52 dnl HEADER is appended at the top of the Makefile's. If HEADER is not
53 dnl set, the generic "Generated by configure. Do not edit." comment
56 AC_DEFUN([CAIRO_CONFIG_MAKEFILE],
58 m4_append_uniq([_CAIRO_MAKEFILES], [$1], [ ])dnl
59 CAIRO_CONFIG_MAKEFILE_PRIVATE([$1], [$2], [$3], [$4])dnl
62 dnl Like CAIRO_CONFIG_MAKEFILE but only generate win32 makefile
63 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_WIN32],
65 m4_append_uniq([_CAIRO_MAKEFILES], [$1], [ ])dnl
66 CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32([$1], [$2], [$3], [$4])dnl
69 dnl Like CAIRO_CONFIG_MAKEFILE but only generate automake makefile
70 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_AMAKE],
72 m4_append_uniq([_CAIRO_MAKEFILES], [$1], [ ])dnl
73 CAIRO_CONFIG_MAKEFILE_PRIVATE_AMAKE([$1], [$2], [$3], [$4])dnl
77 dnl CAIRO_CONFIG_MAKEFILE_PRIVATE(TAG, DIR, [SUFFIX], [HEADER])
79 dnl Like CAIRO_CONFIG_MAKEFILE but this makefile tag won't match
80 dnl against '*' in makefile accumulators.
82 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_PRIVATE],
84 m4_ifdef([cr_make_$1_dir],
85 [m4_fatal([Makefile `$1' already registered])])dnl
86 m4_define([cr_make_$1_dir],[$2])dnl
88 CAIRO_CONFIG_MAKEFILE_PRIVATE_AMAKE([$1], [$2], [$3], [$4])dnl
89 CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32([$1], [$2], [$3], [$4])dnl
92 dnl Like CAIRO_CONFIG_MAKEFILE_PRIVATE but only generate automake makefile
93 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_PRIVATE_AMAKE],
95 m4_ifdef([cr_make_$1_dir_amake],
96 [m4_fatal([Automake makefile `$1' already registered])])dnl
97 m4_define([cr_make_$1_dir_amake],[$2])dnl
98 m4_define([cr_make_$1_dir_any],[$2])dnl
101 CAIRO_ACCUMULATORS_REGISTER(MAKEFILE_$1_AMAKE, m4_newline, m4_default([$4],[[# Generated by configure. Do not edit.]])m4_newline)dnl
104 CAIRO_CONFIG_COMMANDS([$srcdir/]m4_if([$2],[.],,[$2/])[Makefile.am.]m4_default([$3],[features]),
105 [echo "$CAIRO_MAKEFILE_$1_AMAKE"],
106 [CAIRO_MAKEFILE_$1_AMAKE='$CAIRO_MAKEFILE_$1_AMAKE'])dnl
109 dnl Like CAIRO_CONFIG_MAKEFILE_PRIVATE but only generate win32 makefile
110 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32],
112 m4_ifdef([cr_make_$1_dir_win32],
113 [m4_fatal([Win32 makefile `$1' already registered])])dnl
114 m4_define([cr_make_$1_dir_win32],[$2])dnl
115 m4_define([cr_make_$1_dir_any],[$2])dnl
118 CAIRO_ACCUMULATORS_REGISTER(MAKEFILE_$1_WIN32, m4_newline, m4_default([$4],[[# Generated by configure. Do not edit.]])m4_newline)dnl
121 CAIRO_CONFIG_COMMANDS([$srcdir/]m4_if([$2],[.],,[$2/])[Makefile.win32.]m4_default([$3],[features]),
122 [echo "$CAIRO_MAKEFILE_$1_WIN32"],
123 [CAIRO_MAKEFILE_$1_WIN32='$CAIRO_MAKEFILE_$1_WIN32'])dnl
127 m4_define([_CAIRO_MAKEFILE_CHECK],
129 m4_ifdef([cr_make_$1_dir_any],,[m4_fatal([Makefile `]$1[' not defined.])])dnl
134 dnl CAIRO_MAKEFILE_INCLUDE(TAG, FILE)
136 dnl Include FILE from Makefile's for TAG. FILE should be placed
137 dnl relative to directory for TAG. If TAG is *, FILE is included from
140 AC_DEFUN([CAIRO_MAKEFILE_INCLUDE],
142 m4_if([$1],[*],,[_CAIRO_MAKEFILE_CHECK([$1])])dnl
143 m4_foreach_w([cr_makefile], m4_if([$1],[*],_CAIRO_MAKEFILES,[$1]),
145 m4_ifdef([cr_make_]cr_makefile[_dir_amake],dnl
146 [CAIRO_ACCUMULATE([MAKEFILE_]cr_makefile[_AMAKE],[include $(top_srcdir)/cr_make_]cr_makefile[_dir_amake/$2]m4_newline)]
148 m4_ifdef([cr_make_]cr_makefile[_dir_win32],dnl
149 [CAIRO_ACCUMULATE([MAKEFILE_]cr_makefile[_WIN32],[ifeq ($(top_srcdir),)]m4_newline[include $2]m4_newline[else]m4_newline[include $(top_srcdir)/cr_make_]cr_makefile[_dir_win32/$2]m4_newline[endif]m4_newline)]
155 m4_pattern_allow([cr_make_tmp])
158 dnl CAIRO_MAKEFILE_ACCUMULATE(TAG, CONTENT)
160 dnl Accumulates CONTENT to Makefile's for TAG. If TAG is *,
161 dnl CONTENT is added to all Makefile's.
163 AC_DEFUN([CAIRO_MAKEFILE_ACCUMULATE],
165 m4_if([$1],[*],,[_CAIRO_MAKEFILE_CHECK([$1])])dnl
166 m4_foreach_w([cr_makefile], m4_if([$1],[*],_CAIRO_MAKEFILES,[$1]),
168 m4_pushdef([cr_make_acc_contents],[$2])dnl
169 cr_make_tmp=_CAIRO_SH_ESCAPE(cr_make_acc_contents(cr_makefile))
170 m4_popdef([cr_make_acc_contents])dnl
171 m4_ifdef([cr_make_]cr_makefile[_dir_amake],dnl
172 [CAIRO_ACCUMULATE_UNQUOTED_UNCHECKED([MAKEFILE_]cr_makefile[_AMAKE], [$cr_make_tmp])]
174 m4_ifdef([cr_make_]cr_makefile[_dir_win32],dnl
175 [CAIRO_ACCUMULATE_UNQUOTED_UNCHECKED([MAKEFILE_]cr_makefile[_WIN32], [$cr_make_tmp])]
180 m4_define([_CAIRO_MAKEFILE_ACCUMULATE_FEATURE],
182 dnl Don't do a conditional for default=always features
183 m4_pushdef([cr_mk_acc_feat_enabled],m4_if([$2],[yes],[m4_if(cr_feature_default,[always],[*],[$2])],[$2]))dnl
184 m4_case(cr_mk_acc_feat_enabled,
186 [yes], [CAIRO_ACCUMULATE([$1], [$3])],
187 [no], [CAIRO_ACCUMULATE([$1], [$3]m4_newline[$4])],
188 [m4_fatal([Invalid ENABLED value `]$2['])])dnl
189 CAIRO_ACCUMULATE_UNQUOTED_UNCHECKED([$1], [$6])dnl
190 m4_case(cr_mk_acc_feat_enabled,
192 [yes], [CAIRO_ACCUMULATE([$1], [$5])],
193 [no], [CAIRO_ACCUMULATE([$1], [$5])],
194 [m4_fatal([Invalid ENABLED value `]$2['])])dnl
195 m4_popdef([cr_mk_acc_feat_enabled])dnl
199 dnl CAIRO_MAKEFILE_ACCUMULATE_FEATURE(TAG, ENABLED, DEFAULT, WHAT, CONTENT)
201 dnl Accumulates CONTENT to Makefile's for TAG for each feature matching
202 dnl ENABLED, DEFAULT, and WHAT. Those parameters are similar to those
203 dnl passed to CAIRO_FEATURE_HOOK_REGISTER.
204 dnl If TAG is *, CONTENT is added to all Makefile's.
206 AC_DEFUN([CAIRO_MAKEFILE_ACCUMULATE_FEATURE],
208 m4_if([$1],[*],,[_CAIRO_MAKEFILE_CHECK([$1])])dnl
209 m4_append([cr_make_acc_counter],[1],[])dnl
210 m4_define([cr_make_acc_contents]m4_len(cr_make_acc_counter), [$5])dnl
211 CAIRO_FEATURE_HOOK_REGISTER(*,[$3],[$4],
213 m4_foreach_w([cr_makefile], m4_if([$1],[*],_CAIRO_MAKEFILES,[$1]),
215 cr_make_tmp=_CAIRO_SH_ESCAPE(cr_make_acc_contents]]m4_len(cr_make_acc_counter)([[cr_makefile,]][$][1],[$][2],[$][3],[$][4])[[)
216 m4_ifdef([cr_make_]cr_makefile[_dir_amake],
217 [_CAIRO_MAKEFILE_ACCUMULATE_FEATURE(
218 [MAKEFILE_]cr_makefile[_AMAKE],
220 [if ]cr_feature_tag, [else], [endif],
223 m4_ifdef([cr_make_]cr_makefile[_dir_win32],
224 [_CAIRO_MAKEFILE_ACCUMULATE_FEATURE(
225 [MAKEFILE_]cr_makefile[_WIN32],
227 [ifeq ($(]cr_feature_tag[),1)], [else], [endif],
234 m4_define([cr_make_acc_counter])dnl