s3:build: first cut at fixing linking of shared/static libs internally
[ira/wip.git] / source3 / m4 / aclocal.m4
index 888c49db37505f67600bba8fd6ececec120c55b9..5a07eddb942c2c4b474d7d355a37ce3b6f6c21d5 100644 (file)
@@ -25,7 +25,7 @@ AC_DEFUN(SMB_MODULE,
        fi
        
        if test x"$DEST" = xSHARED; then
-               AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module])
+               AC_DEFINE([$1][_init], [init_samba_module], [Whether to build $1 as shared module])
                $4_MODULES="$$4_MODULES $3"
                AC_MSG_RESULT([shared])
                [$6]
@@ -54,7 +54,7 @@ AC_DEFUN(SMB_SUBSYSTEM,
 ])
 
 
-dnl SMB_LIBRARY(name)
+dnl SMB_LIBRARY(name, version, default, reason)
 dnl
 dnl configure build and use of an (internal) shared library
 dnl
@@ -68,25 +68,60 @@ LIBUC[_SHARED_TARGET]=bin/LIBNAME.$SHLIBEXT
 LIBUC[_STATIC_TARGET]=bin/LIBNAME.a
 LIBUC[_SHARED]=
 LIBUC[_STATIC]=
-LIBUC[_LIBS]=
+LIBUC[_LIBS]=LIBLIBS
+LIBUC[_TARGET]=
+[INSTALL_]LIBUC=
+[UNINSTALL_]LIBUC=
+
+m4_if([$2], [], [LIBUC[_SOVER]=0], [LIBUC[_SOVER]=$2])
 
 AC_SUBST(LIBUC[_SHARED_TARGET])
 AC_SUBST(LIBUC[_STATIC_TARGET])
 AC_SUBST(LIBUC[_SHARED])
 AC_SUBST(LIBUC[_STATIC])
 AC_SUBST(LIBUC[_LIBS])
+AC_SUBST(LIBUC[_TARGET])
+AC_SUBST([INSTALL_]LIBUC)
+AC_SUBST([UNINSTALL_]LIBUC)
+AC_SUBST(LIBUC[_SOVER])
 
 AC_MSG_CHECKING([whether to build the LIBNAME shared library])
+m4_if([$3], [no], [
+dnl set the default to not build the shared lib
 AC_ARG_WITH(LIBNAME,
-[AS_HELP_STRING([--with-LIBNAME],
-       [Build the LIBNAME shared library (default=yes if shared libs supported)])],
+AS_HELP_STRING([--with-]LIBNAME,
+       m4_if([$4], [],
+               [Build the LIBNAME shared library (default=no)],
+               [Build the LIBNAME shared library (default=no ($4))])),
 [
 case "$withval" in
+       yes)
+               build_lib=yes
+               ;;
        *)
+               AC_MSG_RESULT(yes)
+               build_lib=no
+               ;;
+esac
+],
+[
+# if unspecified, default is not to build
+AC_MSG_RESULT(yes)
+build_lib=no
+]
+)
+],[
+dnl by default, try to build the shared lib
+AC_ARG_WITH(LIBNAME,
+AS_HELP_STRING([--with-]LIBNAME,
+       [Build the LIBNAME shared library (default=yes if shared libs supported)]),
+[
+case "$withval" in
+       no)
                AC_MSG_RESULT(no)
                build_lib=no
                ;;
-       yes)
+       *)
                build_lib=yes
                ;;
 esac
@@ -96,21 +131,34 @@ esac
 build_lib=yes
 ]
 )
+])
 
-if eval test x"$build_lib" = "xyes" -a $BLDSHARED = true; then
-       LIBUC[_SHARED]=$LIBUC[_SHARED_TARGET]
-       AC_MSG_RESULT(yes)
-       if test x"$USESHARED" != x"true" -o x"$LINK_LIBUC" = "xSTATIC" ; then
-               LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET]
+if eval test x"$build_lib" = "xyes" ; then
+       # only set the install targets if the user chose the library
+       [INSTALL_]LIBUC=[install]LIBNAME
+       [UNINSTALL_]LIBUC=[uninstall]LIBNAME
+       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
+                       LIBUC[_TARGET]=$LIBUC[_STATIC_TARGET]
+                       LIBUC[_LIBS]=$LIBUC[_STATIC_TARGET]
+               else
+                       LIBUC[_LIBS]=LIBLIBS
+               fi
        else
-               LIBUC[_LIBS]=LIBLIBS
+               enable_static=yes
+               LIBUC[_TARGET]=$LIBUC[_STATIC_TARGET]
+               AC_MSG_RESULT(no shared library support -- will supply static library)
        fi
 else
        enable_static=yes
-       AC_MSG_RESULT(no shared library support -- will supply static library)
+       AC_MSG_RESULT(shared library not selected, but will supply static library)
 fi
 if test $enable_static = yes; then
-       LIBUC[_STATIC]=$LIBUC[_STATIC_TARGET]
+       LIBUC[_STATIC]=[\$\(]LIBUC[_OBJ0\)]
 fi
 
 m4_popdef([LIBNAME])
@@ -344,11 +392,17 @@ AC_DEFUN(LIB_REMOVE_USR_LIB,[
     case [$]l[$]i in
     -L/usr/lib) ;;
     -L/usr/lib/) ;;
-    -Wl,-rpath,/usr/lib) ;;
-    -Wl,-rpath,/usr/lib/) ;;
+    -L/usr/lib64) ;;
+    -L/usr/lib64/) ;;
+    -Wl,-rpath,/usr/lib) l="";;
+    -Wl,-rpath,/usr/lib/) l="";;
+    -Wl,-rpath,/usr/lib64) l="";;
+    -Wl,-rpath,/usr/lib64/) l="";;
     -Wl,-rpath) l=[$]i;;
     -Wl,-rpath-Wl,/usr/lib) l="";;
     -Wl,-rpath-Wl,/usr/lib/) l="";;
+    -Wl,-rpath-Wl,/usr/lib64) l="";;
+    -Wl,-rpath-Wl,/usr/lib64/) l="";;
     *)
        s=" "
         if test x"[$]ac_new_flags" = x""; then
@@ -844,4 +898,4 @@ int main(void)
        ])
 ])
 
-m4_include(lib/replace/libreplace.m4)
+m4_include(../lib/replace/libreplace.m4)