[Geany-Users] Makefile redirction for Make Command

Colomban Wendling lists.ban at xxxxx
Wed Jan 22 14:21:28 UTC 2014

Le 22/01/2014 09:24, Tim Black a écrit :
> Hello


> In the Manual there is talk of Makefile redirection that is used for
> “out of tree” compilation.
> I am using Geany and have recently migrated a project that uses an
> Automake VPATH build(s) and now my apps will not build without the use
> of this Makefile redirection.
> Has anyone got an example of this Makefile redirection.  Basically I
> need to fire off the makefile that now exists in my build tree.  I have
> two versions of build tree that have different targets and use different
> versions of gcc so it would also be good to pass an argument that would
> select one of the targets.

I believe what you want is a Makefile like this:

	all clean:
        	$(MAKE) -C /path/to/other/directory/ $@

You can of course add all the targets you want to be able to build in
the list with "all" and "clean" (e.g. "all clean distclean doc:" or
whatever);  and of course, /path/to/other/directory can either be
absolute or relative.

However, seeing the examples in your other mail, you could also use a
script that runs make in $(PWD)/../../../build1/<common part>, like that:


	# find subdir of build1 to enter
	cd ../..
	# and enter, and run make in it
	cd "../build1/$sub"
	exec make $@

It has the advantage of not requiring to drop one makefile per source
directory, you just use this script everywhere.  A more committed writer
could also probably write a script that finds the recursion depth itself
by e.g. going up until current directory is APPS, so the script could be
run from any subdirectory of APPS, not only in APPS/*/*/

Hope it helps.


More information about the Users mailing list