modules: standardise on samba_init_module as the hook symbol to resolve
[amitay/samba.git] / source3 / m4 / aclocal.m4
index a79aba0f3fe16f21af4f7ce36c149b8b09b26b63..a4db42e5ca94eb7c6ee949bd6066e990b36d1dbb 100644 (file)
@@ -25,14 +25,14 @@ AC_DEFUN(SMB_MODULE,
        fi
        
        if test x"$DEST" = xSHARED; then
-               AC_DEFINE([$1][_init], [init_samba_module], [Whether to build $1 as shared module])
+               AC_DEFINE([$1][_init], [samba_init_module], [Whether to build $1 as shared module])
                $4_MODULES="$$4_MODULES $3"
                AC_MSG_RESULT([shared])
                [$6]
                string_shared_modules="$string_shared_modules $1"
        elif test x"$DEST" = xSTATIC; then
                [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z])  $1_init();"
-               [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(void);"
+               [decl_static_modules_]translit([$4], [A-Z], [a-z])="$[decl_static_modules_]translit([$4], [A-Z], [a-z]) extern NTSTATUS $1_init(void);"
                string_static_modules="$string_static_modules $1"
                $4_STATIC="$$4_STATIC $2"
                AC_SUBST($4_STATIC)
@@ -54,7 +54,7 @@ AC_DEFUN(SMB_SUBSYSTEM,
 ])
 
 
-dnl SMB_LIBRARY(name, version, default, reason)
+dnl SMB_LIBRARY(name, soversion, fullversion, default, reason)
 dnl
 dnl configure build and use of an (internal) shared library
 dnl
@@ -74,6 +74,10 @@ LIBUC[_TARGET]=
 [UNINSTALL_]LIBUC=
 
 m4_if([$2], [], [LIBUC[_SOVER]=0], [LIBUC[_SOVER]=$2])
+m4_if([$3], [], [LIBUC[_FULLVER]=$LIBUC[_SOVER]], [LIBUC[_FULLVER]=$3])
+
+LIBUC[_SHARED_TARGET_SOVER]=$LIBUC[_SHARED_TARGET].$LIBUC[_SOVER]
+LIBUC[_SHARED_TARGET_FULLVER]=$LIBUC[_SHARED_TARGET].$LIBUC[_FULLVER]
 
 AC_SUBST(LIBUC[_SHARED_TARGET])
 AC_SUBST(LIBUC[_STATIC_TARGET])
@@ -84,29 +88,32 @@ AC_SUBST(LIBUC[_TARGET])
 AC_SUBST([INSTALL_]LIBUC)
 AC_SUBST([UNINSTALL_]LIBUC)
 AC_SUBST(LIBUC[_SOVER])
+AC_SUBST(LIBUC[_FULLVER])
+AC_SUBST(LIBUC[_SHARED_TARGET_SOVER])
+AC_SUBST(LIBUC[_SHARED_TARGET_FULLVER])
 
 AC_MSG_CHECKING([whether to build the LIBNAME shared library])
-m4_if([$3], [no], [
+m4_if([$4], [no], [
 dnl set the default to not build the shared lib
 AC_ARG_WITH(LIBNAME,
 AS_HELP_STRING([--with-]LIBNAME,
-       m4_if([$4], [],
+       m4_if([$5], [],
                [Build the LIBNAME shared library (default=no)],
-               [Build the LIBNAME shared library (default=no ($4))])),
+               [Build the LIBNAME shared library (default=no ($5))])),
 [
 case "$withval" in
        yes)
                build_lib=yes
                ;;
        *)
-               AC_MSG_RESULT(yes)
+               AC_MSG_RESULT(no)
                build_lib=no
                ;;
 esac
 ],
 [
 # if unspecified, default is not to build
-AC_MSG_RESULT(yes)
+AC_MSG_RESULT(no)
 build_lib=no
 ]
 )
@@ -140,6 +147,7 @@ if eval test x"$build_lib" = "xyes" ; then
        if eval $BLDSHARED = true; then
                LIBUC[_SHARED]=$LIBUC[_SHARED_TARGET]
                LIBUC[_TARGET]=$LIBUC[_SHARED_TARGET]
+
                AC_MSG_RESULT(yes)
                if test x"$USESHARED" != x"true" -o x"$[LINK_]LIBUC" = "xSTATIC" ; then
                        enable_static=yes
@@ -151,6 +159,7 @@ if eval test x"$build_lib" = "xyes" ; then
        else
                enable_static=yes
                LIBUC[_TARGET]=$LIBUC[_STATIC_TARGET]
+               LIBUC[_LIBS]=$LIBUC[_STATIC_TARGET]
                AC_MSG_RESULT(no shared library support -- will supply static library)
        fi
 else
@@ -334,7 +343,7 @@ AC_DEFUN([AC_CHECK_FUNC_EXT],
            [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1])) $3], 
            [$4])dnl
 AS_VAR_POPDEF([ac_var])dnl
-])# AC_CHECK_FUNC
+])# AC_CHECK_FUNC_EXT
 
 # AH_CHECK_FUNC_EXT(FUNCNAME)
 # ---------------------
@@ -362,9 +371,9 @@ EOF
 
 dnl Copied from libtool.m4
 AC_DEFUN(AC_PROG_LD_GNU,
-[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[AC_CACHE_CHECK([if the linker used by compiler is GNU ld], ac_cv_prog_gnu_ld,
 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $CC -Wl,-v /dev/null 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
   ac_cv_prog_gnu_ld=yes
 else
   ac_cv_prog_gnu_ld=no
@@ -432,45 +441,47 @@ AC_DEFUN(jm_ICONV,
     jm_cv_giconv=no
     jm_save_LIBS="$LIBS"
 
-    dnl Check for include in funny place but no lib needed
-    if test "$jm_cv_func_iconv" != yes; then 
-      AC_TRY_LINK([#include <stdlib.h>
+  dnl Check for include in giconv.h but no lib needed
+  if test "$jm_cv_func_iconv" != yes; then
+    AC_TRY_LINK([#include <stdlib.h>
 #include <giconv.h>],
+      [iconv_t cd = iconv_open("","");
+       iconv(cd,NULL,NULL,NULL,NULL);
+       iconv_close(cd);],
+       jm_cv_func_iconv=yes
+       jm_cv_include="giconv.h"
+       jm_cv_giconv="yes"
+       jm_cv_lib_iconv="")
+
+    dnl Standard iconv.h include, lib in glibc or libc ...
+    if test "$jm_cv_func_iconv" != yes; then
+      AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
         [iconv_t cd = iconv_open("","");
          iconv(cd,NULL,NULL,NULL,NULL);
          iconv_close(cd);],
+         jm_cv_include="iconv.h"
          jm_cv_func_iconv=yes
-         jm_cv_include="giconv.h"
-         jm_cv_giconv="yes"
          jm_cv_lib_iconv="")
 
-      dnl Standard iconv.h include, lib in glibc or libc ...
+      dnl Include in giconv.h, libgiconv needed to link
       if test "$jm_cv_func_iconv" != yes; then
+        jm_save_LIBS="$LIBS"
+        LIBS="$LIBS -lgiconv"
         AC_TRY_LINK([#include <stdlib.h>
-#include <iconv.h>],
+#include <giconv.h>],
           [iconv_t cd = iconv_open("","");
            iconv(cd,NULL,NULL,NULL,NULL);
            iconv_close(cd);],
-           jm_cv_include="iconv.h"
-           jm_cv_func_iconv=yes
-           jm_cv_lib_iconv="")
-
-          if test "$jm_cv_lib_iconv" != yes; then
-            jm_save_LIBS="$LIBS"
-            LIBS="$LIBS -lgiconv"
-            AC_TRY_LINK([#include <stdlib.h>
-#include <giconv.h>],
-              [iconv_t cd = iconv_open("","");
-               iconv(cd,NULL,NULL,NULL,NULL);
-               iconv_close(cd);],
-              jm_cv_lib_iconv=yes
-              jm_cv_func_iconv=yes
-              jm_cv_include="giconv.h"
-              jm_cv_giconv=yes
-              jm_cv_lib_iconv="giconv")
+          jm_cv_lib_iconv=yes
+          jm_cv_func_iconv=yes
+          jm_cv_include="giconv.h"
+          jm_cv_giconv=yes
+          jm_cv_lib_iconv="giconv")
 
-           LIBS="$jm_save_LIBS"
+        LIBS="$jm_save_LIBS"
 
+        dnl Include in iconv.h, libiconv needed to link
         if test "$jm_cv_func_iconv" != yes; then
           jm_save_LIBS="$LIBS"
           LIBS="$LIBS -liconv"
@@ -484,7 +495,8 @@ AC_DEFUN(jm_ICONV,
             jm_cv_lib_iconv="iconv")
           LIBS="$jm_save_LIBS"
 
-          if test "$jm_cv_lib_iconv" != yes; then
+          dnl Include in biconv.h, libbiconv needed to link
+          if test "$jm_cv_func_iconv" != yes; then
             jm_save_LIBS="$LIBS"
             LIBS="$LIBS -lbiconv"
             AC_TRY_LINK([#include <stdlib.h>
@@ -499,7 +511,7 @@ AC_DEFUN(jm_ICONV,
               jm_cv_lib_iconv="biconv")
 
             LIBS="$jm_save_LIBS"
-         fi
+          fi
         fi
       fi
     fi
@@ -605,6 +617,19 @@ AC_DEFUN([AC_DISABLE_STATIC],
 [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
 AC_ENABLE_STATIC(no)])
 
+dnl AC_TRY_COMMAND_NO_STDERR - also fail if there is output on stderr
+AC_DEFUN( [AC_TRY_COMMAND_NO_STDERR],
+[
+       { OUT=`($1) 3>&AS_MESSAGE_LOG_FD 2>&1 1>&3`
+       RC=$?
+       echo "\$?=$RC" >&AS_MESSAGE_LOG_FD
+       if test x"$OUT" != x ; then
+               echo "stderr:" >&AS_MESSAGE_LOG_FD
+               echo "$OUT" >&AS_MESSAGE_LOG_FD
+       fi
+       test $RC -eq 0 -a x"$OUT" = x ; }
+])
+
 dnl AC_TRY_RUN_STRICT(PROGRAM,CFLAGS,CPPFLAGS,LDFLAGS,
 dnl            [ACTION-IF-TRUE],[ACTION-IF-FALSE],
 dnl            [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])
@@ -693,13 +718,13 @@ AC_DEFUN([SMB_CHECK_DMAPI],
     fi
 
     if test x"$samba_dmapi_libs" = x"" ; then
-       AC_CHECK_LIB(xdsm, dm_get_eventlist,
-               [samba_dmapi_libs="-lxdsm"], [])
+        AC_CHECK_LIB(dmapi, dm_get_eventlist,
+                [samba_dmapi_libs="-ldmapi"], [])
     fi
 
     if test x"$samba_dmapi_libs" = x"" ; then
-        AC_CHECK_LIB(dmapi, dm_get_eventlist,
-                [samba_dmapi_libs="-ldmapi"], [])
+       AC_CHECK_LIB(xdsm, dm_get_eventlist,
+               [samba_dmapi_libs="-lxdsm"], [])
     fi
 
 
@@ -774,37 +799,6 @@ AC_DEFUN([SMB_CHECK_DMAPI],
 
 ])
 
-dnl SMB_CHECK_CLOCK_ID(clockid)
-dnl Test whether the specified clock_gettime clock ID is available. If it
-dnl is, we define HAVE_clockid
-AC_DEFUN([SMB_CHECK_CLOCK_ID],
-[
-    AC_MSG_CHECKING(for $1)
-    AC_TRY_LINK([
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-    ],
-    [
-clockid_t clk = $1;
-    ],
-    [
-       AC_MSG_RESULT(yes)
-       AC_DEFINE(HAVE_$1, 1,
-           [Whether the clock_gettime clock ID $1 is available])
-    ],
-    [
-       AC_MSG_RESULT(no)
-    ])
-])
-
 dnl SMB_IF_RTSIGNAL_BUG([actions if true],
 dnl                    [actions if false],
 dnl                    [actions if cross compiling])
@@ -827,6 +821,9 @@ AC_DEFUN([SMB_IF_RTSIGNAL_BUG],
 #include <fcntl.h>
 #include <signal.h>
 
+#ifndef SIGRTMIN
+#define SIGRTMIN NSIG
+#endif
 /* from smbd/notify_kernel.c */
 #ifndef RT_SIGNAL_NOTIFY
 #define RT_SIGNAL_NOTIFY (SIGRTMIN+2)
@@ -899,4 +896,3 @@ int main(void)
 ])
 
 m4_include(../lib/replace/libreplace.m4)
-AC_CHECK_FUNCS([syslog],,[AC_MSG_ERROR([Required function not found])])