Bug 213352 - autotools: support redhat/fedora rpmbuild %configure and %makeinstall
autotools: support redhat/fedora rpmbuild %configure and %makeinstall
Status: CLOSED CURRENTRELEASE
Product: 389
Classification: Community
Component: Directory Server (Show other bugs)
1.0.2
All All
medium Severity medium
: ---
: ---
Assigned To: Rich Megginson
Viktor Ashirov
:
Depends On:
Blocks: 152373 240316
  Show dependency treegraph
 
Reported: 2006-10-31 18:21 EST by Rich Megginson
Modified: 2015-12-07 11:46 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-07 11:46:59 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)
diffs (18.21 KB, patch)
2006-10-31 18:21 EST, Rich Megginson
no flags Details | Diff
list of files affected (339 bytes, text/plain)
2006-10-31 18:22 EST, Rich Megginson
no flags Details
cvs commit log (3.09 KB, text/plain)
2006-11-01 22:12 EST, Rich Megginson
no flags Details

  None (edit)
Description Rich Megginson 2006-10-31 18:21:35 EST
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 18:21:35 EST
Created attachment 139919 [details]
diffs
Comment 2 Rich Megginson 2006-10-31 18:22:23 EST
Created attachment 139920 [details]
list of files affected

list of files
Comment 3 Noriko Hosoi 2006-11-01 18:07:19 EST
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 18:32:54 EST
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-01 20:47:43 EST
> 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-01 21:23:12 EST
Ah, I see!  The var format is shared, of course.  Thanks for explaining it for me!
Comment 7 Rich Megginson 2006-11-01 22:12:52 EST
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 17:29:58 EST
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 17:34:58 EST
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 18:12:12 EST
pushed to be verified bu build person
Comment 11 Nathan Kinder 2007-12-21 13:46:04 EST
We have been using these changes to sucessfully build our RPM for quite some
time now.

Marking as VERIFIED.

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