summaryrefslogtreecommitdiff
path: root/source4/build/smb_build/public.m4
blob: 12238bbcc8279eb43bad05d6811ad1e63d9eea71 (plain)
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
dnl SMB Build System
dnl ----------------
dnl Copyright (C) 2004 Stefan Metzmacher
dnl Copyright (C) 2004 Jelmer Vernooij
dnl Published under the GPL
dnl
dnl SMB_MODULE_DEFAULT(
dnl		1:name,
dnl		2:default_build
dnl		)
dnl
dnl SMB_SUBSYSTEM_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
dnl
dnl SMB_SUBSYSTEM(
dnl		1:name,
dnl		2:init_obj_files,
dnl		3:add_obj_files,
dnl		4:required_libraries,
dnl		5:required_subsystems
dnl		)
dnl
dnl SMB_EXT_LIB_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
dnl
dnl SMB_EXT_LIB_FROM_PKGCONFIG(
dnl		1:name,
dnl		2:pkg-config name
dnl		)
dnl
dnl SMB_EXT_LIB(
dnl		1:name,
dnl		2:libs,
dnl		3:cflags,
dnl		4:cppflags,
dnl		5:ldflags
dnl		)
dnl
dnl SMB_LIBRARY_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
dnl
dnl SMB_BINARY_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
dnl
dnl SMB_MAKE_TARGET(
dnl		1:name
dnl		2:calledname
dnl		)
dnl
dnl SMB_INCLUDE_M4(
dnl		1: inputfile
dnl		2: comment
dnl		)
dnl
dnl SMB_ENV_CHECK(
dnl		1:dummy
dnl		)
dnl
dnl SMB_AC_OUTPUT(
dnl		1: outputfile
dnl		)

dnl #######################################################
dnl ### And now the implementation			###
dnl #######################################################

AC_DEFUN([STR2ARRAY], [@<:@ input::str2array(\"$1\") @:>@])


dnl SMB_MODULE_DEFAULT(
dnl		1:name,
dnl		2:default_build
dnl		)
AC_DEFUN([SMB_MODULE_DEFAULT],
[
	[SMB_MODULE_DEFAULT][$1]="$2"
SMB_INFO_MODULES="$SMB_INFO_MODULES
\$INPUT{$1}{DEFAULT_BUILD} = \"$2\";"
])

dnl SMB_SUBSYSTEM_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
AC_DEFUN([SMB_SUBSYSTEM_ENABLE],
[
	[SMB_SUBSYSTEM_ENABLE_][$1]="$2"
SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
\$INPUT{$1}{ENABLE} = \"$2\";"
])

dnl SMB_SUBSYSTEM(
dnl		1:name,
dnl		2:init_obj_files,
dnl		3:add_obj_files,
dnl		4:required_libs,
dnl		5:required_subsystems
dnl		)
AC_DEFUN([SMB_SUBSYSTEM],
[

	if test -z "$[SMB_SUBSYSTEM_ENABLE_][$1]"; then
		[SMB_SUBSYSTEM_ENABLE_][$1]="YES";
	fi

	if test -z "$[SMB_SUBSYSTEM_NOPROTO_][$1]"; then
		[SMB_SUBSYSTEM_NOPROTO_][$1]="NO";
	fi

SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
###################################
# Start Subsystem $1
\$INPUT{$1} = {
	TYPE => \"SUBSYSTEM\",
	NAME => \"$1\",
	INIT_OBJ_FILES => ][STR2ARRAY([$2])][,
	ADD_OBJ_FILES => ][STR2ARRAY([$3])][,
	REQUIRED_LIBRARIES => ][STR2ARRAY([$4])][,
	REQUIRED_SUBSYSTEMS => ][STR2ARRAY([$5])][,
	ENABLE => \"YES\"
};
# End Subsystem $1
###################################
"
])

dnl SMB_EXT_LIB_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
AC_DEFUN([SMB_EXT_LIB_ENABLE],
[
[SMB_EXT_LIB_ENABLE_][$1]="$2"
SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$INPUT{EXT_LIB_$1}{ENABLE} = \"$2\";"
])

dnl SMB_EXT_LIB_FROM_PKGCONFIG(
dnl		1:name,
dnl		2:pkg-config name
dnl )
AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG], 
[
	dnl Figure out the correct variables and call SMB_EXT_LIB()

	if test -z "$PKG_CONFIG"; then
		AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
	fi

	if test "$PKG_CONFIG" = "no" ; then
    		echo "*** The pkg-config script could not be found. Make sure it is"
    		echo "*** in your path, or set the PKG_CONFIG environment variable"
    		echo "*** to the full path to pkg-config."
    		echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
			SMB_EXT_LIB($1)
			SMB_EXT_LIB_ENABLE($1, NO)
	else
		if $PKG_CONFIG --atleast-pkgconfig-version 0.9.0; then
        		AC_MSG_CHECKING(for $2)

          		if test "$SMB_EXT_LIB_$1"x = "NO"x ; then
				SMB_EXT_LIB_ENABLE($1, NO)
				AC_MSG_RESULT(disabled)		
          		elif $PKG_CONFIG --exists '$2' ; then
            			AC_MSG_RESULT(yes)


				$1_CFLAGS="`$PKG_CONFIG --cflags '$2'`"
    			OLD_CFLAGS="$CFLAGS"
	    		CFLAGS="$CFLAGS $$1_CFLAGS"
		    	AC_MSG_CHECKING([that the C compiler can use the $1_CFLAGS])
    			AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
					SMB_EXT_LIB_ENABLE($1, YES)
			    	AC_MSG_RESULT(yes),
					AC_MSG_RESULT(no),
    				CFLAGS="$OLD_CFLAGS"
					AC_MSG_WARN([cannot run when cross-compiling]))


				SMB_EXT_LIB($1, 
					[`$PKG_CONFIG --libs-only-l '$2'`], 
					[`$PKG_CONFIG --cflags-only-other '$2'`],
					[`$PKG_CONFIG --cflags-only-I '$2'`],
					[`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])

        		else
				SMB_EXT_LIB($1)
				SMB_EXT_LIB_ENABLE($1, NO)
				AC_MSG_RESULT(no)
            			$PKG_CONFIG --errors-to-stdout --print-errors '$2'
        		fi
     		else
        		echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
        			echo "*** See http://www.freedesktop.org/software/pkgconfig"
				SMB_EXT_LIB($1)
				SMB_EXT_LIB_ENABLE($1, NO)
     		fi
  	fi
])

dnl SMB_EXT_LIB(
dnl		1:name,
dnl		2:libs,
dnl		3:cflags,
dnl		4:cppflags,
dnl		5:ldflags
dnl		)
AC_DEFUN([SMB_EXT_LIB],
[

SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
###################################
# Start Ext Lib $1
\$INPUT{EXT_LIB_$1} = {
	TYPE => \"EXT_LIB\",
	NAME => \"EXT_LIB_$1\",
	LIBS => ][STR2ARRAY([$2])][,
	CFLAGS => ][STR2ARRAY([$3])][,
	CPPFLAGS => ][STR2ARRAY([$4])][,
	LDFLAGS => ][STR2ARRAY([$5])][
};
# End Ext Lib $1
###################################
"
])


dnl SMB_LIBRARY_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
AC_DEFUN([SMB_LIBRARY_ENABLE],
[
SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$INPUT{$1}{ENABLE} = \"$2\";"
])

dnl SMB_BINARY_ENABLE(
dnl		1:name,
dnl		2:default_build
dnl		)
AC_DEFUN([SMB_BINARY_ENABLE],
[
	[SMB_BINARY_ENABLE_][$1]="$2";

SMB_INFO_BINARIES="$SMB_INFO_BINARIES
\$INPUT{$1}{ENABLE} = \"$2\";"
])

dnl SMB_MAKE_TARGET(
dnl		1:name
dnl		2:calledname
dnl		)
AC_DEFUN([SMB_MAKE_TARGET],
[
	echo "#SMB_MAKE_TARGET TOTO"
])

dnl SMB_INCLUDE_M4(
dnl		1: inputfile
dnl		2: comment
dnl		)
AC_DEFUN([SMB_INCLUDE_M4],
[
###################################
# Start Include $1
# $2
sinclude($1)
# End Include $1
###################################
])

dnl SMB_ENV_CHECK(
dnl		1:dummy
dnl		)
AC_DEFUN([SMB_ENV_CHECK],
[
	_SMB_BUILD_ENV($1)
])

dnl SMB_AC_OUTPUT(
dnl		1: outputfile
dnl		)
AC_DEFUN([SMB_AC_OUTPUT],
[
	AC_OUTPUT([$1],[],[_SMB_BUILD_CORE([[$1][.in]])])
])