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]