summaryrefslogtreecommitdiff
path: root/source4/build/m4
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/m4')
-rw-r--r--source4/build/m4/ax_cflags_gcc_option.m4109
-rw-r--r--source4/build/m4/ax_cflags_irix_option.m4174
-rw-r--r--source4/build/m4/check_cc.m4157
-rw-r--r--source4/build/m4/check_doc.m41
-rw-r--r--source4/build/m4/check_ld.m4187
-rw-r--r--source4/build/m4/check_make.m439
-rw-r--r--source4/build/m4/check_path.m4207
-rw-r--r--source4/build/m4/check_perl.m428
-rw-r--r--source4/build/m4/env.m446
-rw-r--r--source4/build/m4/public.m4229
10 files changed, 1177 insertions, 0 deletions
diff --git a/source4/build/m4/ax_cflags_gcc_option.m4 b/source4/build/m4/ax_cflags_gcc_option.m4
new file mode 100644
index 0000000000..ec01a000aa
--- /dev/null
+++ b/source4/build/m4/ax_cflags_gcc_option.m4
@@ -0,0 +1,109 @@
+dnl @synopsis AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
+dnl
+dnl AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
+dnl "checking CFLAGS for gcc -fvomit-frame ... yes" and adds
+dnl the optionflag to CFLAGS if it is understood. You can override
+dnl the shellvar-default of CFLAGS of course. The order of arguments
+dnl stems from the explicit macros like AX_CFLAGS_WARN_ALL.
+dnl
+dnl The macro is a lot simpler than any special AX_CFLAGS_* macro (or
+dnl ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
+dnl However, if you use this macro in a few places, it would be great
+dnl if you would make up a new function-macro and submit it to the
+dnl ac-archive.
+dnl
+dnl - $1 option-to-check-for : required ("-option" as non-value)
+dnl - $2 shell-variable-to-add-to : CFLAGS
+dnl - $3 action-if-found : add value to shellvariable
+dnl - $4 action-if-not-found : nothing
+dnl
+dnl note: in earlier versions, $1-$2 were swapped. We try to detect the
+dnl situation and accept a $2=~/-/ as being the old option-to-check-for.
+dnl
+dnl also: there are other variants that emerged from the original macro
+dnl variant which did just test an option to be possibly added. However,
+dnl some compilers accept an option silently, or possibly for just
+dnl another option that was not intended. Therefore, we have to do a
+dnl generic test for a compiler family. For gcc we check "-pedantic"
+dnl being accepted which is also understood by compilers who just want
+dnl to be compatible with gcc even when not being made from gcc sources.
+dnl
+dnl see also:
+dnl AX_CFLAGS_SUN_OPTION AX_CFLAGS_HPUX_OPTION
+dnl AX_CFLAGS_AIX_OPTION AX_CFLAGS_IRIX_OPTION
+dnl
+dnl @, tested, experimental
+dnl @version $Id: ax_cflags_gcc_option.m4,v 1.5 2003/11/29 08:13:25 guidod Exp $
+dnl @author Guido Draheim <guidod@gmx.de>
+dnl http://ac-archive.sourceforge.net/C_Support/ax_cflags_gcc_option.m4
+dnl
+AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
+AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
+AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
+VAR,[VAR="no, unknown"
+ AC_LANG_SAVE
+ AC_LANG_C
+ ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_TRY_COMPILE([],[return 0;],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+ FLAGS="$ac_save_[]FLAGS"
+ AC_LANG_RESTORE
+])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_ifvaln($4,$4) ;;
+ *) m4_ifvaln($3,$3,[
+ if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
+ then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
+ else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
+ m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
+ fi ]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+AS_VAR_POPDEF([FLAGS])dnl
+])
+
+
+dnl -------------------------------------------------------------------------
+
+AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
+AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
+AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
+VAR,[VAR="no, unknown"
+ AC_LANG_SAVE
+ AC_LANG_C
+ ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_TRY_COMPILE([],[return 0;],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+ FLAGS="$ac_save_[]FLAGS"
+ AC_LANG_RESTORE
+])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_ifvaln($4,$4) ;;
+ *) m4_ifvaln($3,$3,[
+ if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
+ then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
+ else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
+ m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
+ fi ]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+AS_VAR_POPDEF([FLAGS])dnl
+])
+
+
+AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
+[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
diff --git a/source4/build/m4/ax_cflags_irix_option.m4 b/source4/build/m4/ax_cflags_irix_option.m4
new file mode 100644
index 0000000000..f7fe2a19b0
--- /dev/null
+++ b/source4/build/m4/ax_cflags_irix_option.m4
@@ -0,0 +1,174 @@
+dnl @synopsis AX_CFLAGS_IRIX_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
+dnl
+dnl AX_CFLAGS_IRIX_OPTION(-go_for_it) would show a message as like
+dnl "checking CFLAGS for irix/cc -go_for_it ... yes" and adds the
+dnl optionflag to CFLAGS if it is understood. You can override the
+dnl shellvar-default of CFLAGS of course. The order of arguments stems
+dnl from the explicit macros like AX_CFLAGS_WARN_ALL.
+dnl
+dnl The cousin AX_CXXFLAGS_IRIX_OPTION would check for an option to add
+dnl to CXXFLAGS - and it uses the autoconf setup for C++ instead of C
+dnl (since it is possible to use different compilers for C and C++).
+dnl
+dnl The macro is a lot simpler than any special AX_CFLAGS_* macro (or
+dnl ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
+dnl However, if you use this macro in a few places, it would be great
+dnl if you would make up a new function-macro and submit it to the
+dnl ac-archive.
+dnl
+dnl - $1 option-to-check-for : required ("-option" as non-value)
+dnl - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case)
+dnl - $3 action-if-found : add value to shellvariable
+dnl - $4 action-if-not-found : nothing
+dnl
+dnl note: in earlier versions, $1-$2 were swapped. We try to detect the
+dnl situation and accept a $2=~/-/ as being the old
+dnl option-to-check-for.
+dnl
+dnl see also: AX_CFLAGS_GCC_OPTION for the widely used original
+dnl variant.
+dnl
+dnl @category C
+dnl @author Guido Draheim <guidod@gmx.de>
+dnl @version 2005-01-21
+dnl @license GPLWithACException
+
+AC_DEFUN([AX_CFLAGS_IRIX_OPTION_OLD], [dnl
+AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_irix_option_$2])dnl
+AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for irix/cc m4_ifval($2,$2,-option)],
+VAR,[VAR="no, unknown"
+ AC_LANG_SAVE
+ AC_LANG_C
+ ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-fullwarn -use_readonly_const % m4_ifval($2,$2,-option)" dnl IRIX C
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_TRY_COMPILE([],[return 0;],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+ FLAGS="$ac_save_[]FLAGS"
+ AC_LANG_RESTORE
+])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_ifvaln($4,$4) ;;
+ *) m4_ifvaln($3,$3,[
+ if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
+ then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
+ else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
+ m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
+ fi ]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+AS_VAR_POPDEF([FLAGS])dnl
+])
+
+dnl the only difference - the LANG selection... and the default FLAGS
+
+AC_DEFUN([AX_CXXFLAGS_IRIX_OPTION_OLD], [dnl
+AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_irix_option_$2])dnl
+AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for irix/cc m4_ifval($2,$2,-option)],
+VAR,[VAR="no, unknown"
+ AC_LANG_SAVE
+ AC_LANG_CXX
+ ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-fullwarn -use_readonly_const % m4_ifval($2,$2,-option)" dnl IRIX C
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_TRY_COMPILE([],[return 0;],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+ FLAGS="$ac_save_[]FLAGS"
+ AC_LANG_RESTORE
+])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_ifvaln($4,$4) ;;
+ *) m4_ifvaln($3,$3,[
+ if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
+ then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
+ else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
+ m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
+ fi ]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+AS_VAR_POPDEF([FLAGS])dnl
+])
+
+dnl --------------------------------------------------------------------------
+
+AC_DEFUN([AX_CFLAGS_IRIX_OPTION_NEW], [dnl
+AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_irix_option_$1])dnl
+AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for irix/cc m4_ifval($1,$1,-option)],
+VAR,[VAR="no, unknown"
+ AC_LANG_SAVE
+ AC_LANG_C
+ ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-fullwarn -use_readonly_const % m4_ifval($1,$1,-option)" dnl IRIX C
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_TRY_COMPILE([],[return 0;],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+ FLAGS="$ac_save_[]FLAGS"
+ AC_LANG_RESTORE
+])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_ifvaln($4,$4) ;;
+ *) m4_ifvaln($3,$3,[
+ if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
+ then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
+ else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
+ m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
+ fi ]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+AS_VAR_POPDEF([FLAGS])dnl
+])
+
+dnl the only difference - the LANG selection... and the default FLAGS
+
+AC_DEFUN([AX_CXXFLAGS_IRIX_OPTION_NEW], [dnl
+AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_irix_option_$1])dnl
+AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for irix/cc m4_ifval($1,$1,-option)],
+VAR,[VAR="no, unknown"
+ AC_LANG_SAVE
+ AC_LANG_CXX
+ ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-fullwarn -use_readonly_const % m4_ifval($1,$1,-option)" dnl IRIX C
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_TRY_COMPILE([],[return 0;],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+ FLAGS="$ac_save_[]FLAGS"
+ AC_LANG_RESTORE
+])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_ifvaln($4,$4) ;;
+ *) m4_ifvaln($3,$3,[
+ if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
+ then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
+ else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
+ m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
+ fi ]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+AS_VAR_POPDEF([FLAGS])dnl
+])
+
+AC_DEFUN([AX_CFLAGS_IRIX_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
+[AX_CFLAGS_IRIX_OPTION_NEW($@)],[AX_CFLAGS_IRIX_OPTION_OLD($@)])])
+
+AC_DEFUN([AX_CXXFLAGS_IRIX_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
+[AX_CXXFLAGS_IRIX_OPTION_NEW($@)],[AX_CXXFLAGS_IRIX_OPTION_OLD($@)])])
diff --git a/source4/build/m4/check_cc.m4 b/source4/build/m4/check_cc.m4
new file mode 100644
index 0000000000..51531ca776
--- /dev/null
+++ b/source4/build/m4/check_cc.m4
@@ -0,0 +1,157 @@
+dnl SMB Build Environment CC Checks
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+
+AC_LIBREPLACE_CC_CHECKS
+
+#
+# Set the debug symbol option if we have
+# --enable-*developer or --enable-debug
+# and the compiler supports it
+#
+if test x$ac_cv_prog_cc_g = xyes -a x$debug = xyes; then
+ CFLAGS="${CFLAGS} -g"
+fi
+
+############################################
+# check if the compiler handles c99 struct initialization
+LIBREPLACE_C99_STRUCT_INIT(samba_cv_c99_struct_initialization=yes,
+ samba_cv_c99_struct_initialization=no)
+
+if test x"$samba_cv_c99_struct_initialization" != x"yes"; then
+ AC_MSG_WARN([C compiler does not support c99 struct initialization!])
+ AC_MSG_ERROR([Please Install gcc from http://gcc.gnu.org/])
+fi
+
+############################################
+# check if the compiler can handle negative enum values
+# and don't truncate the values to INT_MAX
+# a runtime test is needed here
+AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_CC_NEGATIVE_ENUM_VALUES, [
+ AC_TRY_RUN(
+[
+ #include <stdio.h>
+ enum negative_values { NEGATIVE_VALUE = 0xFFFFFFFF };
+ int main(void) {
+ enum negative_values v1 = NEGATIVE_VALUE;
+ unsigned v2 = 0xFFFFFFFF;
+ if (v1 != v2) {
+ printf("v1=0x%08x v2=0x%08x\n", v1, v2);
+ return 1;
+ }
+ return 0;
+ }
+],
+ samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv_CC_NEGATIVE_ENUM_VALUES=no)])
+if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
+ AC_DEFINE(USE_UINT_ENUMS, 1, [Whether the compiler has uint enum support])
+fi
+
+AC_MSG_CHECKING([for test routines])
+AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
+ AC_MSG_RESULT(yes),
+ AC_MSG_ERROR([cant find test code. Aborting config]),
+ AC_MSG_WARN([cannot run when cross-compiling]))
+
+#
+# Check if the compiler support ELF visibility for symbols
+#
+
+visibility_attribute=no
+VISIBILITY_CFLAGS=""
+if test x"$GCC" = x"yes" ; then
+ AX_CFLAGS_GCC_OPTION([-fvisibility=hidden], VISIBILITY_CFLAGS)
+fi
+
+if test -n "$VISIBILITY_CFLAGS"; then
+ AC_MSG_CHECKING([whether the C compiler supports the visibility attribute])
+ OLD_CFLAGS="$CFLAGS"
+
+ CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
+ AC_TRY_LINK([
+ void vis_foo1(void) {}
+ __attribute__((visibility("default"))) void vis_foo2(void) {}
+ ],[
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_VISIBILITY_ATTR,1,[Whether the C compiler supports the visibility attribute])
+ visibility_attribute=yes
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+ CFLAGS="$OLD_CFLAGS"
+fi
+AC_SUBST(visibility_attribute)
+
+#
+# Check if the compiler can handle the options we selected by
+# --enable-*developer
+#
+DEVELOPER_CFLAGS=""
+if test x$developer = xyes; then
+ OLD_CFLAGS="${CFLAGS}"
+
+ CFLAGS="${CFLAGS} -D_SAMBA_DEVELOPER_DONNOT_USE_O2_"
+ DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
+ if test x"$GCC" = x"yes" ; then
+ #
+ # warnings we want...
+ #
+ AX_CFLAGS_GCC_OPTION(-Wall, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wshadow, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Werror-implicit-function-declaration, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wstrict-prototypes, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wpointer-arith, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wcast-qual, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wcast-align, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wwrite-strings, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wmissing-format-attribute, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wformat=2, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wdeclaration-after-statement, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wunused-macros, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wno-unused-macros, CFLAG_NO_UNUSED_MACROS)
+ AC_SUBST(CFLAG_NO_CAST_QUAL)
+ AC_SUBST(CFLAG_NO_UNUSED_MACROS)
+ AX_CFLAGS_GCC_OPTION(-Wno-cast-qual, CFLAG_NO_CAST_QUAL)
+# AX_CFLAGS_GCC_OPTION(-Wextra, DEVELOPER_CFLAGS)
+# AX_CFLAGS_GCC_OPTION(-Wc++-compat, DEVELOPER_CFLAGS)
+# AX_CFLAGS_GCC_OPTION(-Wmissing-prototypes, DEVELOPER_CFLAGS)
+# AX_CFLAGS_GCC_OPTION(-Wmissing-declarations, DEVELOPER_CFLAGS)
+# AX_CFLAGS_GCC_OPTION(-Wmissing-field-initializers, DEVELOPER_CFLAGS)
+ #
+ # warnings we don't want...
+ #
+ AX_CFLAGS_GCC_OPTION(-Wno-format-y2k, DEVELOPER_CFLAGS)
+ AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter, DEVELOPER_CFLAGS)
+ else
+ AX_CFLAGS_IRIX_OPTION(-fullwarn, DEVELOPER_CFLAGS)
+ fi
+
+ CFLAGS="${OLD_CFLAGS}"
+fi
+if test -n "$DEVELOPER_CFLAGS"; then
+ OLD_CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
+ AC_MSG_CHECKING([that the C compiler can use the DEVELOPER_CFLAGS])
+ AC_TRY_COMPILE([],[],
+ AC_MSG_RESULT(yes),
+ DEVELOPER_CFLAGS=""; AC_MSG_RESULT(no))
+ CFLAGS="${OLD_CFLAGS}"
+fi
+
+# allow for --with-hostcc=gcc
+AC_ARG_WITH(hostcc,[ --with-hostcc=compiler choose host compiler],
+[HOSTCC=$withval],
+[
+if test z"$cross_compiling" = "yes"; then
+ HOSTCC=cc
+else
+ HOSTCC=$CC
+fi
+])
+AC_SUBST(HOSTCC)
+
+AC_PATH_PROG(GCOV,gcov)
diff --git a/source4/build/m4/check_doc.m4 b/source4/build/m4/check_doc.m4
new file mode 100644
index 0000000000..2aaf9596de
--- /dev/null
+++ b/source4/build/m4/check_doc.m4
@@ -0,0 +1 @@
+AC_PATH_PROG(XSLTPROC, xsltproc)
diff --git a/source4/build/m4/check_ld.m4 b/source4/build/m4/check_ld.m4
new file mode 100644
index 0000000000..3a74ffc239
--- /dev/null
+++ b/source4/build/m4/check_ld.m4
@@ -0,0 +1,187 @@
+dnl SMB Build Environment LD Checks
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004
+dnl Copyright (C) Jelmer Vernooij 2006
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+
+AC_PATH_PROG(PROG_LD,ld)
+LD=${PROG_LD}
+AC_PROG_LD_GNU
+LD=""
+
+AC_SUBST(BLDSHARED)
+AC_SUBST(LD)
+AC_SUBST(SYS_LDFLAGS)
+AC_SUBST(LDFLAGS)
+
+# Assume non-shared by default and override below
+# these are the defaults, good for lots of systems
+BLDSHARED="false"
+LD="${CC}"
+PICFLAG=""
+
+# allow for --with-hostld=gcc
+AC_ARG_WITH(hostld,[ --with-hostld=linker choose host linker],
+[HOSTLD=$withval],
+[HOSTLD=$HOSTCC])
+
+AC_MSG_CHECKING([whether to try to build shared libraries on $host_os])
+
+# and these are for particular systems
+case "$host_os" in
+ *linux*)
+ BLDSHARED="true"
+ SYS_LDFLAGS="-Wl,--export-dynamic"
+ ;;
+ *solaris*)
+ BLDSHARED="true"
+ if test "${GCC}" = "yes"; then
+ if test "${ac_cv_prog_gnu_ld}" = "yes"; then
+ SYS_LDFLAGS="-Wl,-E"
+ fi
+ fi
+ ;;
+ *sunos*)
+ BLDSHARED="true"
+ ;;
+ *netbsd* | *freebsd* | *dragonfly* )
+ BLDSHARED="true"
+ SYS_LDFLAGS="-Wl,--export-dynamic"
+ ;;
+ *openbsd*)
+ BLDSHARED="true"
+ SYS_LDFLAGS="-Wl,-Bdynamic"
+ ;;
+ *irix*)
+ BLDSHARED="true"
+ ;;
+ *aix*)
+ BLDSHARED="true"
+ SYS_LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
+ ;;
+ *hpux*)
+ # Use special PIC flags for the native HP-UX compiler.
+ BLDSHARED="true" # I hope this is correct
+ if test "$host_cpu" = "ia64"; then
+ SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
+ else
+ SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
+ fi
+ ;;
+ *osf*)
+ BLDSHARED="true"
+ ;;
+ *unixware*)
+ BLDSHARED="true"
+ ;;
+ *darwin*)
+ BLDSHARED="true"
+ ;;
+esac
+
+AC_MSG_RESULT($BLDSHARED)
+
+AC_MSG_CHECKING([LD])
+AC_MSG_RESULT([$LD])
+AC_MSG_CHECKING([LDFLAGS])
+AC_MSG_RESULT([$LDFLAGS])
+AC_MSG_CHECKING([SYS_LDFLAGS])
+AC_MSG_RESULT([$SYS_LDFLAGS])
+
+AC_SUBST(HOSTLD)
+
+AC_LIBREPLACE_STLD
+AC_LIBREPLACE_STLD_FLAGS
+
+AC_MSG_CHECKING([STLD])
+AC_MSG_RESULT([$STLD])
+AC_MSG_CHECKING([STLD_FLAGS])
+AC_MSG_RESULT([$STLD_FLAGS])
+
+AC_LD_PICFLAG
+AC_LD_EXPORT_DYNAMIC
+AC_LD_SHLIBEXT
+AC_LD_SONAMEFLAG
+AC_LIBREPLACE_SHLD
+AC_LIBREPLACE_SHLD_FLAGS
+AC_LIBREPLACE_MDLD
+AC_LIBREPLACE_MDLD_FLAGS
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+
+#######################################################
+# test whether building a shared library actually works
+if test $BLDSHARED = true; then
+
+ AC_MSG_CHECKING([SHLD])
+ AC_MSG_RESULT([$SHLD])
+ AC_MSG_CHECKING([SHLD_FLAGS])
+ AC_MSG_RESULT([$SHLD_FLAGS])
+
+ AC_MSG_CHECKING([MDLD])
+ AC_MSG_RESULT([$MDLD])
+ AC_MSG_CHECKING([MDLD_FLAGS])
+ AC_MSG_RESULT([$MDLD_FLAGS])
+
+ AC_MSG_CHECKING([SHLIBEXT])
+ AC_MSG_RESULT([$SHLIBEXT])
+ AC_MSG_CHECKING([SONAMEFLAG])
+ AC_MSG_RESULT([$SONAMEFLAG])
+
+ AC_MSG_CHECKING([PICFLAG])
+ AC_MSG_RESULT([$PICFLAG])
+
+ AC_CACHE_CHECK([whether building shared libraries actually works],
+ [ac_cv_shlib_works],[
+ ac_cv_shlib_works=no
+ # try building a trivial shared library
+ # TODO: also test SONAMEFLAG
+ ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
+ ${SHLD} ${SHLD_FLAGS} -o shlib.${SHLIBEXT} shlib.o &&
+ ac_cv_shlib_works=yes
+ rm -f shlib.${SHLIBEXT} shlib.o
+ ])
+ AC_CACHE_CHECK([whether building shared modules actually works],
+ [ac_cv_shmod_works],[
+ ac_cv_shmod_works=no
+ # try building a trivial shared library
+ ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
+ ${MDLD} ${MDLD_FLAGS} -o shlib.${SHLIBEXT} shlib.o &&
+ ac_cv_shmod_works=yes
+ rm -f shlib.${SHLIBEXT} shlib.o
+ ])
+ if test $ac_cv_shlib_works = no; then
+ AC_MSG_ERROR(unable to build shared libraries)
+ fi
+ if test $ac_cv_shmod_works = no; then
+ AC_MSG_ERROR(unable to build shared modules)
+ fi
+fi
+
+AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
+
+AC_MSG_CHECKING([if we can link using the selected flags])
+AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
+ AC_MSG_RESULT(yes),
+ AC_MSG_ERROR([we cannot link with the selected cc and ld flags. Aborting configure]),
+ AC_MSG_WARN([cannot run when cross-compiling]))
+
+
+USESHARED=false
+AC_SUBST(USESHARED)
+
+AC_ARG_ENABLE(dso,
+[ --enable-dso Enable using shared libraries internally (experimental)],
+[],[enable_dso=no])
+
+if test x"$enable_dso" = x"yes" -a x"$BLDSHARED" != x"true"; then
+ AC_MSG_ERROR([--enable-dso: no support for shared libraries])
+fi
+
+if test x"$enable_dso" != x"no"; then
+ USESHARED=$BLDSHARED
+fi
+
+AC_MSG_CHECKING([if binaries will use shared libraries])
+AC_MSG_RESULT([$USESHARED])
diff --git a/source4/build/m4/check_make.m4 b/source4/build/m4/check_make.m4
new file mode 100644
index 0000000000..f497684453
--- /dev/null
+++ b/source4/build/m4/check_make.m4
@@ -0,0 +1,39 @@
+dnl SMB Build Environment make Checks
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004
+dnl Copyright (C) Jelmer Vernooij 2005
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+
+AC_PATH_PROGS(MAKE,gmake make)
+
+AC_CACHE_CHECK([whether we have GNU make], samba_cv_gnu_make, [
+if ! $ac_cv_path_MAKE --version | head -1 | grep GNU 2>/dev/null >/dev/null
+then
+ AC_MSG_ERROR([Unable to find GNU make])
+fi
+])
+
+AC_CACHE_CHECK([GNU make version], samba_cv_gnu_make_version,[
+ samba_cv_gnu_make_version=`$ac_cv_path_MAKE --version | head -1 | cut -d " " -f 3 2>/dev/null`
+ ])
+ GNU_MAKE_VERSION=$samba_cv_gnu_make_version
+ AC_SUBST(GNU_MAKE_VERSION)
+
+
+new_make=no
+AC_MSG_CHECKING([for GNU make >= 3.81])
+if $PERL -e " \$_ = '$GNU_MAKE_VERSION'; s/@<:@^\d\.@:>@.*//g; exit (\$_ < 3.81);"; then
+ new_make=yes
+fi
+AC_MSG_RESULT($new_make)
+automatic_dependencies=no
+AX_CFLAGS_GCC_OPTION([-M -MT conftest.d -MF conftest.o], [], [ automatic_dependencies=$new_make ], [])
+AC_MSG_CHECKING([Whether to use automatic dependencies])
+AC_ARG_ENABLE(automatic-dependencies,
+[ --enable-automatic-dependencies Enable automatic dependencies],
+[ automatic_dependencies=$enableval ],
+[ automatic_dependencies=no ])
+AC_MSG_RESULT($automatic_dependencies)
+AC_SUBST(automatic_dependencies)
diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4
new file mode 100644
index 0000000000..c45a803633
--- /dev/null
+++ b/source4/build/m4/check_path.m4
@@ -0,0 +1,207 @@
+dnl SMB Build Environment Path Checks
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+
+AC_LIBREPLACE_LOCATION_CHECKS
+
+#################################################
+# Directory handling stuff to support both the
+# legacy SAMBA directories and FHS compliant
+# ones...
+AC_PREFIX_DEFAULT(/usr/local/samba)
+
+# Defaults and --without-fhs
+logfilebase="${localstatedir}"
+lockdir="${localstatedir}/locks"
+piddir="${localstatedir}/run"
+privatedir="\${prefix}/private"
+modulesdir="\${prefix}/modules"
+winbindd_socket_dir="${localstatedir}/run/winbindd"
+winbindd_privileged_socket_dir="${localstatedir}/lib/winbindd_privileged"
+ntp_signd_socket_dir="${localstatedir}/run/ntp_signd"
+
+AC_ARG_WITH(fhs,
+[AS_HELP_STRING([--with-fhs],[Use FHS-compliant paths (default=no)])],
+ lockdir="${localstatedir}/lib/samba"
+ piddir="${localstatedir}/run/samba"
+ logfilebase="${localstatedir}/log/samba"
+ privatedir="${localstatedir}/lib/samba/private"
+ sysconfdir="${sysconfdir}/samba"
+ modulesdir="${libdir}/samba"
+ datadir="${datadir}/samba"
+ includedir="${includedir}/samba-4.0"
+ ntp_signd_socket_dir="${localstatedir}/run/samba/ntp_signd"
+ winbindd_socket_dir="${localstatedir}/run/samba/winbindd"
+ winbindd_privileged_socket_dir="${localstatedir}/lib/samba/winbindd_privileged"
+)
+
+#################################################
+# set private directory location
+AC_ARG_WITH(privatedir,
+[AS_HELP_STRING([--with-privatedir=DIR],[Where to put sam.ldb and other private files containing key material ($ac_default_prefix/private)])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody calls it without argument
+ #
+ AC_MSG_WARN([--with-privatedir called without argument - will use default])
+ ;;
+ * )
+ privatedir="$withval"
+ ;;
+ esac])
+
+#################################################
+# set where the winbindd socket should be put
+AC_ARG_WITH(winbindd-socket-dir,
+[AS_HELP_STRING([--with-winbindd-socket-dir=DIR],[Where to put the winbindd socket ($winbindd_socket_dir)])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody calls it without argument
+ #
+ AC_MSG_WARN([--with-winbind-socketdir called without argument - will use default])
+ ;;
+ * )
+ winbindd_socket_dir="$withval"
+ ;;
+ esac])
+
+#################################################
+# set where the winbindd privilaged socket should be put
+AC_ARG_WITH(winbindd-privileged-socket-dir,
+[AS_HELP_STRING([--with-winbindd-privileged-socket-dir=DIR],[Where to put the winbindd socket ($winbindd_privileged_socket_dir)])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody calls it without argument
+ #
+ AC_MSG_WARN([--with-winbind-privileged-socketdir called without argument - will use default])
+ ;;
+ * )
+ winbindd_privileged_socket_dir="$withval"
+ ;;
+ esac])
+
+#################################################
+# set where the NTP signing deamon socket should be put
+AC_ARG_WITH(ntp-signd-socket-dir,
+[AS_HELP_STRING([--with-ntp-signd-socket-dir=DIR],[Where to put the NTP signing deamon socket ($ac_default_prefix/run/ntp_signd)])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody calls it without argument
+ #
+ AC_MSG_WARN([--with-ntp-signd-socketdir called without argument - will use default])
+ ;;
+ * )
+ ntp_signd_socket_dir="$withval"
+ ;;
+ esac])
+
+#################################################
+# set lock directory location
+AC_ARG_WITH(lockdir,
+[AS_HELP_STRING([--with-lockdir=DIR],[Where to put lock files ($ac_default_prefix/var/locks)])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody calls it without argument
+ #
+ AC_MSG_WARN([--with-lockdir called without argument - will use default])
+ ;;
+ * )
+ lockdir="$withval"
+ ;;
+ esac])
+
+#################################################
+# set pid directory location
+AC_ARG_WITH(piddir,
+[AS_HELP_STRING([--with-piddir=DIR],[Where to put pid files ($ac_default_prefix/var/locks)])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody calls it without argument
+ #
+ AC_MSG_WARN([--with-piddir called without argument - will use default])
+ ;;
+ * )
+ piddir="$withval"
+ ;;
+ esac])
+
+#################################################
+# set log directory location
+AC_ARG_WITH(logfilebase,
+[AS_HELP_STRING([--with-logfilebase=DIR],[Where to put log files (\$(VARDIR))])],
+[ case "$withval" in
+ yes|no)
+ #
+ # Just in case anybody does it
+ #
+ AC_MSG_WARN([--with-logfilebase called without argument - will use default])
+ ;;
+ * )
+ logfilebase="$withval"
+ ;;
+ esac])
+
+
+AC_SUBST(lockdir)
+AC_SUBST(piddir)
+AC_SUBST(logfilebase)
+AC_SUBST(privatedir)
+AC_SUBST(bindir)
+AC_SUBST(sbindir)
+AC_SUBST(winbindd_socket_dir)
+AC_SUBST(winbindd_privileged_socket_dir)
+AC_SUBST(ntp_signd_socket_dir)
+AC_SUBST(modulesdir)
+
+#################################################
+# set prefix for 'make test'
+# this is needed to workarround the 108 char
+# unix socket path limitation!
+#
+selftest_prefix="./st"
+AC_SUBST(selftest_prefix)
+AC_ARG_WITH(selftest-prefix,
+[AS_HELP_STRING([--with-selftest-prefix=DIR],[The prefix where make test will be run ($selftest_prefix)])],
+[ case "$withval" in
+ yes|no)
+ AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
+ ;;
+ * )
+ selftest_prefix="$withval"
+ ;;
+ esac])
+
+debug=no
+AC_ARG_ENABLE(debug,
+[AS_HELP_STRING([--enable-debug],[Turn on compiler debugging information (default=no)])],
+ [if test x$enable_debug = xyes; then
+ debug=yes
+ fi])
+
+developer=no
+AC_SUBST(developer)
+AC_ARG_ENABLE(developer,
+[AS_HELP_STRING([--enable-developer],[Turn on developer warnings and debugging (default=no)])],
+ [if test x$enable_developer = xyes; then
+ debug=yes
+ developer=yes
+ fi])
+
+dnl disable these external libs
+AC_ARG_WITH(disable-ext-lib,
+[AS_HELP_STRING([--with-disable-ext-lib=LIB],[Comma-seperated list of external libraries])],
+[ if test $withval; then
+ for i in `echo $withval | sed -e's/,/ /g'`
+ do
+ eval SMB_$i=NO
+ done
+fi ])
diff --git a/source4/build/m4/check_perl.m4 b/source4/build/m4/check_perl.m4
new file mode 100644
index 0000000000..82ca242499
--- /dev/null
+++ b/source4/build/m4/check_perl.m4
@@ -0,0 +1,28 @@
+dnl SMB Build Environment Perl Checks
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+
+case "$host_os" in
+ *irix*)
+ # On IRIX, we prefer Freeware or Nekoware Perl, because the
+ # system perl is so ancient.
+ AC_PATH_PROG(PERL, perl, "", "/usr/freeware/bin:/usr/nekoware/bin:$PATH")
+ ;;
+ *)
+ AC_PATH_PROG(PERL, perl)
+ ;;
+esac
+
+if test x"$PERL" = x""; then
+ AC_MSG_WARN([No version of perl was found!])
+ AC_MSG_ERROR([Please install perl from http://www.perl.com/])
+fi
+if test x"$debug" = x"yes";then
+ PERL="$PERL -W"
+fi
+export PERL
+
+AC_PATH_PROG(YAPP, yapp, false)
diff --git a/source4/build/m4/env.m4 b/source4/build/m4/env.m4
new file mode 100644
index 0000000000..6c040b9bab
--- /dev/null
+++ b/source4/build/m4/env.m4
@@ -0,0 +1,46 @@
+dnl SMB Build Environment Checks
+dnl -------------------------------------------------------
+dnl Copyright (C) Stefan (metze) Metzmacher 2004
+dnl Released under the GNU GPL
+dnl -------------------------------------------------------
+dnl
+
+AC_SUBST(srcdir)
+export srcdir;
+
+# we always set builddir to "." as that's nicer than
+# having the absolute path of the current work directory
+builddir=.
+AC_SUBST(builddir)
+export builddir;
+
+AC_SUBST(datarootdir)
+
+AC_SUBST(VPATH)
+VPATH="\$(builddir):\$(srcdir)"
+
+SMB_VERSION_STRING=`cat ${srcdir}/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
+echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
+
+SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat ${srcdir}/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_FULLREV}";then
+ echo "BUILD COMMIT REVISION: ${SAMBA_VERSION_GIT_COMMIT_FULLREV}"
+fi
+SAMBA_VERSION_GIT_COMMIT_DATE=`cat ${srcdir}/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_DATE' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_DATE}";then
+ echo "BUILD COMMIT DATE: ${SAMBA_VERSION_GIT_COMMIT_DATE}"
+fi
+SAMBA_VERSION_GIT_COMMIT_TIME=`cat ${srcdir}/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_TIME' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then
+ echo "BUILD COMMIT TIME: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
+
+ # just to keep the build-farm gui happy for now...
+ echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
+fi
+
+m4_include(build/m4/check_path.m4)
+m4_include(build/m4/check_perl.m4)
+m4_include(build/m4/check_cc.m4)
+m4_include(build/m4/check_ld.m4)
+m4_include(build/m4/check_make.m4)
+m4_include(build/m4/check_doc.m4)
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
new file mode 100644
index 0000000000..d61e00b22e
--- /dev/null
+++ b/source4/build/m4/public.m4
@@ -0,0 +1,229 @@
+dnl SMB Build System
+dnl ----------------
+dnl Copyright (C) 2004 Stefan Metzmacher
+dnl Copyright (C) 2004-2005 Jelmer Vernooij
+dnl Published under the GPL
+dnl
+dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+dnl
+dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
+dnl
+dnl SMB_ENABLE(name,default_build)
+dnl
+dnl SMB_INCLUDE_MK(file)
+dnl
+dnl SMB_WRITE_MAKEVARS(file)
+dnl
+dnl SMB_WRITE_PERLVARS(file)
+dnl
+dnl #######################################################
+dnl ### And now the implementation ###
+dnl #######################################################
+
+dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems,cflags)
+AC_DEFUN([SMB_SUBSYSTEM],
+[
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1_CFLAGS = $4
+$1_ENABLE = YES
+$1_OBJ_FILES = $2
+"
+
+SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
+###################################
+# Start Subsystem $1
+@<:@SUBSYSTEM::$1@:>@
+PRIVATE_DEPENDENCIES = $3
+CFLAGS = \$($1_CFLAGS)
+ENABLE = YES
+# End Subsystem $1
+###################################
+"
+])
+
+dnl SMB_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags)
+AC_DEFUN([SMB_LIBRARY],
+[
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1_CFLAGS = $6
+$1_LDFLAGS = $7
+n1_ENABLE = YES
+$1_OBJ_FILES = $2
+"
+
+SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES
+###################################
+# Start Library $1
+@<:@LIBRARY::$1@:>@
+PRIVATE_DEPENDENCIES = $3
+CFLAGS = \$($1_CFLAGS)
+LDFLAGS = \$($1_LDFLAGS)
+ENABLE = YES
+# End Library $1
+###################################
+"
+])
+
+dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+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://pkg-config.freedesktop.org/ to get pkg-config."
+ ac_cv_$1_found=no
+ else
+ if $PKG_CONFIG --atleast-pkgconfig-version 0.9.0; then
+ AC_MSG_CHECKING(for $2)
+
+ if $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_ENABLE($1, YES)
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no),
+ AC_MSG_WARN([cannot run when cross-compiling]))
+ CFLAGS="$OLD_CFLAGS"
+
+ 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'`])
+ ac_cv_$1_found=yes
+
+ else
+ AC_MSG_RESULT(no)
+ $PKG_CONFIG --errors-to-stdout --print-errors '$2'
+ ac_cv_$1_found=no
+ 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
+ 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
+])
+
+dnl SMB_INCLUDE_MK(file)
+AC_DEFUN([SMB_INCLUDE_MK],
+[
+SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
+mkinclude $1
+"
+])
+
+dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
+AC_DEFUN([SMB_EXT_LIB],
+[
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1_LIBS = $2
+$1_CFLAGS = $3
+$1_CPPFLAGS = $4
+$1_LDFLAGS = $5
+"
+
+])
+
+dnl SMB_ENABLE(name,default_build)
+AC_DEFUN([SMB_ENABLE],
+[
+ MAKE_SETTINGS="$MAKE_SETTINGS
+$1_ENABLE = $2
+"
+SMB_INFO_ENABLES="$SMB_INFO_ENABLES
+\$enabled{$1} = \"$2\";"
+])
+
+dnl SMB_WRITE_MAKEVARS(path, skip_vars)
+AC_DEFUN([SMB_WRITE_MAKEVARS],
+[
+echo "configure: creating $1"
+cat >$1<<CEOF
+# $1 - Autogenerated by configure, DO NOT EDIT!
+$MAKE_SETTINGS
+CEOF
+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
+])
+
+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
+])
+
+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 \
+ ${srcdir}/build/smb_build/main.pl --output=$1 main.mk || exit $?
+],
+[
+srcdir="$srcdir"
+builddir="$builddir"
+PERL="$PERL"
+
+export PERL
+export srcdir
+export builddir
+])
+])