[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
automake links my C programs with the C++ compiler
From: |
Bruno Haible |
Subject: |
automake links my C programs with the C++ compiler |
Date: |
Thu, 24 Aug 2006 15:39:33 +0200 |
User-agent: |
KMail/1.9.1 |
Hi,
Some of the gettext programs contain or don't contain C++ source code,
depending on the platform and configure options. Automake-1.9.6 and -1.9b
emit rules to always link the programs with the C++ compiler. For
automake-1.9.6 this was easy to work around:
# Linking with C++ libraries is needed _only_ on mingw and Cygwin.
if !WOE32DLL
CXXLINK = $(LINK)
endif
Now, in automake-1.9b, thanks to this announced change:
Per-target flags are now correctly handled in link rules.
the workaround becomes much more complex: I would have to override all
of the following variables:
libgettextsrc_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(libgettextsrc_la_LDFLAGS) $(LDFLAGS) -o $@
msgattrib_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(msgattrib_LDFLAGS) $(LDFLAGS) -o $@
msgcat_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(msgcat_LDFLAGS) $(LDFLAGS) -o $@
msgcomm_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(msgcomm_LDFLAGS) $(LDFLAGS) -o $@
msgconv_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(msgconv_LDFLAGS) $(LDFLAGS) -o $@
msgen_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(msgen_LDFLAGS) $(LDFLAGS) -o $@
msgfilter_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(msgfilter_LDFLAGS) $(LDFLAGS) -o $@
msggrep_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(msggrep_LDFLAGS) $(LDFLAGS) -o $@
msgmerge_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(msgmerge_LDFLAGS) $(LDFLAGS) -o $@
xgettext_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(xgettext_LDFLAGS) $(LDFLAGS) -o $@
So, can you please do something about the original problem? Here is a
testcase.
=========================== Makefile.am =========================
AUTOMAKE_OPTIONS = 1.5 foreign
lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = foo1.c
if WOE32DLL
libfoo_la_SOURCES += foo2.cc
endif
bin_PROGRAMS = msgfmt msgmerge
if WOE32DLL
msgfmt_SOURCES = c++msgfmt.cc
else
msgfmt_SOURCES = msgfmt.c
endif
if WOE32DLL
msgmerge_SOURCES = c++msgmerge.cc
else
msgmerge_SOURCES = msgmerget.c
endif
msgfmt_CPPFLAGS = -DPROG=\"msgfmt\"
msgmerge_CPPFLAGS = -DPROG=\"msgmerge\"
msgfmt_LDFLAGS = -lfoo
msgmerge_LDFLAGS = -lfoo
=========================== configure.ac =========================
AC_INIT
AC_CONFIG_SRCDIR(foo1.c)
AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE(foo, 0.0)
AM_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_CXX
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
if test "$enable_shared" = yes; then
case "$host_os" in
mingw* | cygwin*) is_woe32dll=yes ;;
*) is_woe32dll=no ;;
esac
else
is_woe32dll=no
fi
AM_CONDITIONAL([WOE32DLL], [test $is_woe32dll = yes])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
==================================================================
$ mkdir m4
$ cp .../libtool-1.5.22/m4/libtool.m4 m4/libtool.m4
$ cp .../libtool-1.5.22/ltmain.sh ltmain.sh
$ aclocal -I m4
$ autoconf
$ autoheader
$ automake -a -c
You can see that in the generated file
- The libfoo.la rule always uses the $(CXXLINK) variable,
- The msgfmt$(EXEEXT), msgmerge$(EXEEXT) rules always use the
$(msgfmt_LINK) resp. $(msgmerge_LINK) variables, and these are always
defined to a value starting with $(LIBTOOL) --tag=CXX ...
Can you change this to a conditional definition of these rules and variables,
matching the WOE32DLL condition in the Makefile.am and using --tag=CC when
no C++ source file is involved?
If this is not possible before automake-1.10: Can you refactor the common
part of these *_LINK variables, namely
$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS)
into a single variable, that I could override?
Bruno
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- automake links my C programs with the C++ compiler,
Bruno Haible <=