0

Let's assume this project hierarchy:

root
|-src
| |-proj1
| |-proj2
| | |-src
| | | |-nested
|-build

Using GNU autotools and relying on recursive make, configuring and making the project hierarchy in the build directory is no problem with:

root$ cd src && autoreconf -i && cd ../build && ../src/configure --options && make

Now, since this creates a mirror of the src hierarchy in build, I'd like to have a symlink to the corresponding src subdir in every single subdir of build, like this:

root
|-src
| |-proj1
| |-proj2
| | |-src
| | | |-nested
|-build
| |-proj1
| | |-_src -> root/src/proj1
| |-proj2
| | |-_src -> root/src/proj2
| | |-src
| | | |-_src -> root/src/proj2/src
| | | |-nested
| | | | |-_src -> root/src/proj2/src/nested

Is there a way to achieve that?

Irfy
  • 9,323
  • 1
  • 45
  • 67
  • Can I ask why you want to do this? If `$srcdir`, `$top_srcdir`, etc., are used correctly, the generated Makefiles should reference the source directories anyway. – Brett Hale Dec 18 '12 at 00:07
  • Everything *is* generated correctly, I need those for my own use. – Irfy Dec 18 '12 at 09:15
  • Use a `-local` or `-hook` [target](http://www.gnu.org/software/automake/manual/html_node/Extending.html). – Brett Hale Dec 18 '12 at 10:24
  • @BrettHale The way I understand it, I'd need to modify every Makefile.am to include a rule for this. Is there a way to define such a rule only once? – Irfy Dec 18 '12 at 11:53

1 Answers1

1

I may have been somewhat unspecific about what I'm going to do with the symlinks I asked for, so this solution wasn't very obvious. I simply wanted to access the source files, from within the build-dirs, during debugging, with as little typing as possible. Since then, I figured that an alias instead of many symlinks would do the job just as well:

$ less `s`/file.cc

where s is an alias defined as

alias s='pwd | sed -e "s|build|src|"'
Irfy
  • 9,323
  • 1
  • 45
  • 67