URL: https://github.com/freeipa/freeipa/pull/364
Author: tiran
 Title: #364: Client-only builds with --disable-server
Action: opened

PR body:
"""
https://fedorahosted.org/freeipa/ticket/6517

Simple approach to reduce dependencies for client only builds. I simply wrapped 
all daemon, init and install dependencies in AM_COND_IF(). I'm open to 
suggestions. Let the bike shedding begin!
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/364/head:pr364
git checkout pr364
From cdb439792a27e24aaaa943d0ee5c2d9f83902a4a Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Tue, 3 Jan 2017 14:32:05 +0100
Subject: [PATCH] Client-only builds with --disable-server

https://fedorahosted.org/freeipa/ticket/6517
---
 Makefile.am  |   6 +-
 configure.ac | 298 ++++++++++++++++++++++++++++++++---------------------------
 2 files changed, 168 insertions(+), 136 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 73bd378..b7d013c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,11 @@
 ACLOCAL_AMFLAGS = -I m4
 
 IPACLIENT_SUBDIRS = ipaclient ipalib ipapython
-SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests po
+SUBDIRS = asn1 util client contrib $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests po
+
+if ENABLE_SERVER
+    SUBDIRS += daemons init install
+endif
 
 MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \
 		   ignore_import_errors.pyc ignore_import_errors.pyo \
diff --git a/configure.ac b/configure.ac
index e8a4701..d52f45f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,17 @@ LT_INIT
 
 AC_HEADER_STDC
 
+PKG_PROG_PKG_CONFIG
+
+AC_ARG_ENABLE([server],
+[  --disable-server        Disable server support],
+[case "${enableval}" in
+  yes) enable_server=true ;;
+  no)  enable_server=false ;;
+  *) AC_MSG_ERROR([bad value ${enableval} for --disable-server]) ;;
+esac],[enable_server=true])
+AM_CONDITIONAL([ENABLE_SERVER], [test x$enable_server = xtrue])
+
 AM_CONDITIONAL([HAVE_GCC], [test "$ac_cv_prog_gcc" = yes])
 
 dnl ---------------------------------------------------------------------------
@@ -36,34 +47,39 @@ dnl ---------------------------------------------------------------------------
 dnl - Check for DS slapi plugin
 dnl ---------------------------------------------------------------------------
 
-# Need to hack CPPFLAGS to be able to correctly detetct slapi-plugin.h
-SAVE_CPPFLAGS=$CPPFLAGS
-CPPFLAGS=$NSPR_CFLAGS
-AC_CHECK_HEADER(dirsrv/slapi-plugin.h)
-if test "x$ac_cv_header_dirsrv_slapi-plugin_h" = "xno" ; then
-	AC_MSG_ERROR([Required 389-ds header not available (389-ds-base-devel)])
-fi
-AC_CHECK_HEADER(dirsrv/repl-session-plugin.h)
-if test "x$ac_cv_header_dirsrv_repl_session_plugin_h" = "xno" ; then
-	AC_MSG_ERROR([Required 389-ds header not available (389-ds-base-devel)])
-fi
-CPPFLAGS=$SAVE_CPPFLAGS
-
-if test "x$ac_cv_header_dirsrv_slapi_plugin_h" = "xno" ; then
-	AC_MSG_ERROR([Required DS slapi plugin header not available (fedora-ds-base-devel)])
-fi
+AM_COND_IF([ENABLE_SERVER], [
+    # Need to hack CPPFLAGS to be able to correctly detetct slapi-plugin.h
+    SAVE_CPPFLAGS=$CPPFLAGS
+    CPPFLAGS=$NSPR_CFLAGS
+    AC_CHECK_HEADER(dirsrv/slapi-plugin.h)
+    if test "x$ac_cv_header_dirsrv_slapi-plugin_h" = "xno" ; then
+        AC_MSG_ERROR([Required 389-ds header not available (389-ds-base-devel)])
+    fi
+    AC_CHECK_HEADER(dirsrv/repl-session-plugin.h)
+    if test "x$ac_cv_header_dirsrv_repl_session_plugin_h" = "xno" ; then
+        AC_MSG_ERROR([Required 389-ds header not available (389-ds-base-devel)])
+    fi
+    CPPFLAGS=$SAVE_CPPFLAGS
+
+    if test "x$ac_cv_header_dirsrv_slapi_plugin_h" = "xno" ; then
+        AC_MSG_ERROR([Required DS slapi plugin header not available (fedora-ds-base-devel)])
+    fi
+])
 
 dnl ---------------------------------------------------------------------------
 dnl - Check for KRB5
 dnl ---------------------------------------------------------------------------
 
 PKG_CHECK_MODULES([KRB5], [krb5])
-AC_CHECK_HEADER(krad.h, [], [AC_MSG_ERROR([krad.h not found])])
-AC_CHECK_LIB(krad, main, [], [AC_MSG_ERROR([libkrad not found])])
-KRAD_LIBS="-lkrad"
-krb5rundir="${localstatedir}/run/krb5kdc"
-AC_SUBST(KRAD_LIBS)
-AC_SUBST(krb5rundir)
+
+AM_COND_IF([ENABLE_SERVER], [
+    AC_CHECK_HEADER(krad.h, [], [AC_MSG_ERROR([krad.h not found])])
+    AC_CHECK_LIB(krad, main, [], [AC_MSG_ERROR([libkrad not found])])
+    KRAD_LIBS="-lkrad"
+    krb5rundir="${localstatedir}/run/krb5kdc"
+    AC_SUBST(KRAD_LIBS)
+    AC_SUBST(krb5rundir)
+])
 
 dnl ---------------------------------------------------------------------------
 dnl - Check for OpenLDAP SDK
@@ -104,64 +120,69 @@ dnl ---------------------------------------------------------------------------
 dnl Check for ndr_krb5pac and other samba libraries
 dnl ---------------------------------------------------------------------------
 
-PKG_PROG_PKG_CONFIG()
-PKG_CHECK_MODULES([TALLOC], [talloc])
-PKG_CHECK_MODULES([TEVENT], [tevent])
-PKG_CHECK_MODULES([NDRPAC], [ndr_krb5pac])
-PKG_CHECK_MODULES([NDRNBT], [ndr_nbt])
-PKG_CHECK_MODULES([NDR], [ndr])
-PKG_CHECK_MODULES([SAMBAUTIL], [samba-util])
-SAMBA40EXTRA_LIBPATH="-L`$PKG_CONFIG --variable=libdir samba-util`/samba -Wl,-rpath=`$PKG_CONFIG --variable=libdir samba-util`/samba"
-AC_SUBST(SAMBA40EXTRA_LIBPATH)
-
-bck_cflags="$CFLAGS"
-CFLAGS="$NDRPAC_CFLAGS"
-AC_CHECK_MEMBER(
-    [struct PAC_DOMAIN_GROUP_MEMBERSHIP.domain_sid],
-    [AC_DEFINE([HAVE_STRUCT_PAC_DOMAIN_GROUP_MEMBERSHIP], [1],
-               [struct PAC_DOMAIN_GROUP_MEMBERSHIP is available.])],
-    [AC_MSG_NOTICE([struct PAC_DOMAIN_GROUP_MEMBERSHIP is not available])],
-                 [[#include <ndr.h>
-                   #include <gen_ndr/krb5pac.h>]])
-
-CFLAGS="$bck_cflags"
-
-LIBPDB_NAME=""
-AC_CHECK_LIB([samba-passdb],
-             [make_pdb_method],
-             [LIBPDB_NAME="samba-passdb"; HAVE_LIBPDB=1],
-             [LIBPDB_NAME="pdb"],
-             [$SAMBA40EXTRA_LIBPATH])
-
-if test "x$LIB_PDB_NAME" = "xpdb" ; then
-  AC_CHECK_LIB([$LIBPDB_NAME],
-               [make_pdb_method],
-               [HAVE_LIBPDB=1],
-               [AC_MSG_ERROR([Neither libpdb nor libsamba-passdb does have make_pdb_method])],
-               [$SAMBA40EXTRA_LIBPATH])
-fi
-
-AC_SUBST(LIBPDB_NAME)
-
-AC_CHECK_LIB([$LIBPDB_NAME],[pdb_enum_upn_suffixes],
-             [AC_DEFINE([HAVE_PDB_ENUM_UPN_SUFFIXES], [1], [Ability to enumerate UPN suffixes])],
-             [AC_MSG_WARN([libpdb does not have pdb_enum_upn_suffixes, no support for realm domains in ipasam])],
-             [$SAMBA40EXTRA_LIBPATH])
+AM_COND_IF([ENABLE_SERVER], [
+    PKG_CHECK_MODULES([TALLOC], [talloc])
+    PKG_CHECK_MODULES([TEVENT], [tevent])
+    PKG_CHECK_MODULES([NDRPAC], [ndr_krb5pac])
+    PKG_CHECK_MODULES([NDRNBT], [ndr_nbt])
+    PKG_CHECK_MODULES([NDR], [ndr])
+    PKG_CHECK_MODULES([SAMBAUTIL], [samba-util])
+    SAMBA40EXTRA_LIBPATH="-L`$PKG_CONFIG --variable=libdir samba-util`/samba -Wl,-rpath=`$PKG_CONFIG --variable=libdir samba-util`/samba"
+    AC_SUBST(SAMBA40EXTRA_LIBPATH)
+
+    bck_cflags="$CFLAGS"
+    CFLAGS="$NDRPAC_CFLAGS"
+    AC_CHECK_MEMBER(
+        [struct PAC_DOMAIN_GROUP_MEMBERSHIP.domain_sid],
+        [AC_DEFINE([HAVE_STRUCT_PAC_DOMAIN_GROUP_MEMBERSHIP], [1],
+                   [struct PAC_DOMAIN_GROUP_MEMBERSHIP is available.])],
+        [AC_MSG_NOTICE([struct PAC_DOMAIN_GROUP_MEMBERSHIP is not available])],
+                     [[#include <ndr.h>
+                       #include <gen_ndr/krb5pac.h>]])
+
+    CFLAGS="$bck_cflags"
+
+    LIBPDB_NAME=""
+    AC_CHECK_LIB([samba-passdb],
+                 [make_pdb_method],
+                 [LIBPDB_NAME="samba-passdb"; HAVE_LIBPDB=1],
+                 [LIBPDB_NAME="pdb"],
+                 [$SAMBA40EXTRA_LIBPATH])
+
+    if test "x$LIB_PDB_NAME" = "xpdb" ; then
+      AC_CHECK_LIB([$LIBPDB_NAME],
+                   [make_pdb_method],
+                   [HAVE_LIBPDB=1],
+                   [AC_MSG_ERROR([Neither libpdb nor libsamba-passdb does have make_pdb_method])],
+                   [$SAMBA40EXTRA_LIBPATH])
+    fi
+
+    AC_SUBST(LIBPDB_NAME)
+
+    AC_CHECK_LIB([$LIBPDB_NAME],[pdb_enum_upn_suffixes],
+                 [AC_DEFINE([HAVE_PDB_ENUM_UPN_SUFFIXES], [1], [Ability to enumerate UPN suffixes])],
+                 [AC_MSG_WARN([libpdb does not have pdb_enum_upn_suffixes, no support for realm domains in ipasam])],
+                 [$SAMBA40EXTRA_LIBPATH])
+])
 
 dnl ---------------------------------------------------------------------------
 dnl Check for libunistring
 dnl ---------------------------------------------------------------------------
-AC_CHECK_HEADERS([unicase.h],,AC_MSG_ERROR([Could not find unicase.h]))
-AC_CHECK_LIB([unistring],
-             [ulc_casecmp],
-             [UNISTRING_LIBS="-lunistring"],
-             [AC_MSG_ERROR([libunistring does not have ulc_casecmp])])
-AC_SUBST(UNISTRING_LIBS)
+AM_COND_IF([ENABLE_SERVER], [
+    AC_CHECK_HEADERS([unicase.h],,AC_MSG_ERROR([Could not find unicase.h]))
+    AC_CHECK_LIB([unistring],
+                 [ulc_casecmp],
+                 [UNISTRING_LIBS="-lunistring"],
+                 [AC_MSG_ERROR([libunistring does not have ulc_casecmp])])
+    AC_SUBST(UNISTRING_LIBS)
+])
 
 dnl ---------------------------------------------------------------------------
 dnl Check for libverto
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES([LIBVERTO], [libverto])
+AM_COND_IF([ENABLE_SERVER], [
+    PKG_CHECK_MODULES([LIBVERTO], [libverto])
+])
 
 dnl ---------------------------------------------------------------------------
 dnl - Check for cmocka unit test framework http://cmocka.cryptomilk.org/
@@ -249,20 +270,22 @@ PKG_CHECK_MODULES([INI], [ini_config >= 1.2.0])
 dnl ---------------------------------------------------------------------------
 dnl - Check for systemd directories
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_EXISTS([systemd], [], [AC_MSG_ERROR([systemd not found])])
-AC_ARG_WITH([systemdsystemunitdir],
-            AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
-			   [Directory for systemd service files]),
-            [systemdsystemunitdir=$with_systemdsystemunitdir],
-	    [systemdsystemunitdir=$($PKG_CONFIG --define-variable=prefix='${prefix}' --variable=systemdsystemunitdir systemd)])
-AC_SUBST([systemdsystemunitdir])
-
-AC_ARG_WITH([systemdtmpfilesdir],
-            AS_HELP_STRING([--with-systemdtmpfilesdir=DIR],
-			   [Directory for systemd-tmpfiles configuration files]),
-            [systemdtmpfilesdir=$with_systemdtmpfilesdir],
-	    [systemdtmpfilesdir=$($PKG_CONFIG --define-variable=prefix='${prefix}' --variable=tmpfilesdir systemd)])
-AC_SUBST([systemdtmpfilesdir])
+AM_COND_IF([ENABLE_SERVER], [
+    PKG_CHECK_EXISTS([systemd], [], [AC_MSG_ERROR([systemd not found])])
+    AC_ARG_WITH([systemdsystemunitdir],
+                AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
+                   [Directory for systemd service files]),
+                [systemdsystemunitdir=$with_systemdsystemunitdir],
+            [systemdsystemunitdir=$($PKG_CONFIG --define-variable=prefix='${prefix}' --variable=systemdsystemunitdir systemd)])
+    AC_SUBST([systemdsystemunitdir])
+
+    AC_ARG_WITH([systemdtmpfilesdir],
+                AS_HELP_STRING([--with-systemdtmpfilesdir=DIR],
+                   [Directory for systemd-tmpfiles configuration files]),
+                [systemdtmpfilesdir=$with_systemdtmpfilesdir],
+            [systemdtmpfilesdir=$($PKG_CONFIG --define-variable=prefix='${prefix}' --variable=tmpfilesdir systemd)])
+    AC_SUBST([systemdtmpfilesdir])
+])
 
 dnl ---------------------------------------------------------------------------
 dnl - Get /etc/sysconfig directory path
@@ -497,55 +520,6 @@ AC_CONFIG_FILES([
     client/man/Makefile
     contrib/completion/Makefile
     contrib/Makefile
-    daemons/dnssec/Makefile
-    daemons/Makefile
-    daemons/ipa-kdb/Makefile
-    daemons/ipa-sam/Makefile
-    daemons/ipa-otpd/Makefile
-    daemons/ipa-slapi-plugins/Makefile
-    daemons/ipa-slapi-plugins/libotp/Makefile
-    daemons/ipa-slapi-plugins/ipa-cldap/Makefile
-    daemons/ipa-slapi-plugins/ipa-dns/Makefile
-    daemons/ipa-slapi-plugins/ipa-enrollment/Makefile
-    daemons/ipa-slapi-plugins/ipa-lockout/Makefile
-    daemons/ipa-slapi-plugins/ipa-otp-counter/Makefile
-    daemons/ipa-slapi-plugins/ipa-otp-lasttoken/Makefile
-    daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile
-    daemons/ipa-slapi-plugins/ipa-extdom-extop/Makefile
-    daemons/ipa-slapi-plugins/ipa-winsync/Makefile
-    daemons/ipa-slapi-plugins/ipa-version/Makefile
-    daemons/ipa-slapi-plugins/ipa-uuid/Makefile
-    daemons/ipa-slapi-plugins/ipa-modrdn/Makefile
-    daemons/ipa-slapi-plugins/ipa-sidgen/Makefile
-    daemons/ipa-slapi-plugins/ipa-range-check/Makefile
-    daemons/ipa-slapi-plugins/topology/Makefile
-    init/systemd/Makefile
-    init/tmpfilesd/Makefile
-    init/Makefile
-    install/Makefile
-    install/certmonger/Makefile
-    install/conf/Makefile
-    install/html/Makefile
-    install/migration/Makefile
-    install/share/Makefile
-    install/share/advise/Makefile
-    install/share/advise/legacy/Makefile
-    install/share/profiles/Makefile
-    install/share/schema.d/Makefile
-    install/ui/Makefile
-    install/ui/css/Makefile
-    install/ui/src/Makefile
-    install/ui/src/libs/Makefile
-    install/ui/images/Makefile
-    install/ui/build/Makefile
-    install/ui/build/dojo/Makefile
-    install/ui/build/freeipa/Makefile
-    install/tools/Makefile
-    install/tools/man/Makefile
-    install/updates/Makefile
-    install/restart_scripts/Makefile
-    install/wsgi/Makefile
-    install/oddjob/Makefile
     ipaclient/Makefile
     ipalib/Makefile
     ipaplatform/Makefile
@@ -558,6 +532,60 @@ AC_CONFIG_FILES([
     util/Makefile
 ])
 
+AM_COND_IF([ENABLE_SERVER], [
+    AC_CONFIG_FILES([
+        daemons/dnssec/Makefile
+        daemons/Makefile
+        daemons/ipa-kdb/Makefile
+        daemons/ipa-sam/Makefile
+        daemons/ipa-otpd/Makefile
+        daemons/ipa-slapi-plugins/Makefile
+        daemons/ipa-slapi-plugins/libotp/Makefile
+        daemons/ipa-slapi-plugins/ipa-cldap/Makefile
+        daemons/ipa-slapi-plugins/ipa-dns/Makefile
+        daemons/ipa-slapi-plugins/ipa-enrollment/Makefile
+        daemons/ipa-slapi-plugins/ipa-lockout/Makefile
+        daemons/ipa-slapi-plugins/ipa-otp-counter/Makefile
+        daemons/ipa-slapi-plugins/ipa-otp-lasttoken/Makefile
+        daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile
+        daemons/ipa-slapi-plugins/ipa-extdom-extop/Makefile
+        daemons/ipa-slapi-plugins/ipa-winsync/Makefile
+        daemons/ipa-slapi-plugins/ipa-version/Makefile
+        daemons/ipa-slapi-plugins/ipa-uuid/Makefile
+        daemons/ipa-slapi-plugins/ipa-modrdn/Makefile
+        daemons/ipa-slapi-plugins/ipa-sidgen/Makefile
+        daemons/ipa-slapi-plugins/ipa-range-check/Makefile
+        daemons/ipa-slapi-plugins/topology/Makefile
+        init/systemd/Makefile
+        init/tmpfilesd/Makefile
+        init/Makefile
+        install/Makefile
+        install/certmonger/Makefile
+        install/conf/Makefile
+        install/html/Makefile
+        install/migration/Makefile
+        install/share/Makefile
+        install/share/advise/Makefile
+        install/share/advise/legacy/Makefile
+        install/share/profiles/Makefile
+        install/share/schema.d/Makefile
+        install/ui/Makefile
+        install/ui/css/Makefile
+        install/ui/src/Makefile
+        install/ui/src/libs/Makefile
+        install/ui/images/Makefile
+        install/ui/build/Makefile
+        install/ui/build/dojo/Makefile
+        install/ui/build/freeipa/Makefile
+        install/tools/Makefile
+        install/tools/man/Makefile
+        install/updates/Makefile
+        install/restart_scripts/Makefile
+        install/wsgi/Makefile
+        install/oddjob/Makefile
+    ])
+])
+
 AC_OUTPUT
 
 echo "
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to