-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Pax Unix wrote: > It sounds like you could use MAKEFILE_LIST inside Makefile: > > makefileDir := $(dir $(firstword $(MAKEFILE_LIST))) > > MAKEFILE_LIST contains the paths of all makefiles read (in order) during > make's invocation. The above won't quite work, though, if someone > causes a different file to be included before the Makefile you specified: > > make -f otherdir/preMakefile -f Makefile > > In this case, the above would echo 'otherdir/', not './' like I expect > you want.
As you point out that isn't reliable because of the fact that MAKEFILE_LIST gets appended any time a Makefile is loaded (e.g. -f or include). If you want to work with MAKEFILE_LIST it must be done right at the start of the Makefile you are in. My recommendation is that the first line of the Makefile be: CURRENT_MAKEFILE_LIST := $(MAKEFILE_LIST) and then work with CURRENT_MAKEFILE_LIST. If you do that the your makefileDir becomes: makefileDir := $(dir $(firstword $(CURRENT_MAKEFILE_LIST))) and is reliable. John. - -- John Graham-Cumming [EMAIL PROTECTED] Home: http://www.jgc.org/ Blog: http://www.jgc.org/blog/ New! UseTheSource: http://usethesource.com/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGUVC8Lphrp73n/hARAuGgAJ9mjzcHXzFfSbkjNt4dEL+/4t7RCwCdHRXM VnDjR+SvukWfz7/NyjebUDo= =YqET -----END PGP SIGNATURE----- _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
