2004-05-13 14:20:53 +04:00
dnl SMB Build System
dnl ----------------
2004-11-13 21:20:33 +03:00
dnl Copyright (C) 2004 Stefan Metzmacher
2005-07-28 15:51:37 +04:00
dnl Copyright (C) 2004-2005 Jelmer Vernooij
2004-11-13 21:20:33 +03:00
dnl Published under the GPL
2004-05-13 14:20:53 +04:00
dnl
2007-05-06 19:31:03 +04:00
dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
2004-05-13 19:37:57 +04:00
dnl
2009-02-21 20:21:20 +03:00
dnl SMB_INCLUDED_LIB_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
dnl
2008-02-18 21:46:27 +03:00
dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
2004-05-13 14:20:53 +04:00
dnl
2005-10-29 01:13:30 +04:00
dnl SMB_ENABLE(name,default_build)
2004-05-13 14:20:53 +04:00
dnl
2007-05-06 19:31:03 +04:00
dnl SMB_INCLUDE_MK(file)
dnl
2008-05-18 19:48:50 +04:00
dnl SMB_WRITE_MAKEVARS(file)
dnl
dnl SMB_WRITE_PERLVARS(file)
dnl
2004-05-13 14:20:53 +04:00
dnl #######################################################
dnl ### And now the implementation ###
dnl #######################################################
2006-05-13 23:57:09 +04:00
dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems,cflags)
2004-05-13 14:20:53 +04:00
AC_DEFUN([SMB_SUBSYSTEM],
[
2008-02-11 00:58:03 +03:00
MAKE_SETTINGS="$MAKE_SETTINGS
$1_CFLAGS = $4
2008-02-11 16:39:21 +03:00
$1_ENABLE = YES
2008-04-14 22:00:04 +04:00
$1_OBJ_FILES = $2
2008-02-11 00:58:03 +03:00
"
2004-05-13 14:20:53 +04:00
SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
###################################
# Start Subsystem $1
2005-07-28 15:51:37 +04:00
@<:@SUBSYSTEM::$1@:>@
2006-04-24 19:47:59 +04:00
PRIVATE_DEPENDENCIES = $3
2008-05-31 02:35:55 +04:00
CFLAGS = \$($1_CFLAGS)
2005-07-28 15:51:37 +04:00
ENABLE = YES
2004-05-13 14:20:53 +04:00
# End Subsystem $1
###################################
"
])
2010-03-09 12:44:41 +03:00
dnl SMB_BUILD_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags,realname)
2010-02-28 23:02:00 +03:00
AC_DEFUN([SMB_BUILD_LIBRARY],
2007-06-28 00:32:35 +04:00
[
2008-02-11 00:58:03 +03:00
MAKE_SETTINGS="$MAKE_SETTINGS
2010-02-28 23:02:00 +03:00
$1_CFLAGS = $4
$1_LDFLAGS = $5
2008-04-25 13:04:20 +04:00
n1_ENABLE = YES
2008-02-11 00:58:03 +03:00
$1_OBJ_FILES = $2
"
2007-06-28 00:32:35 +04:00
SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES
###################################
# Start Library $1
@<:@LIBRARY::$1@:>@
2008-01-22 20:49:51 +03:00
PRIVATE_DEPENDENCIES = $3
2008-02-11 21:28:59 +03:00
CFLAGS = \$($1_CFLAGS)
2008-02-11 01:32:31 +03:00
LDFLAGS = \$($1_LDFLAGS)
2007-06-28 00:32:35 +04:00
ENABLE = YES
2010-03-09 12:44:41 +03:00
ifelse([$6], [], [], [LIBRARY_REALNAME = $6])
2007-06-28 00:32:35 +04:00
# End Library $1
###################################
"
])
2007-05-06 19:31:03 +04:00
dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
2004-05-13 19:37:57 +04:00
AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
[
dnl Figure out the correct variables and call SMB_EXT_LIB()
2004-05-13 22:04:36 +04:00
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
2004-05-13 19:37:57 +04:00
2004-05-13 22:04:36 +04:00
if test "$PKG_CONFIG" = "no" ; then
2008-02-08 18:28:04 +03:00
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://pkg-config.freedesktop.org/ to get pkg-config."
2007-09-07 18:25:03 +04:00
ac_cv_$1_found=no
2004-05-13 19:37:57 +04:00
else
2009-03-17 10:58:04 +03:00
SAMBA_PKG_CONFIG_MIN_VERSION="0.9.0"
if $PKG_CONFIG --atleast-pkgconfig-version $SAMBA_PKG_CONFIG_MIN_VERSION; then
2008-02-08 18:28:04 +03:00
AC_MSG_CHECKING(for $2)
2004-05-13 19:37:57 +04:00
2008-02-08 18:28:04 +03:00
if $PKG_CONFIG --exists '$2' ; then
2007-09-07 18:25:03 +04:00
AC_MSG_RESULT(yes)
2004-05-13 19:37:57 +04:00
2005-02-18 02:11:26 +03:00
$1_CFLAGS="`$PKG_CONFIG --cflags '$2'`"
2008-02-08 18:28:04 +03:00
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $$1_CFLAGS"
AC_MSG_CHECKING([that the C compiler can use the $1_CFLAGS])
2009-01-22 13:35:28 +03:00
AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
2006-04-26 16:22:54 +04:00
SMB_ENABLE($1, YES)
2008-02-08 18:28:04 +03:00
AC_MSG_RESULT(yes),
2005-02-18 02:11:26 +03:00
AC_MSG_RESULT(no),
AC_MSG_WARN([cannot run when cross-compiling]))
2008-02-08 18:28:04 +03:00
CFLAGS="$OLD_CFLAGS"
2005-02-18 02:11:26 +03:00
2009-03-15 02:54:55 +03:00
ac_cv_$1_libs_only_other="`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`"
LIB_REMOVE_USR_LIB(ac_cv_$1_libs_only_other)
2009-03-15 20:10:20 +03:00
ac_cv_$1_includedir_only="`$PKG_CONFIG --cflags-only-I '$2'`"
CFLAGS_REMOVE_USR_INCLUDE(ac_cv_$1_includedir_only)
2004-05-13 22:04:36 +04:00
SMB_EXT_LIB($1,
2004-10-08 13:37:55 +04:00
[`$PKG_CONFIG --libs-only-l '$2'`],
[`$PKG_CONFIG --cflags-only-other '$2'`],
2009-03-15 20:10:20 +03:00
[$ac_cv_$1_includedir_only],
2009-03-15 02:54:55 +03:00
[$ac_cv_$1_libs_only_other])
2007-09-07 18:25:03 +04:00
ac_cv_$1_found=yes
2004-05-13 19:37:57 +04:00
2008-02-08 18:28:04 +03:00
else
2004-05-13 19:37:57 +04:00
AC_MSG_RESULT(no)
2008-02-08 18:28:04 +03:00
$PKG_CONFIG --errors-to-stdout --print-errors '$2'
2007-09-07 18:25:03 +04:00
ac_cv_$1_found=no
2008-02-08 18:28:04 +03:00
fi
else
2009-03-17 10:58:04 +03:00
echo "*** Your version of pkg-config is too old. You need version $SAMBA_PKG_CONFIG_MIN_VERSION or newer."
2008-02-08 18:28:04 +03:00
echo "*** See http://pkg-config.freedesktop.org/"
ac_cv_$1_found=no
fi
fi
2007-09-07 18:25:03 +04:00
if test x$ac_cv_$1_found = x"yes"; then
ifelse([$3], [], [echo -n ""], [$3])
else
ifelse([$4], [], [
SMB_EXT_LIB($1)
SMB_ENABLE($1, NO)
], [$4])
fi
2004-05-13 19:37:57 +04:00
])
2009-02-21 20:21:20 +03:00
dnl SMB_INCLUDED_LIB_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
AC_DEFUN([SMB_INCLUDED_LIB_PKGCONFIG],
[
AC_ARG_ENABLE([external-]translit($1,`A-Z',`a-z'),
2009-02-21 20:59:12 +03:00
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)])
2009-02-21 20:21:20 +03:00
if test $enableval = yes -o $enableval = auto; then
SMB_EXT_LIB_FROM_PKGCONFIG([$1], [$2], [$3], [
if test $enableval = yes; then
AC_MSG_ERROR([Unable to find external $1])
fi
2009-02-21 20:59:12 +03:00
enableval=no
2009-02-21 20:21:20 +03:00
])
2009-02-21 20:59:12 +03:00
fi
if test $enableval = no; then
2009-02-21 20:21:20 +03:00
ifelse([$4], [], [
SMB_EXT_LIB($1)
SMB_ENABLE($1, NO)
], [$4])
fi
])
2007-05-06 19:31:03 +04:00
dnl SMB_INCLUDE_MK(file)
AC_DEFUN([SMB_INCLUDE_MK],
[
SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
2008-02-18 22:04:18 +03:00
mkinclude $1
2007-05-06 19:31:03 +04:00
"
])
2009-02-25 10:42:33 +03:00
dnl
dnl SMB_EXT_LIB() just specifies the details of the library.
dnl Note: the library isn't enabled by default.
dnl You need to enable it with SMB_ENABLE(name) if configure
dnl find it should be used. E.g. it should not be enabled
dnl if the library is present, but the header file is missing.
dnl
2008-02-18 21:46:27 +03:00
dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
2004-05-13 14:20:53 +04:00
AC_DEFUN([SMB_EXT_LIB],
[
2008-02-11 00:58:03 +03:00
MAKE_SETTINGS="$MAKE_SETTINGS
$1_LIBS = $2
$1_CFLAGS = $3
$1_CPPFLAGS = $4
$1_LDFLAGS = $5
"
2004-05-13 14:20:53 +04:00
])
2005-10-29 01:13:30 +04:00
dnl SMB_ENABLE(name,default_build)
AC_DEFUN([SMB_ENABLE],
2004-05-13 14:20:53 +04:00
[
2008-02-11 16:39:21 +03:00
MAKE_SETTINGS="$MAKE_SETTINGS
$1_ENABLE = $2
"
2005-07-28 15:51:37 +04:00
SMB_INFO_ENABLES="$SMB_INFO_ENABLES
2009-06-03 01:07:59 +04:00
\$enabled{\"$1\"} = \"$2\";"
2004-05-13 14:20:53 +04:00
])
2008-05-18 19:48:50 +04:00
2009-01-04 19:57:40 +03:00
dnl SMB_MAKE_SETTINGS(text)
AC_DEFUN([SMB_MAKE_SETTINGS],
[
MAKE_SETTINGS="$MAKE_SETTINGS
$1
"
])
2008-09-03 16:10:35 +04:00
dnl SMB_WRITE_MAKEVARS(path, skip_vars)
2008-05-18 19:48:50 +04:00
AC_DEFUN([SMB_WRITE_MAKEVARS],
[
echo "configure: creating $1"
cat >$1<<CEOF
# $1 - Autogenerated by configure, DO NOT EDIT!
$MAKE_SETTINGS
CEOF
2008-09-03 16:10:35 +04:00
skip_vars=" $2 "
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
if echo "$skip_vars" | grep -v " $ac_var " >/dev/null 2>/dev/null; then
echo "$ac_var = $ac_val" >> $1
fi
done
2008-05-18 19:48:50 +04:00
])
dnl SMB_WRITE_PERLVARS(path)
AC_DEFUN([SMB_WRITE_PERLVARS],
[
echo "configure: creating $1"
cat >$1<<CEOF
# config.pm - Autogenerate by configure. DO NOT EDIT!
package config;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(%enabled %config);
use strict;
use vars qw(%enabled %config);
2008-11-26 18:22:11 +03:00
%config = (
CEOF
for ac_var in $ac_subst_vars
do
2009-01-09 14:05:55 +03:00
eval ac_val=\$$ac_var
# quote ' (\x27) inside '...' and make sure \ isn't eaten by shells, so use perl:
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
2008-11-26 18:22:11 +03:00
done
2008-05-18 19:48:50 +04:00
2008-11-26 18:22:11 +03:00
cat >>$1<<CEOF
);
2008-05-18 19:48:50 +04:00
$SMB_INFO_ENABLES
1;
CEOF
])
2008-05-18 19:55:50 +04:00
dnl SMB_BUILD_RUN(OUTPUT_FILE)
AC_DEFUN([SMB_BUILD_RUN],
[
AC_OUTPUT_COMMANDS(
[
test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && (
cd $builddir;
# NOTE: We *must* use -R so we don't follow symlinks (at least on BSD
# systems).
test -d heimdal || cp -R $srcdir/heimdal $builddir/
test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/
test -d build || builddir="$builddir" \
srcdir="$srcdir" \
$PERL ${srcdir}/script/buildtree.pl
)
$PERL -I${builddir} -I${builddir}/build \
-I${srcdir} -I${srcdir}/build \
2008-05-18 20:08:37 +04:00
${srcdir}/build/smb_build/main.pl --output=$1 main.mk || exit $?
2008-05-18 19:55:50 +04:00
],
[
srcdir="$srcdir"
builddir="$builddir"
PERL="$PERL"
export PERL
export srcdir
export builddir
])
])