Bug 213352

Summary: autotools: support redhat/fedora rpmbuild %configure and %makeinstall
Product: [Retired] 389 Reporter: Rich Megginson <rmeggins>
Component: Directory ServerAssignee: Rich Megginson <rmeggins>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.0.2   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:46:59 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    
Attachments:
Description Flags
diffs
none
list of files affected
none
cvs commit log none

Description Rich Megginson 2006-10-31 23:21:35 UTC
The standard way to do an rpmbuild on fedora/redhat is to use the %configure
macro in the %prep section of the spec file and the %makeinstall macro in the
%install section.  These set all of the bindir, libdir, datadir, sysconfdir,
etc. paths used by the application.  %configure sets them to their "real"
runtime locations e.g. /usr/lib, and %makeinstall sets them to their paths used
for rpm packaging e.g. /var/tmp/fedora-ds-foo-bar-baz/usr/lib.  There were a few
places in our autotools files where we were running afoul of this.

Another thing is that configure defines bindir etc. as literally
'${exec_prefix}/bin' so that the real value doesn't get expanded until make or
make install time.  This means that we cannot create scripts from templates in
configure, we have to do that in make.  So this adds a sed command to
Makefile.am in order to do all of the script and config file path replacement at
make time.

Since we do the subst this way, whatever $prefix is set during make will be
incorporated into the value of $bindir etc. so we can omit directly referencing
@prefix@ in the template files.

Comment 1 Rich Megginson 2006-10-31 23:21:35 UTC
Created attachment 139919 [details]
diffs

Comment 2 Rich Megginson 2006-10-31 23:22:23 UTC
Created attachment 139920 [details]
list of files affected

list of files

Comment 3 Noriko Hosoi 2006-11-01 23:07:19 UTC
Your changes look good.  One question...  Could you tell me why the backslash is
needed before the second @?  It's in Makefile.am.  
+fixupcmd = sed \
+	-e 's,@bindir\@,$(bindir),g' \
                     ^
+	-e 's,@libdir\@,$(libdir),g' \
                     ^
+       [...]

Comment 4 Nathan Kinder 2006-11-01 23:32:54 UTC
Aside from Noriko's question in comment#3, the changes look fine.  You may be
able to use things such as $pkglibdir in places where you want to package name
(fedora-ds in this case) appended to one of the standard paths such as $libdir.
 Automake supports this for all of the normal path macros like bindir, libdir,
sysconfdir, etc.

Comment 5 Rich Megginson 2006-11-02 01:47:43 UTC
> Your changes look good.  One question...  Could you tell me why the backslash is
> needed before the second @?  It's in Makefile.am.  
> +fixupcmd = sed \
> +    -e 's,@bindir\@,$(bindir),g' \
>                     ^
>+    -e 's,@libdir\@,$(libdir),g' \
>                     ^
>+       [...]

Good question.  It's because configure runs the same substitution on Makefile.in
to create Makefile.  We have to escape one of the @ so that configure won't
replace e.g. @bindir@ with /usr/bin (or ${exec_prefix}/bin).  I suppose I could
have used another delimiter character, but we're already using @var@ in our
templates and scripts.

> You may be able to use things such as $pkglibdir in places where you want
> to package name (fedora-ds in this case) appended to one of the standard
> paths such as $libdir.
> Automake supports this for all of the normal path macros like bindir, libdir,
> sysconfdir, etc.

I'm not sure what you mean.  How would I use this?

Comment 6 Noriko Hosoi 2006-11-02 02:23:12 UTC
Ah, I see!  The var format is shared, of course.  Thanks for explaining it for me!

Comment 7 Rich Megginson 2006-11-02 03:12:52 UTC
Created attachment 140071 [details]
cvs commit log

Reviewed by: nhosoi (Thanks!)
Files: see diff
Branch: HEAD
Platforms tested: RHEL4
Flag Day: no
Doc impact: no

Comment 8 Nathan Kinder 2006-11-03 22:29:58 UTC
An additional change is needed to allow us to build from outside of the
ldapserver directory.  Here's the change:

Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.am,v
retrieving revision 1.9
diff -u -5 -t -r1.9 Makefile.am
--- Makefile.am 2 Nov 2006 03:11:39 -0000       1.9
+++ Makefile.am 3 Nov 2006 21:27:05 -0000
@@ -905,7 +905,8 @@
         -e 's,@serverdir\@,$(serverdir),g' \
         -e 's,@serverplugindir\@,$(serverplugindir),g' \
         -e 's,@taskdir\@,$(taskdir),g' \
         -e 's,@configdir\@,$(configdir),g'

-% : %.in
+%: %.in
+        mkdir -p $(dir $@)
         $(fixupcmd) $^ > $@

Comment 9 Nathan Kinder 2006-11-03 22:34:58 UTC
Checked in the changes from comment#8 (along with the generated build files).

Checking in Makefile.am;
/cvs/dirsec/ldapserver/Makefile.am,v  <--  Makefile.am
new revision: 1.10; previous revision: 1.9
done
Checking in Makefile.in;
/cvs/dirsec/ldapserver/Makefile.in,v  <--  Makefile.in
new revision: 1.11; previous revision: 1.10
done
Checking in aclocal.m4;
/cvs/dirsec/ldapserver/aclocal.m4,v  <--  aclocal.m4
new revision: 1.4; previous revision: 1.3
done
Checking in compile;
/cvs/dirsec/ldapserver/compile,v  <--  compile
new revision: 1.3; previous revision: 1.2
done
Checking in config.guess;
/cvs/dirsec/ldapserver/config.guess,v  <--  config.guess
new revision: 1.3; previous revision: 1.2
done
Checking in config.sub;
/cvs/dirsec/ldapserver/config.sub,v  <--  config.sub
new revision: 1.3; previous revision: 1.2
done
Checking in configure;
/cvs/dirsec/ldapserver/configure,v  <--  configure
new revision: 1.8; previous revision: 1.7
done
Checking in depcomp;
/cvs/dirsec/ldapserver/depcomp,v  <--  depcomp
new revision: 1.3; previous revision: 1.2
done
Checking in install-sh;
/cvs/dirsec/ldapserver/install-sh,v  <--  install-sh
new revision: 1.3; previous revision: 1.2
done
Checking in missing;
/cvs/dirsec/ldapserver/missing,v  <--  missing
new revision: 1.3; previous revision: 1.2
done


Comment 10 Michael Gregg 2007-12-06 23:12:12 UTC
pushed to be verified bu build person

Comment 11 Nathan Kinder 2007-12-21 18:46:04 UTC
We have been using these changes to sucessfully build our RPM for quite some
time now.

Marking as VERIFIED.