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
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
###################################
"
])
2008-03-28 02:44:14 +03:00
dnl SMB_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags)
2007-06-28 00:32:35 +04:00
AC_DEFUN([SMB_LIBRARY],
[
2008-02-11 00:58:03 +03:00
MAKE_SETTINGS="$MAKE_SETTINGS
$1_CFLAGS = $6
$1_LDFLAGS = $7
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
# 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
if $PKG_CONFIG --atleast-pkgconfig-version 0.9.0; 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])
AC_TRY_RUN([#include "${srcdir-.}/build/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
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'`],
[`$PKG_CONFIG --cflags-only-I '$2'`],
2008-02-18 21:46:27 +03:00
[`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])
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
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
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
])
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
"
])
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
\$enabled{$1} = \"$2\";"
2004-05-13 14:20:53 +04:00
])
2008-05-18 19:48:50 +04:00
dnl SMB_WRITE_MAKEVARS(path)
AC_DEFUN([SMB_WRITE_MAKEVARS],
[
echo "configure: creating $1"
cat >$1<<CEOF
# $1 - Autogenerated by configure, DO NOT EDIT!
AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
AC_Var = $AC_Var])
$MAKE_SETTINGS
CEOF
])
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);
%config = (AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
AC_Var => '$AC_Var',])
);
$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
])
])