URL: https://github.com/freeipa/freeipa/pull/155
Author: pspacek
 Title: #155: Build system cleanup
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/155/head:pr155
git checkout pr155
From e641d9cf9b9e596bd335f89080eaf79d019fee73 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 10:52:43 +0200
Subject: [PATCH 1/7] Build: add missing KRB5_LIBS to daemons/ipa-otpd

It was working accidentally because krb5 libs are part of OPENLDAP_LIBS.
---
 daemons/ipa-otpd/Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/daemons/ipa-otpd/Makefile.am b/daemons/ipa-otpd/Makefile.am
index 8392174..946b882 100644
--- a/daemons/ipa-otpd/Makefile.am
+++ b/daemons/ipa-otpd/Makefile.am
@@ -1,5 +1,5 @@
-AM_CFLAGS := @LDAP_CFLAGS@ @LIBVERTO_CFLAGS@
-AM_LDFLAGS := @LDAP_LIBS@ @LIBVERTO_LIBS@ @KRAD_LIBS@
+AM_CFLAGS := @LDAP_CFLAGS@ @LIBVERTO_CFLAGS@ @KRB5_CFLAGS@
+AM_LDFLAGS := @LDAP_LIBS@ @LIBVERTO_LIBS@ @KRAD_LIBS@ @KRB5_LIBS@
 
 noinst_HEADERS = internal.h
 libexec_PROGRAMS = ipa-otpd

From f6feb2765f66ad3cf64849a2b508229e2802c23b Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 10:57:57 +0200
Subject: [PATCH 2/7] Build: modernize Kerberos library detection

Use package config instead of checking headers.
Package config is faster because it does not invoke compiler
and guarantees proper linking flags because these are provided
by package maintainer instead of hardcoded into build system.

libkrad does not have package config file so we keep the old way here.
---
 daemons/configure.ac | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/daemons/configure.ac b/daemons/configure.ac
index 5c5a104..1d0209d 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -54,15 +54,11 @@ dnl ---------------------------------------------------------------------------
 dnl - Check for KRB5
 dnl ---------------------------------------------------------------------------
 
-AC_CHECK_HEADER(krb5.h, [], [AC_MSG_ERROR([krb5.h not found])])
+PKG_CHECK_MODULES([KRB5], [krb5], [], [AC_MSG_ERROR([libkrb5 not found])])
 AC_CHECK_HEADER(krad.h, [], [AC_MSG_ERROR([krad.h not found])])
-AC_CHECK_LIB(krb5, main, [], [AC_MSG_ERROR([libkrb5 not found])])
-AC_CHECK_LIB(k5crypto, main, [krb5crypto=k5crypto], [krb5crypto=crypto])
 AC_CHECK_LIB(krad, main, [], [AC_MSG_ERROR([libkrad not found])])
-KRB5_LIBS="-lkrb5 -l$krb5crypto -lcom_err"
 KRAD_LIBS="-lkrad"
 krb5rundir="${localstatedir}/run/krb5kdc"
-AC_SUBST(KRB5_LIBS)
 AC_SUBST(KRAD_LIBS)
 AC_SUBST(krb5rundir)
 

From 2d7bb09e5a161cba81881b9be375b801bb280d48 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 10:58:22 +0200
Subject: [PATCH 3/7] Build: modernize UUID library detection

Use package config instead of checking headers.
Package config is faster because it does not invoke compiler
and guarantees proper linking flags because these are provided
by package maintainer instead of hardcoded into build system.
---
 daemons/configure.ac | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/daemons/configure.ac b/daemons/configure.ac
index 1d0209d..34773f9 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -135,10 +135,7 @@ AC_SUBST(SSL_LIBS)
 dnl ---------------------------------------------------------------------------
 dnl - Check for UUID library
 dnl ---------------------------------------------------------------------------
-AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([uuid/uuid.h not found])])
-
-AC_CHECK_LIB(uuid, uuid_generate_time, [UUID_LIBS="-luuid"])
-AC_SUBST(UUID_LIBS)
+PKG_CHECK_MODULES([UUID], [uuid], [], [AC_MSG_ERROR([libuuid not found])])
 
 dnl ---------------------------------------------------------------------------
 dnl - Check for Python

From 2855f61fda02c9ba00d1ebcbfd1c1cb7b1e5a3f0 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 11:01:02 +0200
Subject: [PATCH 4/7] Build: modernize crypto library detection

Use package config instead of checking headers.
Package config is faster because it does not invoke compiler
and guarantees proper linking flags because these are provided
by package maintainer instead of hardcoded into build system.
---
 daemons/configure.ac                                | 9 ++-------
 daemons/ipa-sam/Makefile.am                         | 3 ++-
 daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am | 4 ++--
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/daemons/configure.ac b/daemons/configure.ac
index 34773f9..958f01c 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -125,12 +125,7 @@ AC_SUBST(LDAP_LIBS)
 dnl ---------------------------------------------------------------------------
 dnl - Check for OpenSSL Crypto library
 dnl ---------------------------------------------------------------------------
-dnl This is a very simple check, we should probably check also for MD4_Init and
-dnl probably also the version we are using is recent enough
-SSL_LIBS=
-AC_CHECK_HEADER(openssl/md4.h, [], [AC_MSG_ERROR([openssl/md4.h not found])])
-AC_CHECK_LIB(crypto, MD4_Init, [SSL_LIBS="-lcrypto"])
-AC_SUBST(SSL_LIBS)
+PKG_CHECK_MODULES([CRYPTO], [libcrypto], [], [AC_MSG_ERROR([libcrypto not found])])
 
 dnl ---------------------------------------------------------------------------
 dnl - Check for UUID library
@@ -381,6 +376,6 @@ echo "
         LDAP libs:                ${LDAP_LIBS}
         KRB5 libs:                ${KRB5_LIBS}
         KRAD libs:                ${KRAD_LIBS}
-        OpenSSL libs:             ${SSL_LIBS}
+        OpenSSL crypto libs:      ${CRYPTO_LIBS}
         Maintainer mode:          ${USE_MAINTAINER_MODE}
 "
diff --git a/daemons/ipa-sam/Makefile.am b/daemons/ipa-sam/Makefile.am
index ea14661..c321493 100644
--- a/daemons/ipa-sam/Makefile.am
+++ b/daemons/ipa-sam/Makefile.am
@@ -23,6 +23,7 @@ AM_CPPFLAGS =						\
 	-DLDAPIDIR=\""$(localstatedir)/run"\"		\
 	-DHAVE_LDAP					\
 	-I $(KRB5_UTIL_DIR)				\
+	$(CRYPTO_CFLAGS)				\
 	$(LDAP_CFLAGS)					\
 	$(KRB5_CFLAGS)					\
 	$(WARN_CFLAGS)					\
@@ -48,10 +49,10 @@ ipasam_la_LDFLAGS = 		\
 	$(NULL)
 
 ipasam_la_LIBADD = 		\
+	$(CRYPTO_LIBS)		\
 	$(LDAP_LIBS)		\
 	$(KRB5_LIBS)		\
 	$(TALLOC_LIBS)		\
-	$(SSL_LIBS)		\
 	$(SAMBAUTIL_LIBS)	\
 	$(NDR_LIBS)		\
 	$(SAMBA40EXTRA_LIBS)	\
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
index 46a6491..048e8bd 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
@@ -19,16 +19,16 @@ AM_CPPFLAGS =							\
 	-DLIBDIR=\""$(libdir)"\" 				\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
+	$(CRYPTO_CFLAGS)					\
 	$(LDAP_CFLAGS)					\
 	$(KRB5_CFLAGS)						\
-	$(SSL_CFLAGS)						\
 	$(NSS_CFLAGS)						\
 	$(WARN_CFLAGS)						\
 	$(NULL)
 
 AM_LDFLAGS = \
+	$(CRYPTO_LIBS)	\
 	$(KRB5_LIBS)	\
-	$(SSL_LIBS)	\
 	$(LDAP_LIBS)	\
 	$(NSPR_LIBS)	\
 	$(NSS_LIBS)	\

From 46f71e71df882371f94d9f7dd2e204acef3f7f79 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 11:05:23 +0200
Subject: [PATCH 5/7] Build: remove traces of mozldap library

Mozldap is not used for some time now. We can remove
all traces of it.

AFAIK the complex logic for OpenLDAP detection should not be
necessary and -lldap_r -llber options should suffice.

Unfortunatelly OpenLDAP package does not ship
package config files so we have to hardcode flags.
---
 daemons/configure.ac                               | 59 +++-------------------
 .../ipa-slapi-plugins/ipa-pwd-extop/Makefile.am    |  2 +-
 2 files changed, 7 insertions(+), 54 deletions(-)

diff --git a/daemons/configure.ac b/daemons/configure.ac
index 958f01c..4d78a52 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -63,64 +63,17 @@ AC_SUBST(KRAD_LIBS)
 AC_SUBST(krb5rundir)
 
 dnl ---------------------------------------------------------------------------
-dnl - Check for Mozilla LDAP and OpenLDAP SDK
+dnl - Check for OpenLDAP SDK
 dnl ---------------------------------------------------------------------------
 
 SAVE_CPPFLAGS=$CPPFLAGS
 CPPFLAGS="$NSPR_CFLAGS $NSS_CFLAGS"
-AC_CHECK_HEADER(svrcore.h)
-AC_CHECK_HEADER(svrcore/svrcore.h)
-if test "x$ac_cv_header_svrcore_h" = "xno" && test "x$ac_cv_header_svrcore_svrcore_h" = "xno" ; then
-	AC_MSG_ERROR([Required svrcore header not available (svrcore-devel)])
-fi
-if test "x$ac_cv_header_svrcore_svrcore_h" = "yes" ; then
-	CPPFLAGS="$CPPFLAGS -I/usr/include/svrcore"
-fi
-
-AC_CHECK_LIB(ldap, ldap_search, with_ldap=yes)
-dnl Check for other libraries we need to link with to get the main routines.
-test "$with_ldap" != "yes" && { AC_CHECK_LIB(ldap, ldap_open, [with_ldap=yes with_ldap_lber=yes], , -llber) }
-test "$with_ldap" != "yes" && { AC_CHECK_LIB(ldap, ldap_open, [with_ldap=yes with_ldap_lber=yes with_ldap_krb=yes], , -llber -lkrb) }
-test "$with_ldap" != "yes" && { AC_CHECK_LIB(ldap, ldap_open, [with_ldap=yes with_ldap_lber=yes with_ldap_krb=yes with_ldap_des=yes], , -llber -lkrb -ldes) }
-dnl Recently, we need -lber even though the main routines are elsewhere,
-dnl because otherwise be get link errors w.r.t. ber_pvt_opt_on.  So just
-dnl check for that (it's a variable not a fun but that doesn't seem to
-dnl matter in these checks)  and stick in -lber if so.  Can't hurt (even to
-dnl stick it in always shouldn't hurt, I don't think) ... #### Someone who
-dnl #### understands LDAP needs to fix this properly.
-test "$with_ldap_lber" != "yes" && { AC_CHECK_LIB(lber, ber_pvt_opt_on, with_ldap_lber=yes) }
-
-if test "$with_ldap" = "yes"; then
-  if test "$with_ldap_des" = "yes" ; then
-    OPENLDAP_LIBS="${OPENLDAP_LIBS} -ldes"
-  fi
-  if test "$with_ldap_krb" = "yes" ; then
-    OPENLDAP_LIBS="${OPENLDAP_LIBS} -lkrb"
-  fi
-  if test "$with_ldap_lber" = "yes" ; then
-    OPENLDAP_LIBS="${OPENLDAP_LIBS} -llber"
-  fi
-  OPENLDAP_LIBS="${OPENLDAP_LIBS} -lldap_r"
-else
-  AC_MSG_ERROR([OpenLDAP not found])
-fi
-
-AC_SUBST(OPENLDAP_LIBS)
-
-OPENLDAP_CFLAGS="${OPENLDAP_CFLAGS} -DWITH_OPENLDAP"
-AC_SUBST(OPENLDAP_CFLAGS)
-
-AC_ARG_WITH([openldap],
-            [AS_HELP_STRING([--with-openldap],
-                            [compile plugins with openldap instead of mozldap])],
-            [], [])
-
-LDAP_CFLAGS="${OPENLDAP_CFLAGS} $NSPR_CFLAGS $NSS_CFLAGS -DUSE_OPENLDAP"
-LDAP_LIBS="${OPENLDAP_LIBS}"
-AC_DEFINE_UNQUOTED(WITH_OPENLDAP, 1, [Use OpenLDAP libraries])
-
-AC_SUBST(LDAP_CFLAGS)
+AC_CHECK_LIB([ldap_r], [ldap_search], [], AC_MSG_ERROR([libldap_r not found]))
+AC_CHECK_LIB([lber], [ber_peek_tag], [], AC_MSG_ERROR([liblber not found]))
+LDAP_LIBS="-lldap_r -llber"
+LDAP_CFLAGS=""
 AC_SUBST(LDAP_LIBS)
+AC_SUBST(LDAP_CFLAGS)
 
 dnl ---------------------------------------------------------------------------
 dnl - Check for OpenSSL Crypto library
diff --git a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
index 048e8bd..de61509 100644
--- a/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
+++ b/daemons/ipa-slapi-plugins/ipa-pwd-extop/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS =							\
 	-DLIBEXECDIR=\""$(libexecdir)"\"			\
 	-DDATADIR=\""$(datadir)"\"				\
 	$(CRYPTO_CFLAGS)					\
-	$(LDAP_CFLAGS)					\
+	$(LDAP_CFLAGS)						\
 	$(KRB5_CFLAGS)						\
 	$(NSS_CFLAGS)						\
 	$(WARN_CFLAGS)						\

From 2d719a478b3fa142746f0feed57b4d0a31fd522a Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 11:06:21 +0200
Subject: [PATCH 6/7] Build: require Python >= 2.7

The Python detection logic will be improved later when we start to use
top-level configure.ac to manage build completely. For now simple bump
is enough.
---
 daemons/configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemons/configure.ac b/daemons/configure.ac
index 4d78a52..36bf943 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -91,7 +91,7 @@ dnl ---------------------------------------------------------------------------
 
 AC_MSG_NOTICE([Checking for Python])
 have_python=no
-AM_PATH_PYTHON(2.3)
+AM_PATH_PYTHON(2.7)
 
 if test "x$PYTHON" = "x" ; then
   AC_MSG_ERROR([Python not found])

From 9e8201b9e2d5754a692b294e7dbe409a9d25c5ca Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 12 Oct 2016 13:06:58 +0200
Subject: [PATCH 7/7] Build: remove deprecated AC_STDC_HEADERS macro

Interestingly, the new macro AC_HEADER_STDC is alredy present.
---
 daemons/configure.ac | 1 -
 1 file changed, 1 deletion(-)

diff --git a/daemons/configure.ac b/daemons/configure.ac
index 36bf943..136a915 100644
--- a/daemons/configure.ac
+++ b/daemons/configure.ac
@@ -12,7 +12,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
 
 AM_MAINTAINER_MODE
 AC_PROG_CC_C99
-AC_STDC_HEADERS
 AC_DISABLE_STATIC
 LT_INIT
 
-- 
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