Re: top level project directory

2003-03-02 Thread Beni Cherniavsky
On 2003-03-02, Muli Ben-Yehuda wrote:

 On Sat, Mar 01, 2003 at 11:02:33PM +0200, Beni Cherniavsky wrote:

  OK.  Then have a relative path to the top in every makefile and let
  `make dist' in the top directory fix these pathes in all makefiles in
  subdirs, before creating the archives.

 No. As mentioned previously, having a relative path to the top
 makefile in every subdir makefile breaks horribly when you start
 moving them around.

The point was also to have some sort of `make fixpath' target in the
top makefile that updates all these pathes (the details are left as an
excercise to the reader).  So after you move it around you run `make
fixpath' in the top directory and it works happily again.

 The solution I like best is to use a top level Makefile which builds
 everything else. For example,

 make -f Makefile.build obj=arch/i386/boot/

 As for my thought excersize, no 100% fool proof to do that, given
 the constrained I outlined. I think Oleg Goldshmidt came closest in
 private communication.

You can have tiny script in the top dir like this (or the equivallent
shell function):

alias m=make -C `pwd`

Then you source the script when you start working on the project and
use `m' instead of `make' every time you need to compile, whereever
you are now.

Another realted approach, in case yuo want to manage a lot of
projects in this way, would be to make an alias/function for make that
when there is no makefile in the current directory, searches in `..',
then in `../..', etc.  You can still use recursive make by naming all
sub-makefiles something other...

-- 
Beni Cherniavsky [EMAIL PROTECTED]

True elegance has negative overhead so it isn't subject to tradeoffs.

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: top level project directory

2003-03-01 Thread Beni Cherniavsky
On 2003-02-28, Muli Ben-Yehuda wrote:

 On Fri, Feb 28, 2003 at 12:43:02PM +0200, guy keren wrote:

   Now that I think of it, another way would be to change the build
   structure from recursive builds to a centralized build - all
   directories are built from the top level directory. Let's say that I
   do want to use recrusive build, though. What trick am I missing?
 
  none. all possible tricks have problems of various sorts. btw, why are you
  so against using an environment variable?

 Consider it a thought excersize - I want to give someone a tarball of
 my code, and have it work out of the box when he types make,
 regardless of where he opens it, and which subdirectory of the
 project he builds from. The out of the box requirement excludes
 setting any env variables prior to compilation.

OK.  Then have a relative path to the top in every makefile and let
`make dist' in the top directory fix these pathes in all makefiles in
subdirs, before creating the archives.

-- 
Beni Cherniavsky [EMAIL PROTECTED]

True elegance has negative overhead so it isn't subject to tradeoffs.

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: top level project directory

2003-03-01 Thread Muli Ben-Yehuda
On Sat, Mar 01, 2003 at 11:02:33PM +0200, Beni Cherniavsky wrote:

 OK.  Then have a relative path to the top in every makefile and let
 `make dist' in the top directory fix these pathes in all makefiles in
 subdirs, before creating the archives.

No. As mentioned previously, having a relative path to the top
makefile in every subdir makefile breaks horribly when you start
moving them around. 

The solution I like best is to use a top level Makefile which builds
everything else. For example, 

make -f Makefile.build obj=arch/i386/boot/

As for my thought excersize, no 100% fool proof to do that, given
the constrained I outlined. I think Oleg Goldshmidt came closest in
private communication. 
-- 
Muli Ben-Yehuda
http://www.mulix.org



pgp0.pgp
Description: PGP signature


Re: top level project directory

2003-02-28 Thread guy keren

On Wed, 26 Feb 2003, Muli Ben-Yehuda wrote:

 Let's say that I have a complex project, using many Makefiles. In some
 of them, I'd like to refer to other directories of the project. So
 far, I've been using various combinations on ../, ../../, etc, but
 that's awfully brittle when you start moving directories around (not
 to mention potentially dangerous). Is there a way, which does NOT
 involve setting an environment variable, to refer to the top level
 project directory? Specifically, I have a Rules.make in that
 directory, which is included from the other Makefiles. If I could make
 the Rules.make contain the top level directory in a variable, it would
 solve most of my problems. 

you cannot have that, unless you force all 'make' invocations to be run 
from that top-level directory.

here are a few things to try - non seems to be too satisfactory:

1. make your project 'shallow' (i.e. all source directories are located 
   under a single 'src' directory, no hierarchies). that's what i use in 
   all my projects (small and large alike), together with '-I..' and 
   using directoy names in includes (i.e. #include dir/file.h). this 
   kind of structure also helps avoid most of the directory moving - only 
   files moving between directories need more work.

   ofcourse, if your project inherits from the linux kernel itself, you 
   won't dare go via that path.

2. having a symlink from each directory to the top-level directory (i.e.,
   in directory 'top_dir/subsys1/unit1/': ln -s ../../.. top_dir_link

   then use this link to access the top-level rules file. this won't help
   alot with directory renaming, though.

3. avoid moving directories. think a bit further before you create a 
   directory - in case you have a reason to beleive it might turn out more 
   'generic' then you first think it is - make it into that generic 
   directory, and put it in the right place from the start.

 Now that I think of it, another way would be to change the build
 structure from recursive builds to a centralized build - all
 directories are built from the top level directory. Let's say that I
 do want to use recrusive build, though. What trick am I missing? 

none. all possible tricks have problems of various sorts. btw, why are you 
so against using an environment variable?

-- 
guy

For world domination - press 1,
 or dial 0, and please hold, for the creator. -- nob o. dy


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: top level project directory

2003-02-27 Thread Oron Peled
On Wed, 26 Feb 2003 08:27:56 +0200
Muli Ben-Yehuda [EMAIL PROTECTED] wrote:
 Is there a way, which does NOT
 involve setting an environment variable, to refer to the top level
 project directory?

Of course automake generated Makefiles (Makefile.in to be exact)
are built to define $(topdir)


Oron Peled Voice/Fax: +972-4-8228492
[EMAIL PROTECTED]  http://www.actcom.co.il/~oron

www.OpenBSD.org -- We're fixing security problems so you can sleep at night.
(If it wasn't so fascinating I might get some sleep myself...) Theo de Raadt

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: top level project directory

2003-02-26 Thread Oleg Goldshmidt
Muli Ben-Yehuda [EMAIL PROTECTED] writes:

 Let's say that I have a complex project, using many Makefiles. In some
 of them, I'd like to refer to other directories of the project. So
 far, I've been using various combinations on ../, ../../, etc, but
 that's awfully brittle when you start moving directories around (not
 to mention potentially dangerous). Is there a way, which does NOT
 involve setting an environment variable, to refer to the top level
 project directory? Specifically, I have a Rules.make in that
 directory, which is included from the other Makefiles. If I could make
 the Rules.make contain the top level directory in a variable, it would
 solve most of my problems. 
 
 Now that I think of it, another way would be to change the build
 structure from recursive builds to a centralized build - all
 directories are built from the top level directory. Let's say that I
 do want to use recrusive build, though. What trick am I missing? 

Provide a reassonable (relative) default in every Makefile

UNTESTED:

In top-level Makefile

ifndef TOPDIR
TOPDIR := $(shell pwd)
endif

export TOPDIR

In all the other makefiles

ifndef TOPDIR
TOPDIR := default path to TOPDIR
export TOPDIR
endif

include $(TOPDIR)/Rules.mk

On the command line you'll be able to change it at will

$ make TOPDIR=path

HIH, let me know if you run into problems.

-- 
Oleg Goldshmidt | [EMAIL PROTECTED]

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]