Hello
I am trying to create a Makefile.am file for a simple
program that has all its sources in a single directory.
I thought this would be easy, but I just can not seem
to figure out how to tell automake to conditionally
compile one of two files. I must be missing a something
really obvious here.
I am using autoconf, automake, and libtool from the CVS.
The AM_CONDITIONAL in the configure.in file looks like this:
dnl Define an AM_CONDITIONAL for the subsystem we will build
AC_MSG_CHECKING([for subsystem to build])
if test "x$ac_cv_mingw32" = "xyes" ; then
AC_MSG_RESULT([WIN32])
AM_CONDITIONAL(WIN32, `echo true`)
else
AC_MSG_RESULT([X])
AM_CONDITIONAL(X, `echo true`)
fi
Here is my Makefile.am. I just want to compile a single
shared library using libtool.
lib_LTLIBRARIES = libtkgs.la
libtkgs_la_SOURCES = \
tkgs.c \
tkgsColor.c \
tkgsGc.c \
tkgsPS.c \
tkgsCanvas.c \
tkgsDrawable.c \
tkgsObj.c \
tkgsSquare.c
noinst_HEADERS = \
tkgs.h \
tkgsColor.h \
tkgsDriver.h \
tkgsInt.h \
tkgsPS.h \
tkgsWin.h \
tkgsCanvas.h \
tkgsDrawable.h \
tkgsGc.h \
tkgsObj.h \
tkgsSquare.h
if WIN32
libtkgs_la_SOURCES += tkgsWin.c
noinst_HEADERS += tkgsWin.h
endif
if X
libtkgs_la_SOURCES += tkgsXlib.c
noinst_HEADERS += tkgsXlib.h
endif
When I run automake I get the really
confusing error message.
Makefile.am:3: libtkgs_la_SOURCES defined both conditionally and
unconditionally
Makefile.am:13: noinst_HEADERS defined both conditionally and unconditionally
The Makefile.in ends up looking like this:
lib_LTLIBRARIES = libtkgs.la
WIN32_TRUE@libtkgs_la_SOURCES = @WIN32_TRUE@\
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED]\
@WIN32_TRUE@ tkgsWin.c
@X_TRUE@libtkgs_la_SOURCES = @[EMAIL PROTECTED]
@WIN32_TRUE@noinst_HEADERS = @WIN32_TRUE@\
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
@[EMAIL PROTECTED] \
When I run this file, it tries to compile tkgsWin.h
even thought configure properly detected X not WIN32.
gcc -DHAVE_CONFIG_H -I. -I/home/mo/project/tkgs -I. -g -O2 -c
/home/mo/project/t
kgs/tkgsWin.c -Wp,-MD,.deps/tkgsWin.TPlo -fPIC -DPIC -o .libs/tkgsWin.lo
In file included from /home/mo/project/tkgs/tkgsWin.c:4:
/home/mo/project/tkgs/tkgsWin.h:7: windows.h: No such file or directory
make: *** [tkgsWin.lo] Error 1
Could anyone shed some light on this? Is there a better
way to conditionally compile certain files?
Mo DeJong
Red Hat Inc