Bug 214533

Summary: configure needs to support --with-fhs
Product: [Retired] 389 Reporter: Noriko Hosoi <nhosoi>
Component: Install/UninstallAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0.2CC: nkinder, rmeggins
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:57:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 152373, 240316, 427409    
Attachments:
Description Flags
cvs diffs (configure.ac Makefile.am), new file m4/fhs.m4
none
cvs diffs (all the source codes)
none
cvs commit message (ldapserver)
none
cvs commit (autoconf tools)
none
cvs commit message (confiugre.ac configure)
none
cvs diffs
none
cvs commit message none

Description Noriko Hosoi 2006-11-08 00:33:54 UTC
Description of problem:
Richard Megginson wrote:
> I think we just need the following options:
> 1) Default paths - user specifies nothing, use defaults for everything -
layout looks like this:
> /opt/fedora-ds - the default prefix
>  bin/ - bindir is relative to exec_prefix (which set to prefix by default)
>  lib/ - libdir is relative to exec_prefix (which set to prefix by default)
>  etc/ - relative to prefix
>  var/ - relative to prefix
>  share/ - relative to prefix
>  include/ - relative to prefix
> which is what we want, I think.  I don't think we want to have
/opt/fedora-ds/usr/include or /opt/fedora-ds/usr/bin or the like - I think we
want to have everything under a flat namespace if a prefix is given.  And in
this case, we don't need libdir/fedora-ds, share/fedora-ds, etc. since
everything is already under a single path.
>
> 2) User specified prefix - user specifies --prefix=/path - layout is the same
as above
> This would be useful for development e.g. configure
--prefix=/export/rmeggins/ds72 && make && make install
>
> 3) FHS style --with-fhs
> This is equivalent to
> --prefix= --exec_prefix=/usr --includedir=/usr/include --datadir=/usr/share
> based on the default definitions in configure:
> bindir='${exec_prefix}/bin'
> sbindir='${exec_prefix}/sbin'
> libexecdir='${exec_prefix}/libexec'
> datadir='${prefix}/share'
> sysconfdir='${prefix}/etc'
> sharedstatedir='${prefix}/com'
> localstatedir='${prefix}/var'
> libdir='${exec_prefix}/lib'
> includedir='${prefix}/include'
> oldincludedir='/usr/include'
> infodir='${prefix}/info'
> mandir='${prefix}/man'
>
> So this would result in the following:
> /usr/bin
> /usr/share
> /etc
> /var
> /usr/lib
> /usr/include
>
> It's weird that both datadir and includedir are defined relative to prefix and
not exec_prefix.  If they were defined in terms of exec_prefix, we could just
get FHS by doing
> --prefix= --exec_prefix=/usr
>
> I think this is all we need.  For the GNU style, you just specify
--prefix=/usr/local.  I'm not sure what other styles we need to support.
>

Richard Megginson wrote:
> I think the best approach would be to have configure set all of these paths as
#define in an include file or -D on the gcc command line:
> #define LOCALSTATEDIR   "/var"
> #define SYSCONFDIR      "/etc"
> #define BINDIR          "/usr/bin"
> #define DATADIR         "/usr/share"
> #define DOCDIR          "/usr/doc"
> I think we also need libdir.
>
> I think we can just use AC_DEFINE for this, or perhaps configure automatically
defines these.
> configure can automatically create a config.h that we can include in our files
if we don't want it to define everything on the command line.

Comment 1 Noriko Hosoi 2006-11-10 19:19:22 UTC
Created attachment 140927 [details]
cvs diffs (configure.ac Makefile.am), new file m4/fhs.m4

Files:
configure.ac
Makefile.am
m4/fhs.m4

Changes:
1. introduced a new option --with-fhs
2. instead of passing the define macro with -D, generate config.h

Comment 2 Noriko Hosoi 2006-11-10 19:28:34 UTC
I verified that the changes in Comment #1 generates config.h with the following
define:
with_fhs/config.h:#define IS_FHS 1
without_fhs:/* #undef IS_FHS */

And the build command line (on RHEL4) looks like this:
if gcc -DHAVE_CONFIG_H -I. -I.. -I.  -DXP_UNIX -DLinux -DLINUX -DLINUX2_0
-DLINUX2_2 -DLINUX2_4  -DBUILD_NUM=\"2006.314.1857\" -I../ldap/include
-I../ldap/servers/slapd -I../include -I. -I../lib/ldaputil
-I/usr/include/mozldap6 -I/usr/include/dirsec/nspr4 -I/usr/include/dirsec/nss3 
 -I/usr/include/dirsec/nss3   -I/usr/include/dirsec/nspr4     -g -O2 -MT
lib/ldaputil/libldaputil_a-ldapdb.o -MD -MP -MF
"lib/ldaputil/.deps/libldaputil_a-ldapdb.Tpo" -c -o
lib/ldaputil/libldaputil_a-ldapdb.o `test -f 'lib/ldaputil/ldapdb.c' || echo
'../'`lib/ldaputil/ldapdb.c; 

Now, each source file can have this include at the top of the code?
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

Comment 3 Rich Megginson 2006-11-10 19:46:34 UTC
(In reply to comment #2)
> Now, each source file can have this include at the top of the code?
> #ifdef HAVE_CONFIG_H
> #  include <config.h>
> #endif

Yes.  If there are already common include files, we might be able to save some
work and just put that code in the common include files.  OTOH, it's probably
not a big deal to write a script to add this to all our source code.

Comment 4 Noriko Hosoi 2006-11-10 19:55:02 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Now, each source file can have this include at the top of the code?
> > #ifdef HAVE_CONFIG_H
> > #  include <config.h>
> > #endif
> 
> Yes.  If there are already common include files, we might be able to save some
> work and just put that code in the common include files.  OTOH, it's probably
> not a big deal to write a script to add this to all our source code.

Thanks, Rich!  The autoconf manual writes "The package should '#include' the
configuration header file before any other header files, to prevent
inconsistencies in declarations (for example, if it redefines const)."  So, I
think it'd be safer in the long run to add the include to all...  Let me work on it.

Comment 5 Rich Megginson 2006-11-10 20:23:38 UTC
Ok.

Comment 6 Noriko Hosoi 2006-11-10 22:31:26 UTC
Created attachment 140943 [details]
cvs diffs (all the source codes)

Changes:
Added the following include next to the end of the copyright block.
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+

I updated all the *.h, *.c, *.cpp, and *.cc files under ldapserver.

Comment 7 Noriko Hosoi 2006-11-10 23:16:21 UTC
(In reply to comment #5)
> Ok.

I assume this "Ok" includes this note "to add this to all our source code." :) 
And Nathan gave me a verbal ok, too.

I'm going to check in ALL the source code files in 15 min (starting from 3:30pm)
...  Please stop me now if you have any issue.

Comment 8 Noriko Hosoi 2006-11-10 23:54:07 UTC
Created attachment 140948 [details]
cvs commit message (ldapserver)

Checked in the diffs in Comment #6 into HEAD.

Comment 9 Noriko Hosoi 2006-11-11 00:02:58 UTC
Created attachment 140949 [details]
cvs commit (autoconf tools)

Reviewed by Rich (Thank you!)

Checked in the files reviewed (configure.ac, Makefile.am, and m4/fhs.m4) as
well as the generated files by autogen.sh (Makefile.in configure) into HEAD.

Comment 10 Noriko Hosoi 2006-11-11 01:14:56 UTC
File: configure.ac
Changes: if --with-fhs is set, bindir, libdir, and datadir starts from $prefix/usr:

Index: configure.ac
===================================================================
RCS file: /cvs/dirsec/ldapserver/configure.ac,v
retrieving revision 1.8
diff -t -w -U4 -r1.8 configure.ac
--- configure.ac        10 Nov 2006 23:59:15 -0000      1.8
+++ configure.ac        11 Nov 2006 01:11:45 -0000
@@ -127,9 +127,13 @@
 AC_SUBST(netsnmp_libdir)
 AC_SUBST(netsnmp_link)

 # installation paths
-dnl bindir=/usr/bin
+if test "$with_fhs" = "yes"; then
+  bindir=$prefix/usr/bin
+  libdir=$prefix/usr/lib
+  datadir=$prefix/usr/share
+fi
 # relative to sysconfdir
 configdir=/fedora-ds/config
 # relative to datadir
 sampledatadir=/fedora-ds/data

Now, ds_newinst.pl works without any changes.
$ cd <prefix>
$ ls usr
bin/  lib/  share/
$ ls usr/*
usr/bin:
dbgen.pl*  infadd*  infadd-bin*  ldclt*  ldclt-bin*  rsearch*  rsearch-bin*
usr/lib:
fedora-ds/
usr/share:
fedora-ds/

$ perl usr/lib/fedora-ds/ds_newinst.pl /tmp/install.inf
[nhosoi@laputa ds72_core]$ perl usr/lib/fedora-ds/ds_newinst.pl
/tmp/install.infSuccess!  Your new directory server instance was created

Note: create_instance is going to be updated to support --without-fhs, too.


Comment 11 Noriko Hosoi 2006-11-11 01:18:38 UTC
Note: if $prefix is not added, bindir starts from /usr/bin although I set
--prefix=...

Comment 12 Noriko Hosoi 2006-11-13 18:48:30 UTC
Created attachment 141084 [details]
cvs commit message (confiugre.ac configure)

Reviewed by Nathan (Thank you!!)

Checked in into HEAD.

Comment 13 Noriko Hosoi 2006-11-13 21:51:47 UTC
Created attachment 141108 [details]
cvs diffs 

Modified Files:
configure.ac
ldap/admin/src/create_instance.c
ldap/admin/src/create_instance.h

New File:
ldap/admin/src/ds_newinst.pl.in

Changes:
configure.ac: $prefix should have been @prefix@.  $prefix is replaced with the
value of --prefix, but not with AC_PREFIX_DEFAULT when --prefix is not given.
create_instance.[ch]: depending upon the macro IS_FHS, change swich the LIBDIR,
BINDIR, DATADIR, and DOCDIR.
ds_newinst.pl.in: use @libdir@ to get the ds_newinst path.

Comment 14 Noriko Hosoi 2006-11-13 23:47:30 UTC
Created attachment 141122 [details]
cvs commit message

Reviewed by Rich (Thank you!!!)

Checked in into HEAD.

Comment 15 Noriko Hosoi 2007-11-29 22:19:40 UTC
$ cvs st configure
===================================================================
File: configure         Status: Up-to-date

   Working revision:    1.77
   Repository revision: 1.77    /cvs/dirsec/ldapserver/configure,v
   Sticky Tag:          (none)
   Sticky Date:         (none)
   Sticky Options:      (none)

$ ./configure --help | egrep with-fhs
  --with-fhs   Use FHS layout
  --with-fhs-opt   Use FHS optional layout

The package built with --with-fhs is installed at the directories defined with
FHS.  If --prefix=<path> is added to it, FHS under <prefix> is used.  If an inf
file is passed to setup (setup-ds.pl or setup-ds-admin.pl), the directory
instance is created at the locations specified in the inf file (quickinstall
does it).

I.e., verified.