To: staff@amber.crhc.uiuc.edu From: Michael Chan Reply-to: chan@crhc.uiuc.edu Subject: encap trick Date: Tue, 14 Dec 1999 14:18:00 -0600 I've found a fairly elegant hack for dealing with things that don't encap easily. Most open source stuff is nice in that you can ./configure --prefix and make it go in /usr/local/encap and most things are content to be linked into /usr/local/{bin,lib,man...}. But from time to time you'll find things that aren't and that pretty much sucks. X things that use xmkmf/imake can be quite tricky to encap. First off, to build most of this stuff you need to have built and installed X11R6.4. You can ProjectRoot it in /usr/local/encap without too much trouble but xmkmf and imake will try to jam other X stuff in there too. That makes it hard to maintain the various X toys distributed separately from the core X11 stuff because it will all be mixed in together and you can't tell what's what. And even if you could make it install the X toy in a separate directory it will be dependant on the shared X libraries in the encap tree. So you can't upgrade X without breaking all the X toys. Solving this problem is actually fairly easy. First you flog yourself into unconciousness with O'Reilly's "Software Portability with imake" and then spend 48 straight hours tracing the flow of data through the various imake config things in lib/X11/config. When you're just about ready to give up the strings "DESTDIR" and "ProjectRoot" will come to you in a vision (assuming that you haven't slept or eaten for the full 48 hours and ingested the requisite amount of caffeine and sugar). DESTDIR is a thing you can set to "test 'make install' to see that it will do the right thing". Stuff will get installed in $DESTDIR/$PROJECTROOT. Normally DESTDIR is null and things will just go in PROJECTROOT. So you can set DESTDIR to something and have a separate tree of the X toy stuff that you can move into the encap directory. This is a pretty nifty thing for maintaining the software but the executables probably aren't going to find any libraries or support files if they have any unless you link them into the X11R6.4 encap tree. It's better but it still sucks. What we really want is for X and all the X toys to think they live in /usr/local/{bin,lib,...} so we can use encap to link them in and they will find their stuff where they expect to find it. That's where ProjectRoot comes in. You can ProjectRoot things to /usr/local, install them somewhere else by setting DESTDIR when you do the "make install; make install.man", mv $DESTDIR/usr/local/* $DESTDIR, and epkg it. Sweet, eh? So, when you install X11R6.4 you could set the ProjectRoot to /usr/local and install it in /usr/local/encap with the DESTDIR and encap it. Then you can use xmkmf and imake and all the X toys will figure they're going to land in /usr/local. Because everything is separate, it's easier to maintain. Of course, I didn't figure this out until I had already build X11R6.4 with a ProjectRoot set to /usr/local/encap/X11R6.4. But all was not lost... I don't really care if the /usr/local/encap/X11R6.4/bin stuff looks for it's libraries in /usr/local/encap/X11R6.4/lib. It's external dependancies that are the problem. My goal is to ensure that other X toys won't break if I upgrade the X11 libraries and includes. Other X toys need to find their libraries and stuff in /usr/local not /usr/local/encap/X11R6.4. To do that you just need to change the ProjectRoot in the installed site.def to /usr/local. It's not really necessary to go back and rebuild X. You can just hack the installed config files for imake. But wait! There's more! The makefiles I've sampled that were created with configure also seem to understand DESTDIR! So, let's say you built enlightenment-0.16.3 and you want to install the Epplets too. The epplets want to live in $prefix/enlightenment/epplets where $prefix is where you rooted enlightenment. And if they don't live there enlightenment won't find them. And what about all those themes and shit? The solutions should be clear: prefix enlightenment to /usr/local... DESTDIR install it into /usr/local/encap.. mv $DESTDIR/usr/local/* $DESTDIR... epkg it... enlightenment will look in /usr/local/enlightenment/... Stuff for enlightenment can be linked in from /usr/local/encap... You may now shower me with accolades for this brilliant discovery.