new beta-0.90.0
[luatex.git] / source / libs / cairo / cairo-src / build / aclocal.makefile.m4
blob70777810d14d1a36aa51a873b80eff8c6e6e91b7
1 dnl
2 dnl These are the facilities for generating Makefile.am.features and
3 dnl Makefile.win32.features files.
4 dnl
6 dnl ===========================================================================
8 dnl
9 dnl Define cr_feature_tag ala other cr_feature_* macros
10 dnl Expands to CAIRO_HAS_FEATURE_ID
11 dnl
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 ===========================================================================
21 dnl
22 dnl CAIRO_INIT_MAKEFILES([AUX-DIR])
23 dnl
24 dnl Sets up automake and win32 conditionals for all features
25 dnl
26 AC_DEFUN([CAIRO_INIT_MAKEFILES],
27 [dnl
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,*,
33         [dnl
34                 AM_CONDITIONAL(cr_feature_tag, [test "x$use_]cr_feature[" = xyes])dnl
35         ])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
39 ])dnl
41 dnl ===========================================================================
43 m4_define([_CAIRO_MAKEFILES])dnl
45 dnl
46 dnl CAIRO_CONFIG_MAKEFILE(TAG, DIR, [SUFFIX], [HEADER])
47 dnl
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
50 dnl Makefile's.
51 dnl
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
54 dnl is added.
55 dnl
56 AC_DEFUN([CAIRO_CONFIG_MAKEFILE],
57 [dnl
58         m4_append_uniq([_CAIRO_MAKEFILES], [$1], [ ])dnl
59         CAIRO_CONFIG_MAKEFILE_PRIVATE([$1], [$2], [$3], [$4])dnl
60 ])dnl
62 dnl Like CAIRO_CONFIG_MAKEFILE but only generate win32 makefile
63 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_WIN32],
64 [dnl
65         m4_append_uniq([_CAIRO_MAKEFILES], [$1], [ ])dnl
66         CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32([$1], [$2], [$3], [$4])dnl
67 ])dnl
69 dnl Like CAIRO_CONFIG_MAKEFILE but only generate automake makefile
70 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_AMAKE],
71 [dnl
72         m4_append_uniq([_CAIRO_MAKEFILES], [$1], [ ])dnl
73         CAIRO_CONFIG_MAKEFILE_PRIVATE_AMAKE([$1], [$2], [$3], [$4])dnl
74 ])dnl
76 dnl
77 dnl CAIRO_CONFIG_MAKEFILE_PRIVATE(TAG, DIR, [SUFFIX], [HEADER])
78 dnl
79 dnl Like CAIRO_CONFIG_MAKEFILE but this makefile tag won't match
80 dnl against '*' in makefile accumulators.
81 dnl
82 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_PRIVATE],
83 [dnl
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
90 ])dnl
92 dnl Like CAIRO_CONFIG_MAKEFILE_PRIVATE but only generate automake makefile
93 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_PRIVATE_AMAKE],
94 [dnl
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
100         dnl Accumulators
101         CAIRO_ACCUMULATORS_REGISTER(MAKEFILE_$1_AMAKE, m4_newline, m4_default([$4],[[# Generated by configure.  Do not edit.]])m4_newline)dnl
103         dnl Generate
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
107 ])dnl
109 dnl Like CAIRO_CONFIG_MAKEFILE_PRIVATE but only generate win32 makefile
110 AC_DEFUN([CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32],
111 [dnl
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
117         dnl Accumulators
118         CAIRO_ACCUMULATORS_REGISTER(MAKEFILE_$1_WIN32, m4_newline, m4_default([$4],[[# Generated by configure.  Do not edit.]])m4_newline)dnl
120         dnl Generate
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
124 ])dnl
127 m4_define([_CAIRO_MAKEFILE_CHECK],
128 [dnl
129         m4_ifdef([cr_make_$1_dir_any],,[m4_fatal([Makefile `]$1[' not defined.])])dnl
130 ])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
138 dnl all Makefile's.
140 AC_DEFUN([CAIRO_MAKEFILE_INCLUDE],
141 [dnl
142         m4_if([$1],[*],,[_CAIRO_MAKEFILE_CHECK([$1])])dnl
143         m4_foreach_w([cr_makefile], m4_if([$1],[*],_CAIRO_MAKEFILES,[$1]),
144         [dnl
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)]
147                 )dnl
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)]
150                 )dnl
151         ])dnl
152 ])dnl
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],
164 [dnl
165         m4_if([$1],[*],,[_CAIRO_MAKEFILE_CHECK([$1])])dnl
166         m4_foreach_w([cr_makefile], m4_if([$1],[*],_CAIRO_MAKEFILES,[$1]),
167         [dnl
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])]
173                 )dnl
174                 m4_ifdef([cr_make_]cr_makefile[_dir_win32],dnl
175                          [CAIRO_ACCUMULATE_UNQUOTED_UNCHECKED([MAKEFILE_]cr_makefile[_WIN32], [$cr_make_tmp])]
176                 )dnl
177         ])dnl
178 ])dnl
180 m4_define([_CAIRO_MAKEFILE_ACCUMULATE_FEATURE],
181 [dnl
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,
185                 [*],,
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,
191                 [*],,
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
196 ])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],
207 [dnl
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],
212         [dnl
213                 m4_foreach_w([cr_makefile], m4_if([$1],[*],_CAIRO_MAKEFILES,[$1]),
214                 [dnl
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],
219                                 [$2],
220                                 [if ]cr_feature_tag, [else], [endif],
221                                 [$cr_make_tmp])
222                         ])dnl
223                         m4_ifdef([cr_make_]cr_makefile[_dir_win32],
224                         [_CAIRO_MAKEFILE_ACCUMULATE_FEATURE(
225                                 [MAKEFILE_]cr_makefile[_WIN32],
226                                 [$2],
227                                 [ifeq ($(]cr_feature_tag[),1)], [else], [endif],
228                                 [$cr_make_tmp])dnl
229                         ])dnl
230                 ])dnl
231         ])dnl
232 ])dnl
234 m4_define([cr_make_acc_counter])dnl