From 84c184f0158ef25f411bac96a505591a01e204b0 Mon Sep 17 00:00:00 2001
From: William Brown <firstyear@redhat.com>
Date: Mon, 10 Apr 2017 15:06:34 +1000
Subject: [PATCH] Ticket 49119 - Cleanup configure.ac options and defines

Bug Description:  We have a lot of legacy in files like configure.ac.
We have options that we default to that aren't set correctly, options
we never use now, and more.

Fix Description:  Clean up some of these options. Remove defines
and substitutions that were never used. Cleanup some headers to
standardise their use of certain defines.

https://pagure.io/389-ds-base/issue/49119

Author: wibrown

Review by: ???
---
 Makefile.am                   | 78 -------------------------------------------
 configure.ac                  | 77 ++----------------------------------------
 include/base/systems.h        |  2 +-
 include/public/base/systems.h |  2 +-
 ldap/include/portable.h       |  8 ++---
 ldap/servers/slapd/main.c     |  8 -----
 lib/base/dnsdmain.cpp         |  4 +--
 lib/base/systhr.cpp           |  2 +-
 m4/db.m4                      |  9 +++++
 m4/icu.m4                     |  6 ++++
 m4/netsnmp.m4                 |  6 ++++
 m4/nspr.m4                    |  5 +++
 m4/nss.m4                     |  5 +++
 m4/openldap.m4                | 12 +++++++
 m4/svrcore.m4                 |  3 ++
 m4/systemd.m4                 |  6 ++++
 rpm/389-ds-base.spec.in       | 64 +++--------------------------------
 17 files changed, 68 insertions(+), 229 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 70d7160..057da52 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2061,83 +2061,6 @@ endif
 # LD_LIBRARY_PATH = ${prefix}/lib/dirsrv
 # i.e. it literally copies in '${prefix}' rather than expanding it out - we want this instead:
 # LD_LIBRARY_PATH = /usr/lib/dirsrv
-if BUNDLE
-# on the systems on which we bundle, perldap will be in libdir/perl, so we need to point
-# the perlpath there - on other systems, perldap will be installed as a site module into
-# the system perl
-fixupcmd = sed \
-	-e 's,@bindir\@,$(bindir),g' \
-	-e 's,@sbindir\@,$(sbindir),g' \
-	-e 's,@libdir\@,$(libdir),g' \
-	-e 's,@nspr_libdir\@,$(libdir),g' \
-	-e 's,@nss_libdir\@,$(libdir),g' \
-	-e 's,@ldapsdk_libdir\@,$(libdir),g' \
-	-e 's,@ldapsdk_bindir\@,$(bindir),g' \
-	-e 's,@ldaptool_bindir\@,$(bindir),g' \
-	-e 's,@ldaptool_opts\@,$(ldaptool_opts),g' \
-	-e 's,@plainldif_opts\@,$(plainldif_opts),g' \
-	-e 's,@db_libdir\@,$(libdir),g' \
-	-e 's,@db_bindir\@,$(bindir),g' \
-	-e 's,@sasl_libdir\@,$(libdir),g' \
-	-e 's,@sasl_path\@,$(libdir)/sasl2,g' \
-	-e 's,@netsnmp_libdir\@,$(libdir),g' \
-	-e 's,@pcre_libdir\@,$(libdir),g' \
-	-e 's,@propertydir\@,$(propertydir),g' \
-	-e 's,@datadir\@,$(datadir),g' \
-	-e 's,@schemadir\@,$(schemadir),g' \
-	-e 's,@serverdir\@,$(serverdir),g' \
-	-e 's,@serverincdir\@,$(serverincdir),g' \
-	-e 's,@serverplugindir\@,$(serverplugindir),g' \
-	-e 's,@taskdir\@,$(taskdir),g' \
-	-e 's,@configdir\@,$(configdir),g' \
-	-e 's,@sysconfdir\@,$(sysconfdir),g' \
-	-e 's,@localrundir\@,$(localrundir),g' \
-	-e 's,@localstatedir\@,$(localstatedir),g' \
-	-e 's,@infdir\@,$(infdir),g' \
-	-e 's,@mibdir\@,$(mibdir),g' \
-	-e 's,@templatedir\@,$(sampledatadir),g' \
-	-e 's,@systemschemadir\@,$(systemschemadir),g' \
-	-e 's,@package_name\@,$(PACKAGE_NAME),g' \
-	-e 's,@instconfigdir\@,$(instconfigdir),g' \
-	-e 's,@enable_ldapi\@,$(enable_ldapi),g' \
-	-e 's,@enable_pam_passthru\@,$(enable_pam_passthru),g' \
-	-e 's,@enable_bitwise\@,$(enable_bitwise),g' \
-	-e 's,@enable_dna\@,$(enable_dna),g' \
-	-e 's,@enable_autobind\@,$(enable_autobind),g' \
-	-e 's,@enable_auto_dn_suffix\@,$(enable_auto_dn_suffix),g' \
-	-e 's,@enable_presence\@,$(enable_presence),g' \
-	-e 's,@enable_asan\@,$(ASAN_ON),g' \
-	-e 's,@ECHO_N\@,$(ECHO_N),g' \
-	-e 's,@ECHO_C\@,$(ECHO_C),g' \
-	-e 's,@brand\@,$(brand),g' \
-	-e 's,@capbrand\@,$(capbrand),g' \
-	-e 's,@vendor\@,$(vendor),g' \
-	-e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
-	-e 's,@PACKAGE_VERSION\@,$(PACKAGE_VERSION),g' \
-	-e 's,@RPM_VERSION\@,$(RPM_VERSION),g' \
-	-e 's,@PACKAGE_BASE_VERSION\@,$(PACKAGE_BASE_VERSION),g' \
-	-e 's,@CONSOLE_VERSION\@,$(CONSOLE_VERSION),g' \
-	-e 's,@BUILDNUM\@,$(BUILDNUM),g' \
-	-e 's,@NQBUILD_NUM\@,$(NQBUILDNUM),g' \
-	-e 's,@perlpath\@,$(perldir) $(libdir)/perl/arch $(libdir)/perl,g' \
-	-e 's,@defaultuser\@,$(defaultuser),g' \
-	-e 's,@defaultgroup\@,$(defaultgroup),g' \
-	-e 's,@with_fhs_opt\@,@with_fhs_opt@,g' \
-	-e 's,@with_selinux\@,@with_selinux@,g' \
-	-e 's,@with_systemd\@,$(WITH_SYSTEMD),g' \
-	-e 's,@with_tmpfiles_d\@,@with_tmpfiles_d@,g' \
-	-e 's,@perlexec\@,@perlexec@,g' \
-	-e 's,@pythonexec\@,@pythonexec@,g' \
-	-e 's,@sttyexec\@,@sttyexec@,g' \
-	-e 's,@initconfigdir\@,$(initconfigdir),g'\
-	-e 's,@updatedir\@,$(updatedir),g' \
-	-e 's,@ldaplib\@,$(ldaplib),g' \
-	-e 's,@ldaplib_defs\@,$(ldaplib_defs),g' \
-	-e 's,@systemdsystemunitdir\@,$(systemdsystemunitdir),g' \
-	-e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
-	-e 's,@systemdgroupname\@,$(systemdgroupname),g' \
-	-e 's,@prefixdir\@,$(prefixdir),g'
-else
 fixupcmd = sed \
 	-e 's,@bindir\@,$(bindir),g' \
 	-e 's,@sbindir\@,$(sbindir),g' \
@@ -2210,7 +2133,6 @@ fixupcmd = sed \
 	-e 's,@systemdsystemconfdir\@,$(systemdsystemconfdir),g' \
 	-e 's,@systemdgroupname\@,$(systemdgroupname),g' \
 	-e 's,@prefixdir\@,$(prefixdir),g'
-endif
 
 %: %.in
 	mkdir -p $(dir $@)
diff --git a/configure.ac b/configure.ac
index 6674960..710c0ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,21 +128,6 @@ AC_ARG_ENABLE(profiling, AS_HELP_STRING([--enable-profiling], [Enable gcov profi
 AC_SUBST([profiling_defs])
 AC_SUBST([profiling_links])
 
-
-
-# Used for legacy style packaging where we bundle all of the dependencies.
-AC_MSG_CHECKING(for --enable-bundle)
-AC_ARG_ENABLE(bundle, AS_HELP_STRING([--enable-bundle], [Enable bundled dependencies (default: no)]),
-[
-  AC_MSG_RESULT(yes)
-  bundle="1";
-],
-[
-  AC_MSG_RESULT(no)
-  bundle="";
-])
-AM_CONDITIONAL(BUNDLE,test "$bundle" = "1")
-
 # these enables are for optional or experimental features
 if test -z "$enable_pam_passthru" ; then
    enable_pam_passthru=yes # if not set on cmdline, set default
@@ -530,7 +515,6 @@ fi
 
 # Default to no atomic queue operations.
 with_atomic_queue="no"
-with_xsixfour="no"
 
 # we use stty in perl scripts to disable password echo
 # this doesn't work unless the full absolute path of the
@@ -543,11 +527,7 @@ with_xsixfour="no"
 sttyexec=/bin/stty
 case $host in
   *-*-linux*)
-    AC_DEFINE([Linux], [1], [Linux])
     AC_DEFINE([LINUX], [1], [Linux])
-    AC_DEFINE([LINUX2_0], [1], [Linux 2.0])
-    AC_DEFINE([LINUX2_2], [1], [Linux 2.2])
-    AC_DEFINE([LINUX2_4], [1], [Linux 2.4])
     AC_DEFINE([_GNU_SOURCE], [1], [GNU Source])
     platform="linux"
     initdir='$(sysconfdir)/rc.d/init.d'
@@ -558,7 +538,6 @@ case $host in
         AC_DEFINE([CPU_x86], [], [cpu type x86])
         ;;
       x86_64-*-linux*)
-        with_xsixfour="yes"
         AC_DEFINE([CPU_x86_64], [1], [cpu type x86_64])
 
         # This turns on and off LFDS inside of libsds
@@ -744,6 +723,7 @@ AM_CONDITIONAL([ATOMIC_QUEUE_OPERATIONS], [test "$with_atomic_queue" = "yes"])
 AM_CONDITIONAL([HPUX],[test "$platform" = "hpux"])
 AM_CONDITIONAL([SOLARIS],[test "$platform" = "solaris"])
 AM_CONDITIONAL([FREEBSD],[test "$platform" = "freebsd"])
+AM_CONDITIONAL([SPARC],[test "x$TARGET" = xSPARC])
 
 # Check for library dependencies
 m4_include(m4/nspr.m4)
@@ -774,49 +754,21 @@ else
 fi
 
 AM_CONDITIONAL(OPENLDAP,test "$with_openldap" = "yes")
-AM_CONDITIONAL(SOLARIS,test "$platform" = "solaris")
-AM_CONDITIONAL(SPARC,test "x$TARGET" = xSPARC)
 
 # write out paths for binary components
-AC_SUBST(nspr_inc)
-AC_SUBST(nspr_lib)
-AC_SUBST(nspr_libdir)
-AC_SUBST(nss_inc)
-AC_SUBST(nss_lib)
-AC_SUBST(nss_libdir)
 AC_SUBST(ldapsdk_inc)
 AC_SUBST(ldapsdk_lib)
 AC_SUBST(ldapsdk_libdir)
 AC_SUBST(ldapsdk_bindir)
-AC_SUBST(openldap_inc)
-AC_SUBST(openldap_lib)
-AC_SUBST(openldap_libdir)
-AC_SUBST(openldap_bindir)
 AC_SUBST(ldaplib)
 AC_SUBST(ldaplib_defs)
 AC_SUBST(ldaptool_bindir)
 AC_SUBST(ldaptool_opts)
 AC_SUBST(plainldif_opts)
-AC_SUBST(ol_libver)
-AC_SUBST(db_inc)
-AC_SUBST(db_incdir)
-AC_SUBST(db_lib)
-AC_SUBST(db_libdir)
-AC_SUBST(db_bindir)
-AC_SUBST(db_libver)
 AC_SUBST(sasl_inc)
 AC_SUBST(sasl_lib)
 AC_SUBST(sasl_libdir)
 AC_SUBST(sasl_path)
-AC_SUBST(svrcore_inc)
-AC_SUBST(svrcore_lib)
-AC_SUBST(icu_lib)
-AC_SUBST(icu_inc)
-AC_SUBST(icu_bin)
-AC_SUBST(netsnmp_inc)
-AC_SUBST(netsnmp_lib)
-AC_SUBST(netsnmp_libdir)
-AC_SUBST(netsnmp_link)
 AC_SUBST(pcre_inc)
 AC_SUBST(pcre_lib)
 AC_SUBST(pcre_libdir)
@@ -824,9 +776,6 @@ AC_SUBST(nunc_stans_inc)
 AC_SUBST(nunc_stans_lib)
 AC_SUBST(nunc_stans_libdir)
 AC_SUBST(localrundir)
-AC_SUBST(systemd_inc)
-AC_SUBST(systemd_lib)
-AC_SUBST(systemd_defs)
 
 AC_SUBST(brand)
 AC_SUBST(capbrand)
@@ -838,33 +787,13 @@ AC_SUBST(vendor)
 # which gives us the option to do performance testing without the presence of
 # logging.  To remove the presence of error logging undefine LDAP_ERROR_LOGGING.
 AC_DEFINE([LDAP_ERROR_LOGGING], [1], [LDAP error logging flag])
-AC_DEFINE([LDAP_DONT_USE_SMARTHEAP], [1], [Don't use smartheap])
-
-# libtool on fedora/rhel contains some gcc-isms which cause problems
-# if not using gcc (e.g. Forte on Solaris, aCC on HP-UX)
-# we remove them here
-if test "$GCC" != yes ; then
-   AC_MSG_NOTICE([Not using gcc - fixing libtool to remove gcc-isms . . .])
-   cp -p libtool libtool.orig
-   cp -p libtool libtool.tmp
-   # dnl note the special chars @<:@ and @:>@ - since m4 treats [ and ] specially,
-   # we have to use the quadrigraph @<:@ for [ and @:>@ for ] - and you thought
-   # perl produced write-only code . . .
-   sed -e '/^gcc_dir/ d' \
-       -e '/^gcc_ver/ d' \
-       -e 's/^predep_objects=.*echo \("@<:@^"@:>@*"\).*$/predep_objects=\1/' \
-       -e 's/^postdep_objects=.*echo \("@<:@^"@:>@*"\).*$/postdep_objects=\1/' \
-       -e 's/^compiler_lib_search_path=.*echo \("@<:@^"@:>@*"\).*$/compiler_lib_search_path=\1/' \
-       -e 's/^sys_lib_search_path_spec=.*echo \("@<:@^"@:>@*"\).*$/sys_lib_search_path_spec=\1/' \
-       libtool > libtool.tmp
-   cp -p libtool.tmp libtool
-   rm -f libtool.tmp
-fi
 
 # Build our pkgconfig files
 # This currently conflicts with %.in: rule in Makefile.am, which should be removed eventually.
+
 AC_CONFIG_FILES([src/pkgconfig/dirsrv.pc src/pkgconfig/nunc-stans.pc src/pkgconfig/libsds.pc])
 
 AC_CONFIG_FILES([Makefile rpm/389-ds-base.spec  ])
 
 AC_OUTPUT
+
diff --git a/include/base/systems.h b/include/base/systems.h
index 15f10fb..a70b3c8 100644
--- a/include/base/systems.h
+++ b/include/base/systems.h
@@ -62,7 +62,7 @@
 /* warning: mmap doesn't work under 9.04 */
 #define SHMEM_MMAP_FLAGS MAP_FILE | MAP_VARIABLE | MAP_SHARED
 
-#elif defined(Linux)
+#elif defined(LINUX)
 
 #define ACCELERATOR_CACHE
 #define DNS_CACHE
diff --git a/include/public/base/systems.h b/include/public/base/systems.h
index ba36502..36646a5 100644
--- a/include/public/base/systems.h
+++ b/include/public/base/systems.h
@@ -56,7 +56,7 @@
 #define SHMEM_UNIX_MMAP
 #define ZERO(ptr,len) memset(ptr,0,len)
 
-#elif defined(Linux)
+#elif defined(LINUX)
 
 #define FILE_UNIX
 #define FILE_UNIX_MMAP
diff --git a/ldap/include/portable.h b/ldap/include/portable.h
index 0f454ce..651b6fd 100644
--- a/ldap/include/portable.h
+++ b/ldap/include/portable.h
@@ -124,7 +124,7 @@
  * Are sys_errlist and sys_nerr declared in stdio.h?
  */
 #ifndef SYSERRLIST_IN_STDIO
-#if defined( __FreeBSD__ ) || defined(Linux)
+#if defined( __FreeBSD__ ) || defined(LINUX)
 #define SYSERRLIST_IN_STDIO
 #endif
 #endif
@@ -133,7 +133,7 @@
  * for select()
  */
 #if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh)
-#if defined(hpux) || defined(LINUX2_0)
+#if defined(hpux) || defined(LINUX)
 #include <sys/time.h>
 #else
 #include <sys/select.h>
@@ -250,7 +250,7 @@ int strncasecmp(const char *, const char *, size_t);
     defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \
     defined(NCR) || defined(OSF1) || defined(NEC) || \
     ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \
-    defined(UnixWare) || defined(LINUX2_0) || defined (__FreeBSD__)
+    defined(UnixWare) || defined(LINUX) || defined (__FreeBSD__)
 #define GETHOSTBYNAME( n, r, b, l, e )  gethostbyname( n )
 #elif defined(AIX)
 #define GETHOSTBYNAME_BUF_T struct hostent_data
@@ -297,7 +297,7 @@ typedef char GETHOSTBYADDR_buf_t [BUFSIZ];
 #endif
 #if defined(hpux9) || defined(LINUX1_2) || defined(SUNOS4) || defined(SNI) || \
     defined(SCOOS) || defined(BSDI) || defined(NCR) || \
-    defined(NEC) || defined(LINUX2_0)
+    defined(NEC) || defined(LINUX)
 /* strtok() is not MT safe, but it is okay to call here because used in mmt_protocol.xs which 
    has been moved in the tetframewrok */
 #define STRTOK( s1, s2, l )		strtok( s1, s2 )
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 05e092e..c3dfb4a 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -58,10 +58,6 @@ union semun {
 #include "fe.h"
 #include <nss.h>
 
-#ifndef LDAP_DONT_USE_SMARTHEAP
-#include "smrtheap.h"
-#endif
-
 #ifdef LINUX
 /* For mallopt. Should be removed soon. */
 #include <malloc.h>
@@ -672,10 +668,6 @@ main( int argc, char **argv)
 		slapd_debug_level_log( slapd_ldap_debug );
 	}
 
-#ifndef LDAP_DONT_USE_SMARTHEAP
-	MemRegisterTask();
-#endif
-
 	slapd_init();
 	g_log_init();
 	vattr_init();
diff --git a/lib/base/dnsdmain.cpp b/lib/base/dnsdmain.cpp
index 0b522ad..0a3afd7 100644
--- a/lib/base/dnsdmain.cpp
+++ b/lib/base/dnsdmain.cpp
@@ -35,12 +35,12 @@ extern "C" {
 #define _PATH_RESCONF "/etc/resolv.conf"
 
 NSPR_BEGIN_EXTERN_C
-#ifdef Linux
+#ifdef LINUX
 extern int getdomainname(char *, size_t);
 #else 
 extern int getdomainname(char *, int);
 #endif /* Linux */
-#if defined(HPUX) || defined(Linux) || defined(SOLARIS_GCC) || defined(__FreeBSD__)
+#if defined(HPUX) || defined(LINUX) || defined(SOLARIS_GCC) || defined(__FreeBSD__)
 extern int gethostname (char *name, size_t namelen);
 #else
 extern int gethostname (char *name, int namelen);
diff --git a/lib/base/systhr.cpp b/lib/base/systhr.cpp
index a826484..075faf4 100644
--- a/lib/base/systhr.cpp
+++ b/lib/base/systhr.cpp
@@ -59,7 +59,7 @@ NSPR_BEGIN_EXTERN_C
 NSAPI_PUBLIC SYS_THREAD
 systhread_start(int prio, int stksz, void (*fn)(void *), void *arg)
 {
-#if defined(Linux) && !defined(USE_PTHREADS)
+#if defined(LINUX) && !defined(USE_PTHREADS)
     prio /= 8; /* quick and dirty fix for user thread priority scale problem */
     if (prio > 3) prio = 3;
 #endif
diff --git a/m4/db.m4 b/m4/db.m4
index a30f53e..d1f3bde 100644
--- a/m4/db.m4
+++ b/m4/db.m4
@@ -124,3 +124,12 @@ if  test -n "$PKG_CONFIG"; then
 else
   db_bindir=/usr/bin
 fi
+
+
+AC_SUBST(db_inc)
+AC_SUBST(db_incdir)
+AC_SUBST(db_lib)
+AC_SUBST(db_libdir)
+AC_SUBST(db_bindir)
+AC_SUBST(db_libver)
+
diff --git a/m4/icu.m4 b/m4/icu.m4
index ffbcfb6..9aa7140 100644
--- a/m4/icu.m4
+++ b/m4/icu.m4
@@ -92,3 +92,9 @@ if test -z "$icu_lib"; then
     AC_MSG_ERROR([ICU not found, specify with --with-icu.])
   fi
 fi
+
+
+AC_SUBST(icu_lib)
+AC_SUBST(icu_inc)
+AC_SUBST(icu_bin)
+
diff --git a/m4/netsnmp.m4 b/m4/netsnmp.m4
index 74fd058..4925c4f 100644
--- a/m4/netsnmp.m4
+++ b/m4/netsnmp.m4
@@ -94,3 +94,9 @@ if test -n "$netsnmp_inc"; then
 else
   AC_MSG_ERROR([Net-SNMP not found, specify with --with-netsnmp.])
 fi
+
+AC_SUBST(netsnmp_inc)
+AC_SUBST(netsnmp_lib)
+AC_SUBST(netsnmp_libdir)
+AC_SUBST(netsnmp_link)
+
diff --git a/m4/nspr.m4 b/m4/nspr.m4
index 22178a3..503a87f 100644
--- a/m4/nspr.m4
+++ b/m4/nspr.m4
@@ -86,3 +86,8 @@ if test -z "$nspr_inc" -o -z "$nspr_lib" -o -z "$nspr_libdir"; then
     fi
   fi
 fi
+
+AC_SUBST(nspr_inc)
+AC_SUBST(nspr_lib)
+AC_SUBST(nspr_libdir)
+
diff --git a/m4/nss.m4 b/m4/nss.m4
index 7cdb8a0..4465479 100644
--- a/m4/nss.m4
+++ b/m4/nss.m4
@@ -86,3 +86,8 @@ if test -z "$nss_inc" -o -z "$nss_lib" -o -z "$nss_libdir"; then
     fi
   fi
 fi
+
+AC_SUBST(nss_inc)
+AC_SUBST(nss_lib)
+AC_SUBST(nss_libdir)
+
diff --git a/m4/openldap.m4 b/m4/openldap.m4
index f45637c..f3381ff 100644
--- a/m4/openldap.m4
+++ b/m4/openldap.m4
@@ -8,6 +8,10 @@
 
 AC_CHECKING(for OpenLDAP)
 
+if test -z "$with_openldap"; then
+    with_openldap=yes # Set default to yes
+fi
+
 # check for --with-openldap
 AC_MSG_CHECKING(for --with-openldap)
 AC_ARG_WITH(openldap, AS_HELP_STRING([--with-openldap@<:@=PATH@:>@],[Use OpenLDAP - optional PATH is path to OpenLDAP SDK]),
@@ -153,3 +157,11 @@ if test "$with_openldap" = yes ; then
   # get plain output from ldapsearch - no version, no comments
   plainldif_opts=-LLL
 fi
+
+
+AC_SUBST(openldap_inc)
+AC_SUBST(openldap_lib)
+AC_SUBST(openldap_libdir)
+AC_SUBST(openldap_bindir)
+AC_SUBST(ol_libver)
+
diff --git a/m4/svrcore.m4 b/m4/svrcore.m4
index d849bdb..f50f4a9 100644
--- a/m4/svrcore.m4
+++ b/m4/svrcore.m4
@@ -107,3 +107,6 @@ if test -z "$svrcore_inc" -o -z "$svrcore_lib"; then
     AC_MSG_ERROR([SVRCORE not found, specify with --with-svrcore.])
   fi
 fi
+
+AC_SUBST(svrcore_inc)
+AC_SUBST(svrcore_lib)
diff --git a/m4/systemd.m4 b/m4/systemd.m4
index 6dc3422..38e39e7 100644
--- a/m4/systemd.m4
+++ b/m4/systemd.m4
@@ -123,3 +123,9 @@ AM_CONDITIONAL([with_systemd],[test -n "$with_systemd"])
 AM_CONDITIONAL([JOURNALD],[test -n "$with_journald"])
 AM_CONDITIONAL([with_systemd_journald],[test -n "$with_journald"])
 
+
+AC_SUBST(systemd_inc)
+AC_SUBST(systemd_lib)
+AC_SUBST(systemd_defs)
+
+
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index 83bc204..4a31cf3 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -11,13 +11,8 @@
 # also need the relprefix field for a pre-release e.g. .0 - also comment out for official release
 #% global relprefix 0.
 
-%global use_openldap 1
-%global use_db4 0
 # If perl-Socket-2.000 or newer is available, set 0 to use_Socket6.
 %global use_Socket6 0
-# nunc-stans only builds on x86_64 for now
-# To build without nunc-stans, set use_nunc_stans to 0.
-%global use_nunc_stans __NUNC_STANS_ON__
 
 # This enables an ASAN build. This should not go to production, so we rename.
 %global use_asan __ASAN_ON__
@@ -61,16 +56,8 @@ Provides:         ldif2ldbm
 BuildRequires:    nspr-devel
 BuildRequires:    nss-devel
 BuildRequires:    svrcore-devel >= 4.1.2
-%if %{use_openldap}
 BuildRequires:    openldap-devel
-%else
-BuildRequires:    mozldap-devel
-%endif
-%if %{use_db4}
-BuildRequires:    db4-devel
-%else
 BuildRequires:    libdb-devel
-%endif
 BuildRequires:    cyrus-sasl-devel
 BuildRequires:    icu
 BuildRequires:    libicu-devel
@@ -78,9 +65,6 @@ BuildRequires:    pcre-devel
 BuildRequires:    gcc-c++
 # The following are needed to build the snmp ldap-agent
 BuildRequires:    net-snmp-devel
-%ifnarch sparc sparc64 ppc ppc64 s390 s390x
-BuildRequires:    lm_sensors-devel
-%endif
 BuildRequires:    bzip2-devel
 BuildRequires:    zlib-devel
 BuildRequires:    openssl-devel
@@ -100,9 +84,7 @@ BuildRequires:    libtool
 BuildRequires:    doxygen
 # For tests!
 BuildRequires:    libcmocka-devel
-%if %{use_nunc_stans}
 BuildRequires:    libevent-devel
-%endif
 
 %if %{use_tcmalloc}
 BuildRequires:    gperftools-devel
@@ -121,11 +103,7 @@ Requires:         policycoreutils-python
 # This is needed for our future move to python selinux interaction.
 Requires:         libsemanage-python
 # the following are needed for some of our scripts
-%if %{use_openldap}
 Requires:         openldap-clients
-%else
-Requires:         mozldap-tools
-%endif
 # use_openldap assumes perl-Mozilla-LDAP is built with openldap support
 Requires:         perl-Mozilla-LDAP
 # this is needed to setup SSL if you are not using the
@@ -138,13 +116,8 @@ Requires:         cyrus-sasl-md5
 # This is optionally supported by us, as we use it in our tests
 Requires:         cyrus-sasl-plain
 # this is needed for verify-db.pl and backldbm
-%if %{use_db4}
-Requires:         db4
-Requires:         db4-utils
-%else
 Requires:         libdb-utils
 Requires:         libdb
-%endif
 # This picks up libperl.so as a Requires, so we add this versioned one
 Requires:         perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
 # Needed by logconv.pl
@@ -187,16 +160,8 @@ Group:            System Environment/Daemons
 # isolation.
 Requires:         nss
 Requires:         nspr
-%if %{use_openldap}
 Requires:         openldap
-%else
-# What does mozldap need?
-Requires:         mozldap-tools
-%endif
-
-%if %{use_nunc_stans}
 Requires:         libevent
-%endif
 Requires:         systemd-libs
 # Pull in sasl
 Requires:         cyrus-sasl-lib
@@ -221,11 +186,7 @@ Requires:         pkgconfig
 Requires:         nspr-devel
 Requires:         nss-devel
 Requires:         svrcore-devel
-%if %{use_openldap}
 Requires:         openldap-devel
-%else
-Requires:         mozldap-devel
-%endif
 # systemd-libs contains the headers iirc.
 Requires:         systemd-libs
 
@@ -280,9 +241,6 @@ BuildRequires:    python%{python3_pkgversion}-setuptools
 The lib389 CI tests that can be run against the Directory Server.
 %endif
 
-
-
-
 %prep
 %setup -q -n %{name}-%{version}%{?prerel}
 
@@ -290,17 +248,10 @@ cp %{SOURCE2} README.devel
 
 %build
 
-%if %{use_openldap}
-OPENLDAP_FLAG="--with-openldap"
-%endif
 %{?with_tmpfiles_d: TMPFILES_FLAG="--with-tmpfiles-d=%{with_tmpfiles_d}"}
 # hack hack hack https://bugzilla.redhat.com/show_bug.cgi?id=833529
 NSSARGS="--with-svrcore-inc=%{_includedir} --with-svrcore-lib=%{_libdir} --with-nss-lib=%{_libdir} --with-nss-inc=%{_includedir}/nss3"
 
-%if %{use_nunc_stans}
-NUNC_STANS_FLAGS="--enable-nunc-stans"
-%endif
-
 %if %{use_asan}
 ASAN_FLAGS="--enable-asan --enable-debug"
 %endif
@@ -312,20 +263,17 @@ TCMALLOC_FLAGS="--with-tcmalloc"
 # Rebuild the autotool artifacts now.
 autoreconf -fiv
 
-%configure --enable-autobind --with-selinux $OPENLDAP_FLAG $TMPFILES_FLAG \
+%configure --with-selinux $TMPFILES_FLAG \
+           --with-systemd \
            --with-systemdsystemunitdir=%{_unitdir} \
            --with-systemdsystemconfdir=%{_sysconfdir}/systemd/system \
-           --with-systemdgroupname=%{groupname} $NSSARGS $NUNC_STANS_FLAGS \
-           --with-systemd $TCMALLOC_FLAGS $ASAN_FLAGS \
+           --with-systemdgroupname=%{groupname} \
+           $NSSARGS $TCMALLOC_FLAGS $ASAN_FLAGS \
            --enable-cmocka
 
 # Generate symbolic info for debuggers
 export XCFLAGS=$RPM_OPT_FLAGS
 
-%ifarch x86_64 ppc64 ia64 s390x sparc64
-export USE_64=1
-%endif
-
 make %{?_smp_mflags}
 
 make setup.py
@@ -553,10 +501,8 @@ fi
 %{_libdir}/%{pkgname}/libslapd.so
 %{_libdir}/%{pkgname}/libns-dshttpd.so
 %{_mandir}/man3/*
-%if %{use_nunc_stans}
 %{_libdir}/%{pkgname}/libnunc-stans.so
 %{_libdir}/%{pkgname}/libsds.so
-%endif
 %{_libdir}/pkgconfig/*
 
 %files libs
@@ -565,10 +511,8 @@ fi
 %dir %{_libdir}/%{pkgname}
 %{_libdir}/%{pkgname}/libslapd.so.*
 %{_libdir}/%{pkgname}/libns-dshttpd-*.so
-%if %{use_nunc_stans}
 %{_libdir}/%{pkgname}/libnunc-stans.so.*
 %{_libdir}/%{pkgname}/libsds.so.*
-%endif
 
 %files snmp
 %defattr(-,root,root,-)
-- 
1.8.3.1

