Bug 214533 - configure needs to support --with-fhs
configure needs to support --with-fhs
Status: CLOSED CURRENTRELEASE
Product: 389
Classification: Community
Component: Install/Uninstall (Show other bugs)
1.0.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Noriko Hosoi
Viktor Ashirov
:
Depends On:
Blocks: 152373 240316 FDS1.1.0
  Show dependency treegraph
 
Reported: 2006-11-07 19:33 EST by Noriko Hosoi
Modified: 2015-12-07 11:57 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-07 11:57:55 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
cvs diffs (configure.ac Makefile.am), new file m4/fhs.m4 (3.32 KB, patch)
2006-11-10 14:19 EST, Noriko Hosoi
no flags Details | Diff
cvs diffs (all the source codes) (552.41 KB, patch)
2006-11-10 17:31 EST, Noriko Hosoi
no flags Details | Diff
cvs commit message (ldapserver) (175.07 KB, text/plain)
2006-11-10 18:54 EST, Noriko Hosoi
no flags Details
cvs commit (autoconf tools) (1.04 KB, text/plain)
2006-11-10 19:02 EST, Noriko Hosoi
no flags Details
cvs commit message (confiugre.ac configure) (615 bytes, text/plain)
2006-11-13 13:48 EST, Noriko Hosoi
no flags Details
cvs diffs (11.55 KB, patch)
2006-11-13 16:51 EST, Noriko Hosoi
no flags Details | Diff
cvs commit message (1.54 KB, text/plain)
2006-11-13 18:47 EST, Noriko Hosoi
no flags Details

  None (edit)
Description Noriko Hosoi 2006-11-07 19:33:54 EST
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 14:19:22 EST
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 14:28:34 EST
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 14:46:34 EST
(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 14:55:02 EST
(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 15:23:38 EST
Ok.
Comment 6 Noriko Hosoi 2006-11-10 17:31:26 EST
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 18:16:21 EST
(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 18:54:07 EST
Created attachment 140948 [details]
cvs commit message (ldapserver)

Checked in the diffs in Comment #6 into HEAD.
Comment 9 Noriko Hosoi 2006-11-10 19:02:58 EST
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-10 20:14:56 EST
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-10 20:18:38 EST
Note: if $prefix is not added, bindir starts from /usr/bin although I set
--prefix=...
Comment 12 Noriko Hosoi 2006-11-13 13:48:30 EST
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 16:51:47 EST
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 18:47:30 EST
Created attachment 141122 [details]
cvs commit message

Reviewed by Rich (Thank you!!!)

Checked in into HEAD.
Comment 15 Noriko Hosoi 2007-11-29 17:19:40 EST
$ 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.

Note You need to log in before you can comment on or make changes to this bug.