source: branches/samba-3.5.x/source4/build/m4/public.m4

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 6.8 KB
Line 
1dnl SMB Build System
2dnl ----------------
3dnl Copyright (C) 2004 Stefan Metzmacher
4dnl Copyright (C) 2004-2005 Jelmer Vernooij
5dnl Published under the GPL
6dnl
7dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
8dnl
9dnl SMB_INCLUDED_LIB_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
10dnl
11dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
12dnl
13dnl SMB_ENABLE(name,default_build)
14dnl
15dnl SMB_INCLUDE_MK(file)
16dnl
17dnl SMB_WRITE_MAKEVARS(file)
18dnl
19dnl SMB_WRITE_PERLVARS(file)
20dnl
21dnl #######################################################
22dnl ### And now the implementation ###
23dnl #######################################################
24
25dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems,cflags)
26AC_DEFUN([SMB_SUBSYSTEM],
27[
28MAKE_SETTINGS="$MAKE_SETTINGS
29$1_CFLAGS = $4
30$1_ENABLE = YES
31$1_OBJ_FILES = $2
32"
33
34SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
35###################################
36# Start Subsystem $1
37@<:@SUBSYSTEM::$1@:>@
38PRIVATE_DEPENDENCIES = $3
39CFLAGS = \$($1_CFLAGS)
40ENABLE = YES
41# End Subsystem $1
42###################################
43"
44])
45
46dnl SMB_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags)
47AC_DEFUN([SMB_LIBRARY],
48[
49MAKE_SETTINGS="$MAKE_SETTINGS
50$1_CFLAGS = $6
51$1_LDFLAGS = $7
52n1_ENABLE = YES
53$1_OBJ_FILES = $2
54"
55
56SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES
57###################################
58# Start Library $1
59@<:@LIBRARY::$1@:>@
60PRIVATE_DEPENDENCIES = $3
61CFLAGS = \$($1_CFLAGS)
62LDFLAGS = \$($1_LDFLAGS)
63ENABLE = YES
64# End Library $1
65###################################
66"
67])
68
69dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
70AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
71[
72 dnl Figure out the correct variables and call SMB_EXT_LIB()
73
74 if test -z "$PKG_CONFIG"; then
75 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
76 fi
77
78 if test "$PKG_CONFIG" = "no" ; then
79 echo "*** The pkg-config script could not be found. Make sure it is"
80 echo "*** in your path, or set the PKG_CONFIG environment variable"
81 echo "*** to the full path to pkg-config."
82 echo "*** Or see http://pkg-config.freedesktop.org/ to get pkg-config."
83 ac_cv_$1_found=no
84 else
85 SAMBA_PKG_CONFIG_MIN_VERSION="0.9.0"
86 if $PKG_CONFIG --atleast-pkgconfig-version $SAMBA_PKG_CONFIG_MIN_VERSION; then
87 AC_MSG_CHECKING(for $2)
88
89 if $PKG_CONFIG --exists '$2' ; then
90 AC_MSG_RESULT(yes)
91
92 $1_CFLAGS="`$PKG_CONFIG --cflags '$2'`"
93 OLD_CFLAGS="$CFLAGS"
94 CFLAGS="$CFLAGS $$1_CFLAGS"
95 AC_MSG_CHECKING([that the C compiler can use the $1_CFLAGS])
96 AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
97 SMB_ENABLE($1, YES)
98 AC_MSG_RESULT(yes),
99 AC_MSG_RESULT(no),
100 AC_MSG_WARN([cannot run when cross-compiling]))
101 CFLAGS="$OLD_CFLAGS"
102
103 ac_cv_$1_libs_only_other="`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`"
104 LIB_REMOVE_USR_LIB(ac_cv_$1_libs_only_other)
105 ac_cv_$1_includedir_only="`$PKG_CONFIG --cflags-only-I '$2'`"
106 CFLAGS_REMOVE_USR_INCLUDE(ac_cv_$1_includedir_only)
107 SMB_EXT_LIB($1,
108 [`$PKG_CONFIG --libs-only-l '$2'`],
109 [`$PKG_CONFIG --cflags-only-other '$2'`],
110 [$ac_cv_$1_includedir_only],
111 [$ac_cv_$1_libs_only_other])
112 ac_cv_$1_found=yes
113
114 else
115 AC_MSG_RESULT(no)
116 $PKG_CONFIG --errors-to-stdout --print-errors '$2'
117 ac_cv_$1_found=no
118 fi
119 else
120 echo "*** Your version of pkg-config is too old. You need version $SAMBA_PKG_CONFIG_MIN_VERSION or newer."
121 echo "*** See http://pkg-config.freedesktop.org/"
122 ac_cv_$1_found=no
123 fi
124 fi
125 if test x$ac_cv_$1_found = x"yes"; then
126 ifelse([$3], [], [echo -n ""], [$3])
127 else
128 ifelse([$4], [], [
129 SMB_EXT_LIB($1)
130 SMB_ENABLE($1, NO)
131 ], [$4])
132 fi
133])
134
135dnl SMB_INCLUDED_LIB_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
136AC_DEFUN([SMB_INCLUDED_LIB_PKGCONFIG],
137[
138 AC_ARG_ENABLE([external-]translit($1,`A-Z',`a-z'),
139 AS_HELP_STRING([--enable-external-]translit($1,`A-Z',`a-z'), [Use external $1 instead of built-in (default=ifelse([$5],[],auto,$5))]), [], [enableval=ifelse([$5],[],auto,$5)])
140
141 if test $enableval = yes -o $enableval = auto; then
142 SMB_EXT_LIB_FROM_PKGCONFIG([$1], [$2], [$3], [
143 if test $enableval = yes; then
144 AC_MSG_ERROR([Unable to find external $1])
145 fi
146 enableval=no
147 ])
148 fi
149 if test $enableval = no; then
150 ifelse([$4], [], [
151 SMB_EXT_LIB($1)
152 SMB_ENABLE($1, NO)
153 ], [$4])
154 fi
155])
156
157dnl SMB_INCLUDE_MK(file)
158AC_DEFUN([SMB_INCLUDE_MK],
159[
160SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
161mkinclude $1
162"
163])
164
165dnl
166dnl SMB_EXT_LIB() just specifies the details of the library.
167dnl Note: the library isn't enabled by default.
168dnl You need to enable it with SMB_ENABLE(name) if configure
169dnl find it should be used. E.g. it should not be enabled
170dnl if the library is present, but the header file is missing.
171dnl
172dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
173AC_DEFUN([SMB_EXT_LIB],
174[
175MAKE_SETTINGS="$MAKE_SETTINGS
176$1_LIBS = $2
177$1_CFLAGS = $3
178$1_CPPFLAGS = $4
179$1_LDFLAGS = $5
180"
181
182])
183
184dnl SMB_ENABLE(name,default_build)
185AC_DEFUN([SMB_ENABLE],
186[
187 MAKE_SETTINGS="$MAKE_SETTINGS
188$1_ENABLE = $2
189"
190SMB_INFO_ENABLES="$SMB_INFO_ENABLES
191\$enabled{\"$1\"} = \"$2\";"
192])
193
194dnl SMB_MAKE_SETTINGS(text)
195AC_DEFUN([SMB_MAKE_SETTINGS],
196[
197MAKE_SETTINGS="$MAKE_SETTINGS
198$1
199"
200])
201
202dnl SMB_WRITE_MAKEVARS(path, skip_vars)
203AC_DEFUN([SMB_WRITE_MAKEVARS],
204[
205echo "configure: creating $1"
206cat >$1<<CEOF
207# $1 - Autogenerated by configure, DO NOT EDIT!
208$MAKE_SETTINGS
209CEOF
210skip_vars=" $2 "
211for ac_var in $ac_subst_vars
212do
213 eval ac_val=\$$ac_var
214 if echo "$skip_vars" | grep -v " $ac_var " >/dev/null 2>/dev/null; then
215 echo "$ac_var = $ac_val" >> $1
216 fi
217done
218])
219
220dnl SMB_WRITE_PERLVARS(path)
221AC_DEFUN([SMB_WRITE_PERLVARS],
222[
223echo "configure: creating $1"
224cat >$1<<CEOF
225# config.pm - Autogenerate by configure. DO NOT EDIT!
226
227package config;
228require Exporter;
229@ISA = qw(Exporter);
230@EXPORT_OK = qw(%enabled %config);
231use strict;
232
233use vars qw(%enabled %config);
234
235%config = (
236CEOF
237
238for ac_var in $ac_subst_vars
239do
240 eval ac_val=\$$ac_var
241 # quote ' (\x27) inside '...' and make sure \ isn't eaten by shells, so use perl:
242 QAC_VAL=$ac_val QAC_VAR=$ac_var perl -e '$myval="$ENV{QAC_VAL}"; $myval =~ s/\x27/\\\x27/g ; print $ENV{QAC_VAR}." => \x27$myval\x27,\n"' >> $1
243done
244
245cat >>$1<<CEOF
246);
247$SMB_INFO_ENABLES
2481;
249CEOF
250])
251
252dnl SMB_BUILD_RUN(OUTPUT_FILE)
253AC_DEFUN([SMB_BUILD_RUN],
254[
255AC_OUTPUT_COMMANDS(
256[
257test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && (
258 cd $builddir;
259 # NOTE: We *must* use -R so we don't follow symlinks (at least on BSD
260 # systems).
261 test -d heimdal || cp -R $srcdir/heimdal $builddir/
262 test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/
263 test -d build || builddir="$builddir" \
264 srcdir="$srcdir" \
265 $PERL ${srcdir}/script/buildtree.pl
266 )
267
268$PERL -I${builddir} -I${builddir}/build \
269 -I${srcdir} -I${srcdir}/build \
270 ${srcdir}/build/smb_build/main.pl --output=$1 main.mk || exit $?
271],
272[
273srcdir="$srcdir"
274builddir="$builddir"
275PERL="$PERL"
276
277export PERL
278export srcdir
279export builddir
280])
281])
Note: See TracBrowser for help on using the repository browser.