[ace-users] Incorrect Makefile.am code generate for a conditional binary program

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Stephen To » Sat, 05 Feb 2005 12:34:57


In my project I have a binary that depends on boost program options.
Well I made up my own mpb file for it by copying one of the existing
boost files in the $MPC/config. Well the resulting Makefile.am generated
by MPC is incorrect.

bin_PROGRAMS =
## Makefile.kurt_filters.am

if BUILD_BOOST
bin_PROGRAMS += kurt_filters <<< ERROR: not allowed.

kurt_filters_CPPFLAGS = \
-I$(top_srcdir) \
-I$(BOOST_ROOT)/include/$(BOOST_VERSION) \
-I$(srcdir)/src

kurt_filters_SOURCES = \
kurt_filters.cpp \
config.h

kurt_filters_LDADD = \
$(top_builddir)/src/common/libcommon.la
$(top_builddir)/src/output/liboutput.la
$(top_builddir)/src/data_source/libdata_source.la
$(top_builddir)/src/data_types/libdata_types.la
$(top_builddir)/src/filters/libfilters.la
$(top_builddir)/src/infrastructure/libinfrastructure.la
$(top_builddir)/src/input/libinput.la -lboost_program_options
$(BOOST_CFG)

endif BUILD_BOOST

The error is that the keyword bin_PROGRAMS is used twice in the
Makefile.am file. This is not allowed by automake. It results in the
following code being generated in the resulting Makefile. Where
bin_PROGRAMS is redefined in error.

bin_PROGRAMS = kurt_filters
bin_PROGRAMS =

If there is a need to have a conditional binary, which I see that is
what the MPC developers were trying to do, I would suggest having a
Makefile variable based on the binary file name. For example in my mpc
file below I have a binary called kurt_filters. The variable in the
Makefile.am would be kurt_filters_TARGET or kurt_filters_BINARY. This
way the code can be used conditionally and placed in the Makefile.am
like:

bin_PROGRAMS = $(kurt_filters_TARGET)

if BUILD_BOOST
kurt_filters_TARGET = kurt_filters

kurt_filters_CPPFLAGS = \
-I$(top_srcdir) \
-I$(BOOST_ROOT)/include/$(BOOST_VERSION) \
-I$(srcdir)/src

kurt_filters_SOURCES = \
kurt_filters.cpp \
config.h

kurt_filters_LDADD = \
$(top_builddir)/src/common/libcommon.la
$(top_builddir)/src/output/liboutput.la
$(top_builddir)/src/data_source/libdata_source.la
$(top_builddir)/src/data_types/libdata_types.la
$(top_builddir)/src/filters/libfilters.la
$(top_builddir)/src/infrastructure/libinfrastructure.la
$(top_builddir)/src/input/libinput.la -lboost_program_options
$(BOOST_CFG)

endif BUILD_BOOST


Therefore if $(kurt_filters_TARGET) is not defined then bin_PROGRAMS is
blank. We get the conditional build of the binary 'kurt_filters' that we
wanted.

Stephen



-----
MPB for boost_program_options (available in boost 1.32)
-----
// -*- MPC -*-
// $Id: boost_program_options.mpb,v 1.1 2004/11/23 13:53:48 elliott_c
Exp $

project: boost_base {
lit_libs += boost_program_options$(BOOST_CFG)
}

------
MPC
------
project(kurt_filters): common, install, boost_program_options {

exename = kurt_filters

includes += src

libs += common output data_source data_types filters
infrastructure input
after += common output data_source data_types filters
infrastructure input

Source_Files {
kurt_filters.cpp
}

Header_Files {
config.h
}
}

--
Stephen Torri < XXXX@XXXXX.COM >
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by jtc » Sat, 05 Feb 2005 17:59:33

Stephen Torri < XXXX@XXXXX.COM > writes:


But bin_PROGRAMS is not being redefined, it's being defined to nothing
at the beginning of the file, and then it's being appended to for each
conditional.


That's another way to do it, but since the current scheme works, and
it is more like how a human would write the Makefile.am, I can't see a
compelling reason to change.

--jtc


--
J.T. Conklin

 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Stephen To » Sat, 05 Feb 2005 18:10:24


In the resulting Makefile I found the following two lines together one
after the other:

bin_PROGRAMS = kurt_filters
bin_PROGRAMS =

The first line creates a Makefile variable called bin_PROGRAMS and
assigns to it 'kurt_filters'. The second line redefines it to nothing.
That is what I am calling redefinition. Is that a wrong interpretation
of it?


The current scheme is not working for me. I posted what I did because I
found that my resulting Makefile did not compile my binary.

The problem is caused by the fact that bin_PROGRAMS, given my words
above, is being defined a second time to nothing. So when Makefile reads
this file it says "Ok you want 'kurt_filters' compiled then you change
your mind. Fine.". Nothing is done for 'kurt_filters'

I don't see how this current scheme works. Did I miss something in the
mpb file I created? Did I do something wrong when I created the MPC
file?

Stephen
--
Stephen Torri < XXXX@XXXXX.COM >
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by jtc » Sun, 06 Feb 2005 02:46:18

Stephen Torri < XXXX@XXXXX.COM > writes:


I misread your first message and thought the MPC generated Makefile.am
was broken, when it's really the automake generated Makefile.in. What
version of automake are you using? I use automake 1.9.4 with the ACE/
TAO Makefile.am's which extensively use the assign-to-nothing/append-
in-conditionals idiom, and everything seems to work fine.


Now that I (hope I) understand what's going on, it looks like you've
done everything correctly.

Please check your automake version/installation.

--jtc






--
J.T. Conklin
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Stephen To » Sun, 06 Feb 2005 03:25:25


I was using automake 1.6. In reviewing my script I decided to see what
would happen if I used automake 1.9. That worked. If MPC is going to
expect the version of automake used is not less than 1.9 then is there a
way to have the automake use the right version?

Stephen
--
Stephen Torri < XXXX@XXXXX.COM >
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Chad Ellio » Sun, 06 Feb 2005 04:12:06


> > But bin_PROGRAMS is not being redefined, it's being defined to nothing
> > at the beginning of the file, and then it's being appended to for each
> > conditional.
>
> In the resulting Makefile I found the following two lines together one
> after the other:
>
> bin_PROGRAMS = kurt_filters
> bin_PROGRAMS =
>
> The first line creates a Makefile variable called bin_PROGRAMS and
> assigns to it 'kurt_filters'. The second line redefines it to nothing.
> That is what I am calling redefinition. Is that a wrong interpretation
> of it?
>

When I did some testing here, I did not see anything like that. Maybe
it would be easiest to figure this out if you sent your mpc file and the
command line you used to generate your automake files.

Thanks,
Chad
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Chad Ellio » Sun, 06 Feb 2005 04:30:03


> > When I did some testing here, I did not see anything like that. Maybe
> > it would be easiest to figure this out if you sent your mpc file
and the
> > command line you used to generate your automake files.
> >
> > Thanks,
> > Chad
>
> The version of automake I was using at the time was 1.6 now I stepped up
> to 1.9. So with that move everything worked.
>
> The MPC file and the script I use to call mwc.pl are attached.

Is there anything that needs to be done to MPC to alert users to this?

Thanks,
Chad

>
> Stephen
> --
> Stephen Torri < XXXX@XXXXX.COM >
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Stephen To » Sun, 06 Feb 2005 04:30:17


The version of automake I was using at the time was 1.6 now I stepped up
to 1.9. So with that move everything worked.

The MPC file and the script I use to call mwc.pl are attached.

Stephen
--
Stephen Torri < XXXX@XXXXX.COM >
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Stephen To » Sun, 06 Feb 2005 04:47:59


Personally I don't know of a way with automake to say "Hey I need
version X". That would be the easiest way if something was added to the
Makefile.am files so that when automake was executed it could either use
the right version or stop with an error message.

Stephen

--
Stephen Torri < XXXX@XXXXX.COM >
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by jtc » Sun, 06 Feb 2005 06:29:30

Stephen Torri < XXXX@XXXXX.COM > writes:


In the ACE/TAO configure.ac scripts, we have AM_INIT_AUTOMAKE([1.9]).
I'll check whether we can encode that within each Makefile.am. If it
can, I'll make the change.

--jtc




--
J.T. Conklin
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by jtc » Sun, 06 Feb 2005 07:08:46

Stephen Torri < XXXX@XXXXX.COM > writes:

From reading the automake info pages, it looks like changing
AutomakeWorkspaceCreator to emit "AUTOMAKE_OPTIONS = 1.9" in
the Makefile.am before it aggregates the project Makefile.am's
should do the trick. I'll check into it later this evening.

--jtc






--
J.T. Conklin
 
 
 

[ace-users] Incorrect Makefile.am code generate for a conditional binary program

Post by Ossama Oth » Sun, 06 Feb 2005 08:02:40

Hi Stephen,



You can force a pre-requisite of Automake 1.9 or better by passing
version argument to your AM_INIT_AUTOMAKE call in your configure.ac
file, e.g.:

AM_INIT_AUTOMAKE([1.9])

This is what we do in the ACE/TAO configure.ac files.

HTH,
-Ossama
--
Ossama Othman < XXXX@XXXXX.COM >