You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Jonathan Robie <jo...@redhat.com> on 2009/03/23 20:52:54 UTC

Examples makefiles: I want to break your C++ builds ....

Each example in our examples directory currently has two Makefiles. One 
of these is a standard Autotools-generated Makefile located directly in 
the same directory as the source, and it always works because our builds 
break if it does not. Each example also has another Makefile called 
./.libs/Makefile that is easy to read, and although it is also 
generated, the way that it is generated makes it look more like a 
hand-authored Makefile.

The ./libs/Makefile is fragile, because if someone changes one of the 
files used to generate it, the build is not affected. But it's also a 
lot easier to read, and much better to include in documentation.

Could we just put *that* Makefile into the directory for each example, 
so when that file breaks, whoever breaks it gets some feedback? We've 
had it break at least twice in one week recently, due to changes made by 
different people for different reasons.

Jonathan

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Ján Sáreník <js...@redhat.com>.
Hi Jonathan!

On Mon, Mar 23, 2009 at 03:52:54PM -0400, Jonathan Robie wrote:
> Could we just put *that* Makefile into the directory for each example,  
> so when that file breaks, whoever breaks it gets some feedback? We've  
> had it break at least twice in one week recently, due to changes made by  
> different people for different reasons.

I apologize for indentation errors I did as part of
https://issues.apache.org/jira/browse/QPID-1740
as I did not catch them - my local make(1) did not
complain.

Like Manuel writes, I think it would be counterproductive
to redo something which was there before, I mean to separate
the Makefiles.

  Best regards, Jasan
-- 
Red Hat Czech, MRG Quality Assurance Associate

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Jonathan Robie <jo...@redhat.com>.
Alan Conway wrote:
> I think we can go back to simple hand-written makefiles and still 
> handle platform differences and build vs. install by using make 
> variables appropriately.
>
> 1. remove existing examples/*/Makefile.am
>
> 2. Generate examples/makefile.mk with platform-specific settings, e.g.
>
> # makefile.mk
> CXX=g++
>
> 3. Hand-write simple examples/foo/Makefile like this:
>
> # examples/foo/Makefile
> include ../examples.mk
> all: foo
> foo: foo.cpp
>     ${CXX} ${CXXFLAGS} -lqpidclient -o $@ $<
> clean:
>     rm -f foo
>
>
> 4. The hand-written makefiles are designed to work as-is if qpid is 
> installed. To build under automake we put something like this in 
> examples/Makefile.am:
>
> EXAMPLE_DIRS=direct pubsub ...
> EXAMPLE_CXXFLAGS=-I$(top_srcdir)/src -I$(top_srcdir)/src/gen ...
> force:
>     for e in ${EXAMPLE_DIRS} do ; cd $$e ; make 
> CXXFLAGS=$(EXAMPLE_CXXFLAGS) ; done
>
> Make sense?


This makes a lot of sense to me.

Any objections?

Jonathan

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Alan Conway <ac...@redhat.com>.
Jonathan Robie wrote:
> Gordon Sim wrote:
>> Jonathan Robie wrote:
>>> A couple of possible approaches:
>>>
>>> 1. Let the current examples Makefile generate the ./libs Makefile, 
>>> then use it to compile the examples.
>>> 2. Add a goal to '$ make check' that creates a new directory with 
>>> each example and Makefile and ensures that it still compiles.
>>
>> One issue to consider is that the makefiles that will be bundled with 
>> the examples for distribution are intended to compile against 
>> installed versions of the headers and libs. By contrast the make check 
>> operates against a working directory.
> 
> Hmmmm, good point.  I'm not sure how to get around that, our testing 
> model does not presume that you've done a '$ make install'.
> 
> In my own environment, I now have shell scripts that install the 
> examples, compile them, and run them in each language. Maybe anyone 
> using the generated Makefiles will just have to do this. But I'd really 
> like to find a way to make this break upstream if there is an upstream 
> problem.
> 

I think we can go back to simple hand-written makefiles and still handle 
platform differences and build vs. install by using make variables appropriately.

1. remove existing examples/*/Makefile.am

2. Generate examples/makefile.mk with platform-specific settings, e.g.

# makefile.mk
CXX=g++

3. Hand-write simple examples/foo/Makefile like this:

# examples/foo/Makefile
include ../examples.mk
all: foo
foo: foo.cpp
	${CXX} ${CXXFLAGS} -lqpidclient -o $@ $<
clean:
	rm -f foo


4. The hand-written makefiles are designed to work as-is if qpid is installed. 
To build under automake we put something like this in examples/Makefile.am:

EXAMPLE_DIRS=direct pubsub ...
EXAMPLE_CXXFLAGS=-I$(top_srcdir)/src -I$(top_srcdir)/src/gen ...
force:
	for e in ${EXAMPLE_DIRS} do ; cd $$e ; make CXXFLAGS=$(EXAMPLE_CXXFLAGS) ; done

Make sense?

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Jonathan Robie <jo...@redhat.com>.
Gordon Sim wrote:
> Jonathan Robie wrote:
>> A couple of possible approaches:
>>
>> 1. Let the current examples Makefile generate the ./libs Makefile, 
>> then use it to compile the examples.
>> 2. Add a goal to '$ make check' that creates a new directory with 
>> each example and Makefile and ensures that it still compiles.
>
> One issue to consider is that the makefiles that will be bundled with 
> the examples for distribution are intended to compile against 
> installed versions of the headers and libs. By contrast the make check 
> operates against a working directory.

Hmmmm, good point.  I'm not sure how to get around that, our testing 
model does not presume that you've done a '$ make install'.

In my own environment, I now have shell scripts that install the 
examples, compile them, and run them in each language. Maybe anyone 
using the generated Makefiles will just have to do this. But I'd really 
like to find a way to make this break upstream if there is an upstream 
problem.

Jonathan

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Martin Ritchie <ri...@apache.org>.
2009/3/24 Jonathan Robie <jo...@redhat.com>:
> Carl Trieloff wrote:
>>
>> maybe add a rule to make dist
>
> Is it OK for make dist to require Qpid to be installed?

I'm not sure that is a good dependency to have. When the release
artefacts are being built IMHO it should not attempt to install or
access data ouside of the build tree. To prevent accidental inclusion
of data that is not desired.

Perhaps I misunderstand your plan.
I'm fine with the example makefile, that is included in in the example
package after 'make dist' is run, referencing installed Qpid
libraries/headers. However, I don't thinkg 'make dist' should require
Qpid to be installed to succesfully run.

> Jonathan
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
>
>




-- 
Martin Ritchie

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Jonathan Robie <jo...@redhat.com>.
Carl Trieloff wrote:
> maybe add a rule to make dist
Is it OK for make dist to require Qpid to be installed?

Jonathan

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Carl Trieloff <cc...@redhat.com>.
Gordon Sim wrote:
> Jonathan Robie wrote:
>> A couple of possible approaches:
>>
>> 1. Let the current examples Makefile generate the ./libs Makefile, 
>> then use it to compile the examples.
>> 2. Add a goal to '$ make check' that creates a new directory with 
>> each example and Makefile and ensures that it still compiles.
>
> One issue to consider is that the makefiles that will be bundled with 
> the examples for distribution are intended to compile against 
> installed versions of the headers and libs. By contrast the make check 
> operates against a working directory. 

maybe add a rule to make dist

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Gordon Sim <gs...@redhat.com>.
Jonathan Robie wrote:
> A couple of possible approaches:
> 
> 1. Let the current examples Makefile generate the ./libs Makefile, then 
> use it to compile the examples.
> 2. Add a goal to '$ make check' that creates a new directory with each 
> example and Makefile and ensures that it still compiles.

One issue to consider is that the makefiles that will be bundled with 
the examples for distribution are intended to compile against installed 
versions of the headers and libs. By contrast the make check operates 
against a working directory.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Manuel Teira Paz <mt...@tid.es>.
Jonathan Robie escribió:
> Manuel Teira Paz wrote:
>   
>> Hello, Jonathan.
>> I made that change, if I remember correctly. Previously, the makefile 
>> in any of the examples directories was made by hand, and intended to 
>> be human-readable, to be deployed as part of the examples. 
>> Unfortunately, this way, the makefile was not in sync with the 
>> autotools world, and, for example, the compiler to be used, flags, 
>> library locations, were hardwired into the makefile to some extent.
>> What we have now, as you said, is a autotools-generated makefile, to 
>> compile the examples in the build directory, and another one to be 
>> deployed (human-friendly) that also has to be capable of generating 
>> the examples, but using the installed distribution.
>>     
>
> I am not advocating going back to the hand-written makefiles for the 
> examples.
>
> The human-friendly one in ./liibs is generated by a target in the 
> Makefile in the given  example dirctory, and changes people make when 
> doing other things can break it. I like the fact that we have a readable 
> makefile that is generated, but when people break it, I want them to 
> notice. We had to fix it twice this last week.
>
> A couple of possible approaches:
>
> 1. Let the current examples Makefile generate the ./libs Makefile, then 
> use it to compile the examples.
>   
I found this one particulary complex, since you need to handle two build 
modes. For the autotools fashion, you'd rather use .la linkage files, 
and for the simpler, independent, user-friendly one, it seems to be 
better to link directly against the real libraries.
> 2. Add a goal to '$ make check' that creates a new directory with each 
> example and Makefile and ensures that it still compiles.
>   
I find this option more meaningful, since building the examples could be 
seen also as a check.
> Can you think of other approaches that might be better?
>   
I like your #2 approach.
--
Manuel.

> Jonathan
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
>
>   


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Jonathan Robie <jo...@redhat.com>.
Manuel Teira Paz wrote:
> Hello, Jonathan.
> I made that change, if I remember correctly. Previously, the makefile 
> in any of the examples directories was made by hand, and intended to 
> be human-readable, to be deployed as part of the examples. 
> Unfortunately, this way, the makefile was not in sync with the 
> autotools world, and, for example, the compiler to be used, flags, 
> library locations, were hardwired into the makefile to some extent.
> What we have now, as you said, is a autotools-generated makefile, to 
> compile the examples in the build directory, and another one to be 
> deployed (human-friendly) that also has to be capable of generating 
> the examples, but using the installed distribution.

I am not advocating going back to the hand-written makefiles for the 
examples.

The human-friendly one in ./liibs is generated by a target in the 
Makefile in the given  example dirctory, and changes people make when 
doing other things can break it. I like the fact that we have a readable 
makefile that is generated, but when people break it, I want them to 
notice. We had to fix it twice this last week.

A couple of possible approaches:

1. Let the current examples Makefile generate the ./libs Makefile, then 
use it to compile the examples.
2. Add a goal to '$ make check' that creates a new directory with each 
example and Makefile and ensures that it still compiles.

Can you think of other approaches that might be better?

Jonathan

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Manuel Teira Paz <mt...@tid.es>.
Hello, Jonathan.
I made that change, if I remember correctly. Previously, the makefile in 
any of the examples directories was made by hand, and intended to be 
human-readable, to be deployed as part of the examples. Unfortunately, 
this way, the makefile was not in sync with the autotools world, and, 
for example, the compiler to be used, flags, library locations, were 
hardwired into the makefile to some extent.
What we have now, as you said, is a autotools-generated makefile, to 
compile the examples in the build directory, and another one to be 
deployed (human-friendly) that also has to be capable of generating the 
examples, but using the installed distribution.

I don't know if this is the best approach. Of course, one of its 
problems is that you'll never be sure that the examples are going to 
build correctly once deployed. Anyway, be aware that moving the 
.libs/Makefile to the examples one is going to overwrite the 
autotools-generated one, and that doesn't seem a very clean approach.

--
Manuel.


Jonathan Robie escribió:
> Nobody has objected so far. If I don't hear an objection, I'll go ahead 
> and make that change.
>
> Jonathan
>
> Jonathan Robie wrote:
>   
>> Each example in our examples directory currently has two Makefiles. 
>> One of these is a standard Autotools-generated Makefile located 
>> directly in the same directory as the source, and it always works 
>> because our builds break if it does not. Each example also has another 
>> Makefile called ./.libs/Makefile that is easy to read, and although it 
>> is also generated, the way that it is generated makes it look more 
>> like a hand-authored Makefile.
>>
>> The ./libs/Makefile is fragile, because if someone changes one of the 
>> files used to generate it, the build is not affected. But it's also a 
>> lot easier to read, and much better to include in documentation.
>>
>> Could we just put *that* Makefile into the directory for each example, 
>> so when that file breaks, whoever breaks it gets some feedback? We've 
>> had it break at least twice in one week recently, due to changes made 
>> by different people for different reasons.
>>
>> Jonathan
>>     
>
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
>
>   


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Examples makefiles: I want to break your C++ builds ....

Posted by Jonathan Robie <jo...@redhat.com>.
Nobody has objected so far. If I don't hear an objection, I'll go ahead 
and make that change.

Jonathan

Jonathan Robie wrote:
> Each example in our examples directory currently has two Makefiles. 
> One of these is a standard Autotools-generated Makefile located 
> directly in the same directory as the source, and it always works 
> because our builds break if it does not. Each example also has another 
> Makefile called ./.libs/Makefile that is easy to read, and although it 
> is also generated, the way that it is generated makes it look more 
> like a hand-authored Makefile.
>
> The ./libs/Makefile is fragile, because if someone changes one of the 
> files used to generate it, the build is not affected. But it's also a 
> lot easier to read, and much better to include in documentation.
>
> Could we just put *that* Makefile into the directory for each example, 
> so when that file breaks, whoever breaks it gets some feedback? We've 
> had it break at least twice in one week recently, due to changes made 
> by different people for different reasons.
>
> Jonathan


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org