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.
Many Thanks
Tim Black Senior Developer Actia UK Ltd Important: This e-mail is intended for the above named only. It may contain private or confidential information, protected by copyright. If this has been received in error, it should be destroyed or the sender notified. It should not be used except by the intended recipient. The views contained in this email are those of the author and not necessarily those of Actia (UK) Ltd.
It is for the recipient to undertake any virus checking and no liability therefore is accepted by the sender.
Actia (UK) Ltd Registered Office: Unit 81 Mochdre Industrial Estate, Newtown, Powys. SY16 4LE. Company Reg. No: 2910867
On 22 January 2014 19:24, Tim Black tblack@actia.co.uk wrote:
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.
Geany just runs the commands you tell it to, so if you know the commands to use at the command line, you can just add them to the Geany commands with menu->build->set build commands.
One of the filetype independent commands asks for a parameter to be added to the command.
This is detailed here http://www.geany.org/manual/current/index.html#build-menu-configuration and here http://wiki.geany.org/howtos/configurebuildmenu
Cheers Lex
Many Thanks
Tim Black
Senior Developer
Actia UK Ltd
Important: This e-mail is intended for the above named only. It may contain private or confidential information, protected by copyright. If this has been received in error, it should be destroyed or the sender notified. It should not be used except by the intended recipient. The views contained in this email are those of the author and not necessarily those of Actia (UK) Ltd.
It is for the recipient to undertake any virus checking and no liability therefore is accepted by the sender.
Actia (UK) Ltd Registered Office: Unit 81 Mochdre Industrial Estate, Newtown, Powys. SY16 4LE. Company Reg. No: 2910867
Users mailing list Users@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/users
Lex
Yes thanks for that - I already know how to set up commands.
Unless I am missing the point these sections do not address the problem I having.
I have sent a follow up that should explain the problem in more detail.
Regards
Tim
From: users-bounces@lists.geany.org [mailto:users-bounces@lists.geany.org] On Behalf Of Lex Trotman Sent: 22 January 2014 08:31 To: Geany general discussion list Subject: Re: [Geany-Users] Makefile redirction for Make Command
On 22 January 2014 19:24, Tim Black <tblack@actia.co.ukmailto:tblack@actia.co.uk> wrote: 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.
Geany just runs the commands you tell it to, so if you know the commands to use at the command line, you can just add them to the Geany commands with menu->build->set build commands.
One of the filetype independent commands asks for a parameter to be added to the command.
This is detailed here http://www.geany.org/manual/current/index.html#build-menu-configuration and here http://wiki.geany.org/howtos/configurebuildmenu
Cheers Lex
Many Thanks
Tim Black Senior Developer Actia UK Ltd Important: This e-mail is intended for the above named only. It may contain private or confidential information, protected by copyright. If this has been received in error, it should be destroyed or the sender notified. It should not be used except by the intended recipient. The views contained in this email are those of the author and not necessarily those of Actia (UK) Ltd.
It is for the recipient to undertake any virus checking and no liability therefore is accepted by the sender.
Actia (UK) Ltd Registered Office: Unit 81 Mochdre Industrial Estate, Newtown, Powys. SY16 4LE. Company Reg. No: 2910867
_______________________________________________ Users mailing list Users@lists.geany.orgmailto:Users@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/users
Important: This e-mail is intended for the above named only. It may contain private or confidential information, protected by copyright. If this has been received in error, it should be destroyed or the sender notified. It should not be used except by the intended recipient. The views contained in this email are those of the author and not necessarily those of Actia (UK) Ltd.
It is for the recipient to undertake any virus checking and no liability therefore is accepted by the sender.
Actia (UK) Ltd Registered Office: Unit 81 Mochdre Industrial Estate, Newtown, Powys. SY16 4LE. Company Reg. No: 2910867
On Wed, Jan 22, 2014 at 08:24:36AM +0000, Tim Black wrote:
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.
Out-of-tree compilation with autotools is usually fairly straightforward -- just cd into your build tree, and call configure from there, e.g.
To build: $ mkdir -p build-tree $ cd build-tree $ ../configure $ make
And to clean: $ cd .. && rm -rf build-tree
With an autotools project, the autoconf/automake files (configure.ac, Makefile.am, Makefile.in) are in the source tree, whereas your Makefile, and a couple of other auxiliary files, are in your build tree.
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.
TL;DR: Simply put, don't use VPATH directly. In your Makefile.am, use $(srcdir) to refer to the directory, and $(builddir) to refer to the build directory. $(top_srcdir) and $(top_builddir) refer to the root of your source tree and build tree respectively.
In an in-tree build, $(srcdir) == $(builddir) and $(top_srcdir) == $(top_builddir).
In an out-of-tree build, $(srcdir) != $(builddir) and $(top_srcdir) != $(top_builddir). Your binaries go into $(builddir), while your sources remain in $(srcdir).
During `make distcheck`, one of the tests done is to make the entire $(srcdir) read-only, and to do the entire build in a separate directory using this feature. So, any files generated by your build (from ./configure onwards) should not modify anything in your source tree.
Explanation on VPATH: VPATH is a Make feature that affects the lookup of the dependencies, but not the target. When using VPATH, your target is relative to your current directory, whereas your dependencies are looked up in ., and failing which, in VPATH. However, make does not know how to mangle your rules, so...
This is correct: | foobar.o: foobar.c | $(CC) -c $< -o $@
If VPATH=../src, then this automatically expands to: $ cc -c ../src/foobar.c -o foobar
This is wrong: | foobar.o: foobar.c | $(CC) -c foobar.c -o foobar
Because this expands (regardless of VPATH) to: $ cc -c foobar.c -o foobar
Hi thanks for getting back to me.
Maybe I should have been a little more specific in my requirements:
My folder structure looks like:
/APPS /application1 /src /application2 /src <- geany pointing to file here ! See note below /application3 /src
... 20 or so applications ...
/buid1 /application1 /src /application2 /src <- I want geany to execute the Makefile here /application3 /src
... 20 or so applications ...
If I put a makefile (e.g. Makefile.geany) in /APPS/application2/src that points to the makefile in /build1/application2/src then regardless of which directory the file I am editing is the Make command will pick up the Makefile.geany and build application2. Obviously each Makefile.geany file would need to be customised to execute the correct target.
My question is:
What would I put in the Makefile.geany to run make in ../../build1/application/src or would a shell script (geany.make) be more sensible that simply executed e.g. pushd ../../build1/application/src; make; popd; Every directory would have the geany.make script so I can simply have to put geany.make in the command settings.
Your comments on the best course of action would be appreciated.
Thanks again
Tim
-----Original Message----- From: users-bounces@lists.geany.org [mailto:users-bounces@lists.geany.org] On Behalf Of Chow Loong Jin Sent: 22 January 2014 08:54 To: Geany general discussion list Subject: Re: [Geany-Users] Makefile redirction for Make Command
On Wed, Jan 22, 2014 at 08:24:36AM +0000, Tim Black wrote:
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.
Out-of-tree compilation with autotools is usually fairly straightforward -- just cd into your build tree, and call configure from there, e.g.
To build: $ mkdir -p build-tree $ cd build-tree $ ../configure $ make
And to clean: $ cd .. && rm -rf build-tree
With an autotools project, the autoconf/automake files (configure.ac, Makefile.am, Makefile.in) are in the source tree, whereas your Makefile, and a couple of other auxiliary files, are in your build tree.
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.
TL;DR: Simply put, don't use VPATH directly. In your Makefile.am, use $(srcdir) to refer to the directory, and $(builddir) to refer to the build directory. $(top_srcdir) and $(top_builddir) refer to the root of your source tree and build tree respectively.
In an in-tree build, $(srcdir) == $(builddir) and $(top_srcdir) == $(top_builddir).
In an out-of-tree build, $(srcdir) != $(builddir) and $(top_srcdir) != $(top_builddir). Your binaries go into $(builddir), while your sources remain in $(srcdir).
During `make distcheck`, one of the tests done is to make the entire $(srcdir) read-only, and to do the entire build in a separate directory using this feature. So, any files generated by your build (from ./configure onwards) should not modify anything in your source tree.
Explanation on VPATH: VPATH is a Make feature that affects the lookup of the dependencies, but not the target. When using VPATH, your target is relative to your current directory, whereas your dependencies are looked up in ., and failing which, in VPATH. However, make does not know how to mangle your rules, so...
This is correct: | foobar.o: foobar.c | $(CC) -c $< -o $@
If VPATH=../src, then this automatically expands to: $ cc -c ../src/foobar.c -o foobar
This is wrong: | foobar.o: foobar.c | $(CC) -c foobar.c -o foobar
Because this expands (regardless of VPATH) to: $ cc -c foobar.c -o foobar
-- Kind regards, Loong Jin Important: This e-mail is intended for the above named only. It may contain private or confidential information, protected by copyright. If this has been received in error, it should be destroyed or the sender notified. It should not be used except by the intended recipient. The views contained in this email are those of the author and not necessarily those of Actia (UK) Ltd.
It is for the recipient to undertake any virus checking and no liability therefore is accepted by the sender.
Actia (UK) Ltd Registered Office: Unit 81 Mochdre Industrial Estate, Newtown, Powys. SY16 4LE. Company Reg. No: 2910867
On 22 January 2014 23:19, Tim Black tblack@actia.co.uk wrote:
Hi thanks for getting back to me.
Maybe I should have been a little more specific in my requirements:
My folder structure looks like:
/APPS /application1 /src /application2 /src <- geany pointing to file here ! See note below
Not sure what you mean by "pointing to here", do you mean 1) currently editing a file here, 2) Geany was started with here as pwd, 3) the wd of the make command is explicitly pointed here, or something else?
In each case
1) your command could be a script that is passed %d as an argument and then extracts the tail and prefixes it with /build1. That is a single script and it doesn't even need to be in the application dir and can be filetype independent and an absolute path.
2) a filetype independent build command runs a script (from the local dir) that knows to run the matching make in /build1/... This needs a script in each application dir.
3) if its explicit, you might as well make it explicit to build1/... dir
You should probably also be looking at projects which can also set build commands and be more specific.
Personally I would use 2) having a hard wired script in each application dir, its simple, its explicit so the next maintainer can understand it, and it doesn't depend on Geany specifically so you can also run the script from the command line as well. Sure it will take half an hour to set up twenty scripts, but then its done :)
Cheers Lex
/application3 /src
... 20 or so applications ...
/buid1 /application1 /src /application2 /src <- I want geany to execute the Makefile here /application3 /src
... 20 or so applications ...
If I put a makefile (e.g. Makefile.geany) in /APPS/application2/src that points to the makefile in /build1/application2/src then regardless of which directory the file I am editing is the Make command will pick up the Makefile.geany and build application2. Obviously each Makefile.geany file would need to be customised to execute the correct target.
My question is:
What would I put in the Makefile.geany to run make in ../../build1/application/src or would a shell script (geany.make) be more sensible that simply executed e.g. pushd ../../build1/application/src; make; popd; Every directory would have the geany.make script so I can simply have to put geany.make in the command settings.
Your comments on the best course of action would be appreciated.
Thanks again
Tim [...]
Lex
Brilliant answer.
When I said pointing to here I meant currently editing file here!!!!
I think I am going to go for the script(s) option that you recommend - it has the advantages that you mentioned and the technique can be applied for other VPATH builds we may need in the future.
Colomban also mentioned this technique that could also be employed but I think I prefer the fixed path technique you mentioned (but see question below).
"However, seeing the examples in your other mail, you could also use a script that runs make in $(PWD)/../../../build1/<common part>, like that:
#!/bin/sh
# find subdir of build1 to enter
pwd="$PWD"
cd ../..
sub="./${pwd:${#PWD}}"
# 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/*/*/"
Just one more question though - Eclipse allows you to specify a target for a build e.g. Debug or Release.
Is there a way to simulate this in Geany? Can I have a build or build1A target selectable from a menu or something easy to use like that and then pass this as an argument to the build script?
Kind Regards
Tim
From: users-bounces@lists.geany.org [mailto:users-bounces@lists.geany.org] On Behalf Of Lex Trotman Sent: 22 January 2014 21:16 To: Geany general discussion list Subject: Re: [Geany-Users] Makefile redirction for Make Command
On 22 January 2014 23:19, Tim Black <tblack@actia.co.ukmailto:tblack@actia.co.uk> wrote: Hi thanks for getting back to me.
Maybe I should have been a little more specific in my requirements:
My folder structure looks like:
/APPS /application1 /src /application2 /src <- geany pointing to file here ! See note below
Not sure what you mean by "pointing to here", do you mean 1) currently editing a file here, 2) Geany was started with here as pwd, 3) the wd of the make command is explicitly pointed here, or something else?
In each case
1) your command could be a script that is passed %d as an argument and then extracts the tail and prefixes it with /build1. That is a single script and it doesn't even need to be in the application dir and can be filetype independent and an absolute path.
2) a filetype independent build command runs a script (from the local dir) that knows to run the matching make in /build1/... This needs a script in each application dir.
3) if its explicit, you might as well make it explicit to build1/... dir
You should probably also be looking at projects which can also set build commands and be more specific.
Personally I would use 2) having a hard wired script in each application dir, its simple, its explicit so the next maintainer can understand it, and it doesn't depend on Geany specifically so you can also run the script from the command line as well. Sure it will take half an hour to set up twenty scripts, but then its done :)
Cheers Lex
/application3 /src
... 20 or so applications ...
/buid1 /application1 /src /application2 /src <- I want geany to execute the Makefile here /application3 /src
... 20 or so applications ...
If I put a makefile (e.g. Makefile.geany) in /APPS/application2/src that points to the makefile in /build1/application2/src then regardless of which directory the file I am editing is the Make command will pick up the Makefile.geany and build application2. Obviously each Makefile.geany file would need to be customised to execute the correct target.
My question is:
What would I put in the Makefile.geany to run make in ../../build1/application/src or would a shell script (geany.make) be more sensible that simply executed e.g. pushd ../../build1/application/src; make; popd; Every directory would have the geany.make script so I can simply have to put geany.make in the command settings.
Your comments on the best course of action would be appreciated.
Thanks again
Tim [...] Important: This e-mail is intended for the above named only. It may contain private or confidential information, protected by copyright. If this has been received in error, it should be destroyed or the sender notified. It should not be used except by the intended recipient. The views contained in this email are those of the author and not necessarily those of Actia (UK) Ltd.
It is for the recipient to undertake any virus checking and no liability therefore is accepted by the sender.
Actia (UK) Ltd Registered Office: Unit 81 Mochdre Industrial Estate, Newtown, Powys. SY16 4LE. Company Reg. No: 2910867
[...]
Just one more question though - Eclipse allows you to specify a target for a build e.g. Debug or Release.
Is there a way to simulate this in Geany? Can I have a build or build1A target selectable from a menu or something easy to use like that and then pass this as an argument to the build script?
One of the filetype independent commands asks for extra text to be appended to the command.
Cheers Lex [...]
Le 22/01/2014 09:24, Tim Black a écrit :
Hello
Hi,
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:
#!/bin/sh
# find subdir of build1 to enter pwd="$PWD" cd ../.. sub="./${pwd:${#PWD}}" # 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.
Regards, Colomban