Re: Mixing C and C++?

2008-06-06 Thread Ralf Wildenhues
Hi Erik,

* Erik de Castro Lopo wrote on Fri, Jun 06, 2008 at 11:25:45AM CEST:
 
 I have an project that uses automake, autoconf and libtool and for one
 of the generated binaries, I'm trying to mix C and C++, but automake is
 giving me the following error:
 
 tests/Makefile.am: object `cpp_test.$(OBJEXT)' created by `cpp_test.cc'
 and `cpp_test.c'
 
 My project does have a cpp_test.cc but does not contain cpp_test.c.

Please post a small example package that exposes this, or, if that's too
much work, the configure.ac and tests/Makefile.am files; and state which
program versions you use.

Thanks,
Ralf




Re: Mixing C and C++?

2008-06-06 Thread Erik de Castro Lopo
Ralf Wildenhues wrote:

 Please post a small example package that exposes this, or, if that's too
 much work, the configure.ac and tests/Makefile.am files; and state which
 program versions you use.

Trying to set up a test showed up an even bigger problem. I'm using:

automake (GNU automake) 1.9.6
autoconf (GNU Autoconf) 2.61
ltmain.sh (GNU libtool) 1.5.26 Debian 1.5.26-1ubuntu1 (1.1220.2.493 
2008/02/01 16:58:18)

installed from packages on an Hardy Heron machine.

The test project is here:

http://www.mega-nerd.com/tmp/amtest-0.1.tar.gz

If I extract these sources and do:

./autogen.sh (which also runs configure)
make

it results in the following error:

if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT amtest.o -MD -MP \
 -MF .deps/amtest.Tpo -c -o amtest.o amtest.c; \
then mv -f .deps/amtest.Tpo .deps/amtest.Po; else rm -f \
.deps/amtest.Tpo; exit 1; fi
/bin/bash ./libtool --tag=CC --mode=link gcc  -g -O2   -o amtest  amtest.o  
mkdir .libs
gcc -g -O2 -o amtest amtest.o   
amtest.o: In function `main':
/tmp/amtest-0.1/amtest.c:10: undefined reference to `cpp_test'

For some reason, the automake generated Makefile drops the C++ object
file from the link.

What am I doing wrong here?

Cheers,
Erik
-- 
-
Erik de Castro Lopo
-
Two hands working can do more than a thousand clasped in prayer.
-- anonymous




Re: Mixing C and C++?

2008-06-06 Thread Ralf Wildenhues
* Erik de Castro Lopo wrote on Fri, Jun 06, 2008 at 01:49:15PM CEST:
 http://www.mega-nerd.com/tmp/amtest-0.1.tar.gz

 gcc -g -O2 -o amtest amtest.o   
 amtest.o: In function `main':
 /tmp/amtest-0.1/amtest.c:10: undefined reference to `cpp_test'
 
 For some reason, the automake generated Makefile drops the C++ object
 file from the link.

Well, try this for a Makefile.am instead (untested).  HTH.

Cheers,
Ralf

## Process this file with automake to produce Makefile.in
bin_PROGRAMS = amtest
amtest_SOURCES = cpp.cc amtest.c amtest.h
EXTRA_DIST = autogen.sh
TESTS = amtest




install-exec-hook question

2008-06-06 Thread Maynard Johnson
Hi,
I have a need to run some post-install commands that may print a message
that the user must see (so it must be near the end of the output).  I
was hoping that adding the install-exec-hook in my Makefile.am was the
answer.  However, when I run 'make install', what I see is something
like this:
---
Making install in .
make[1]: Entering directory 'my_project_dir'
make[2]: Entering directory 'my_project_dir'
make  install-exec-hook
make[3]: Entering directory 'my_project_dir'
this is where my message to the user shows up
make[3]: Leaving directory `my_project_dir'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `my_project_dir'
make[1]: Leaving directory `my_project_dir'
. . . . then I see all of the usual messages where make recurses through
the subdirectories of my projects and installs executables and data
where appropriate.  So, obviously my post-install message gets lost in
the stream of install messages.
--

In some other posting on this list, I saw a statement that
install-exec-hook recipe is executed as part of install-exec-am.  In
the generated Makefile, the install-exec-am target looks like this:

install-exec-am: install-exec-local
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook

If running on a multi-processor system, does the 'make
install-exec-hook' line run in parallel with the normal install?  In
short, is there a way to print out a user message at the end of 'make
install'?

Thanks in advance for any help.

Regards,
-Maynard Johnson





Re: Mixing C and C++?

2008-06-06 Thread Olly Betts
On 2008-06-06, Erik de Castro Lopo [EMAIL PROTECTED] wrote:
 Ralf Wildenhues wrote:

 amtest_SOURCES = cpp.cc amtest.c amtest.h

 Ah, that fixed that problem. The test project now works as it should.

 Getting back to real project I managed to fix that as well, but I
 not sure what I was doing wrong.

You'd written test_sources = ... which has no special meaning to
automake.  You should have written amtest_SOURCES =   In the
absence of amtest_SOURCES, automake implicitly assumes amtest_SOURCES =
amtest.c.

Cheers,
Olly





A global _CFLAGS assigment?

2008-06-06 Thread Steven Woody
Hi,

My project tree have many Makefile.am in a recursive directory tree
and I want every Makefile.am has a line some thing like xxx_CFLAGS =
-Wall.  What's the way to do that?  You see, there are many different
xxx_ in different Makefile.am.

Thanks.

-
narke




Re: A global _CFLAGS assigment?

2008-06-06 Thread Ralf Wildenhues
Hello Steven,

* Steven Woody wrote on Fri, Jun 06, 2008 at 06:17:30PM CEST:
 
 My project tree have many Makefile.am in a recursive directory tree
 and I want every Makefile.am has a line some thing like xxx_CFLAGS =
 -Wall.  What's the way to do that?  You see, there are many different
 xxx_ in different Makefile.am.

I don't quite understand, but you're either looking for
  AM_CFLAGS = ...

(you can also AC_SUBST([AM_CFLAGS], [...]) from within configure.ac)
or for putting a bunch of 'include $(top_srcdir)/.../fragment.am' into
all the Makefile.am files to have some common code.

Hope that helps.

Cheers,
Ralf




How to define a `prefix' other than the default vaule?

2008-06-06 Thread Steven Woody
Hi,

I want all my stuff by default installed in /usr/local/mypkg unless
user specified another 'preflex' value when run 'configure' script.
How can I?  Thank you.

-
narke




Re: How to define a `prefix' other than the default vaule?

2008-06-06 Thread John Calcote
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Steven Woody wrote:
 Hi,
 
 I want all my stuff by default installed in /usr/local/mypkg unless
 user specified another 'preflex' value when run 'configure' script.
 How can I?  Thank you.


Try AC_PREFIX_DEFAULT([/usr/local/mypkg]) in your configure.ac file.

Regards,
John
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFISWYddcgqmRY/OH8RAsXIAJ9SS1QvfTBYebE2dsp3P7Aw23EEsQCgmhRC
RJyC4S6RrfFfRcHahPV4FnY=
=t2eo
-END PGP SIGNATURE-




Re: How to define a `prefix' other than the default vaule?

2008-06-06 Thread Ralf Wildenhues
* Steven Woody wrote on Fri, Jun 06, 2008 at 06:22:40PM CEST:
 
 I want all my stuff by default installed in /usr/local/mypkg unless
 user specified another 'preflex' value when run 'configure' script.
 How can I?  Thank you.

http://www.gnu.org/software/autoconf/manual/html_node/Default-Prefix.html




Re: A global _CFLAGS assigment?

2008-06-06 Thread Steven Woody
On Sat, Jun 7, 2008 at 12:22 AM, Ralf Wildenhues [EMAIL PROTECTED] wrote:
 Hello Steven,

 * Steven Woody wrote on Fri, Jun 06, 2008 at 06:17:30PM CEST:

 My project tree have many Makefile.am in a recursive directory tree
 and I want every Makefile.am has a line some thing like xxx_CFLAGS =
 -Wall.  What's the way to do that?  You see, there are many different
 xxx_ in different Makefile.am.

 I don't quite understand, but you're either looking for
  AM_CFLAGS = ...

But I have to insert this line in every Makefile.am in the tree,
right? That's I dont want.  But your below solution using AC_SUBST
looks making sense.


 (you can also AC_SUBST([AM_CFLAGS], [...]) from within configure.ac)
 or for putting a bunch of 'include $(top_srcdir)/.../fragment.am' into
 all the Makefile.am files to have some common code.

 Hope that helps.

The big problem may be, the AM_CFLAGS will disappear if in a
Makefile.am, there is a _CFLAGS.




Re: How to define a `prefix' other than the default vaule?

2008-06-06 Thread Steven Woody
On Sat, Jun 7, 2008 at 12:30 AM, John Calcote [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Steven Woody wrote:
 Hi,

 I want all my stuff by default installed in /usr/local/mypkg unless
 user specified another 'preflex' value when run 'configure' script.
 How can I?  Thank you.


 Try AC_PREFIX_DEFAULT([/usr/local/mypkg]) in your configure.ac file.


Thank you!




Re: A global _CFLAGS assigment?

2008-06-06 Thread Ralf Wildenhues
* Steven Woody wrote on Fri, Jun 06, 2008 at 06:44:46PM CEST:
 On Sat, Jun 7, 2008 at 12:22 AM, Ralf Wildenhues [EMAIL PROTECTED] wrote:
 
  (you can also AC_SUBST([AM_CFLAGS], [...]) from within configure.ac)

 The big problem may be, the AM_CFLAGS will disappear if in a
 Makefile.am, there is a _CFLAGS.

_CFLAGS = $(AM_CFLAGS) -additional-flags ...




Re: install-exec-hook question

2008-06-06 Thread Ralf Wildenhues
* Maynard Johnson wrote on Wed, Jun 04, 2008 at 08:21:37PM CEST:
 I have a need to run some post-install commands that may print a message
 that the user must see (so it must be near the end of the output).

You have a graph of Makefile.am vertices connected by directed edges,
SUBDIRS entries.  Even with parallel make, this graph is traversed
serially, in the order induced by SUBDIRS ordering (presence of '.' in
this list defaults to last, if not listed explicitly).  Locate the last
vertex traversed.  Put your message in that Makefile.am.

 If running on a multi-processor system, does the 'make
 install-exec-hook' line run in parallel with the normal install?

Well, install-exec-hook runs strictly after other install-exec* thingies
run *in that directory*.  But that says nothing about the order in which
directories are traversed, and it does not either say anything about the
order with respect to install-data* thingies; in fact, the latter are
likely to run concurrently with a parallel make install, although
without parallel make, the data thingies come after the exec ones.
(For GNU make, you could use '.NOTPARALLEL:' in that Makefile.)

Still, with this method, you have at least a set of leaving directory
messages from make unless you 'make -s'.

 In short, is there a way to print out a user message at the end of
 'make install'?

Here's a different method, rather crazy if you try to understand it; and
the quoting is wild, and if you want to use variables in your message,
you need to pass them to config.status via the third argument of
AC_CONFIG_COMMANDS (please read the details in the Autoconf manual if
needed).  FWIW, there are TABs before the echo commands.

AC_CONFIG_FILES([Makefile],
  [sed '/^install:/{
s/^/my-/
i\
install: my-install\
\   echo Installation is really,\
\   echo really done now
}
   '  Makefile  Makefile.t
   mv -f Makefile.t Makefile
  ])


Hope that helps, or at least amuses.

Cheers,
Ralf




Re: A global _CFLAGS assigment?

2008-06-06 Thread Steven Woody
On Sat, Jun 7, 2008 at 1:23 AM, Ralf Wildenhues [EMAIL PROTECTED] wrote:
 * Steven Woody wrote on Fri, Jun 06, 2008 at 06:44:46PM CEST:
 On Sat, Jun 7, 2008 at 12:22 AM, Ralf Wildenhues [EMAIL PROTECTED] wrote:
 
  (you can also AC_SUBST([AM_CFLAGS], [...]) from within configure.ac)

 The big problem may be, the AM_CFLAGS will disappear if in a
 Makefile.am, there is a _CFLAGS.

 _CFLAGS = $(AM_CFLAGS) -additional-flags ...


Cool!  It works, Thank you!

Before received your post, I tried
  _CFLAGS = @AM_CFLAGS@ -additional-flags ...
but failed, but
  _CFLAGS = @CXXFLAGS@ -additional-flags ...
will passed the make though this is not what I want.  I just wonder
why @CXXFLAGS@ is okay while @AM_CFLAGS@ not




Why I can not overwrite CXXFLAGS values?

2008-06-06 Thread Steven Woody
In my system, the default CXXFLAGS is '-g -O2'.  But, for a particular
program, I need -O0 and without -g.  I tried something like:
  bin_PROGRAS = xxx
  xxx_CXXFLAGS = -O0
in Makefile.am.  But, the final CXXFLAGS used when I compile is
actually -O0 -g -O2, the default CXXFLAGS appended to my xxx_CXXFLAGS.
 What should I do?

Thanks in advance.

-
narke




How can I change shared library's version number?

2008-06-06 Thread Steven Woody
When I use autoconf/automake with its integrated libtool to build a
shared library, I got shared libraray named 'libfoo.so.0.0.0'.  I
don't sure where the 0.0.0 comes from, and I don't like it.  How can I
change it?  I searched info page but found no answer.

Thanks in advance.

-
narke




Re: How can I change shared library's version number?

2008-06-06 Thread Andreas Schwab
Steven Woody [EMAIL PROTECTED] writes:

 When I use autoconf/automake with its integrated libtool to build a
 shared library, I got shared libraray named 'libfoo.so.0.0.0'.  I
 don't sure where the 0.0.0 comes from, and I don't like it.  How can I
 change it?  I searched info page but found no answer.

See (libtool)Versioning.

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.




Re: Mixing C and C++?

2008-06-06 Thread Erik de Castro Lopo
Olly Betts wrote:

 You'd written test_sources = ... which has no special meaning to
 automake.  You should have written amtest_SOURCES =   In the
 absence of amtest_SOURCES, automake implicitly assumes amtest_SOURCES =
 amtest.c.

Yes, thats what I'd done in the small test project I had created. I
did not make the same mistake in the main project. That one remains
a bit of a mystery.

Cheers,
Erik
-- 
-
Erik de Castro Lopo
-
... a discussion of C++'s strengths and flaws always sounds
like an argument about whether one should face north or east
when one is sacrificing one's goat to the rain god.
-- Thant Tessman




Re: Mixing C and C++?

2008-06-06 Thread Ralf Wildenhues
* Erik de Castro Lopo wrote on Sat, Jun 07, 2008 at 12:13:36AM CEST:
 Organization: Erik Conspiracy Secret Labs

LOL!  It's been several years since I last read about the Eric
conspiracy.

 Olly Betts wrote:
 
  You'd written test_sources = ... which has no special meaning to
  automake.  You should have written amtest_SOURCES =   In the
  absence of amtest_SOURCES, automake implicitly assumes amtest_SOURCES =
  amtest.c.
 
 Yes, thats what I'd done in the small test project I had created. I
 did not make the same mistake in the main project. That one remains
 a bit of a mystery.

Hmm, can you relate the main project to us?  Have you tried automake
-Wall?

Cheers,
Ralf




Re: Mixing C and C++?

2008-06-06 Thread Erik de Castro Lopo
Ralf Wildenhues wrote:

 Hmm, can you relate the main project to us?  Have you tried automake
 -Wall?

Its my main project libsndfile.

I fixed it somehow and can't remember how to get it back into the
state where I reported the bug. Sorry :-)

Cheers,
Erik
-- 
-
Erik de Castro Lopo
-
If you think C++ is not overly complicated, just what is a
protected abstract virtual base pure virtual private destructor
and when was the last time you needed one? -- Tom Cargill