On Mon, 26 Jun 2000, Tom Tromey wrote:
> Mo> if WIN
> Mo> sysinit = tkgsWinInit.c
> Mo> endif
>
> Mo> if UNIX
> Mo> sysinit = tkgsUnixInit.c
> Mo> endif
>
> Mo> libtkgs_la_SOURCES = \
> Mo> [ ... ]
> Mo> $(sysinit)
>
> Mo> src/Makefile.am:15: warning: automake does not support conditional
> Mo> definition of sysinit in libtkgs_la_SOURCES
>
> I'm a bit suprised that doesn't work. Well, maybe not too suprised.
> Dealing intelligently with conditionals in every situation is hard.
> Hopefully the next reimplementation of automake will have a smarter
> way of doing this.
>
> Try something like:
>
> if WIN
> ...
> else
> if UNIX
> ...
> endif
> endif
>
> If that fails make the libtkgs_la_SOURCES variable itself conditional
>
> shared = list them
> if WIN
> libtkgs_la_SOURCES = $(shared) ...
> endif
> if UNIX
> ...
> endif
>
> Let us know what you find it.
> (It is particularly sad that I said that. First, I should know.
> Second, nobody should need to know.)
>
> Tom
It is no wonder this is the the top FAQ, this conditional stuff
is a mess!
Here is what I found.
if WIN
sysinit = tkgsWinInit.c
else
if UNIX
sysinit = tkgsUnixInit.c
endif
endif
libtkgs_la_SOURCES = \
tkgs.c \
tkgs.h \
tkgsColor.c \
tkgsColor.h \
tkgsDrawable.c \
tkgsDrawable.h \
tkgsDriver.h \
tkgsFont.c \
tkgsFont.h \
tkgsInit.c \
tkgsInt.h \
tkgsObj.c \
tkgsObj.h \
$(sysinit)
BECOMES:
lib_LTLIBRARIES = libtkgs.la
#sysinit = #tkgsWinInit.c
sysinit = tkgsUnixInit.c
libtkgs_la_SOURCES = \
tkgs.c \
tkgs.h \
tkgsColor.c \
tkgsColor.h \
tkgsDrawable.c \
tkgsDrawable.h \
tkgsDriver.h \
tkgsFont.c \
tkgsFont.h \
tkgsInit.c \
tkgsInt.h \
tkgsObj.c \
tkgsObj.h \
$(sysinit)
So at least that worked, even if
it is a little bit ugly. Here
are some things that did not
work.
if WIN
sysinit = tkgsWinInit.c
endif
if UNIX
sysinit = tkgsUnixInit.c
endif
% automake
src/Makefile.am:15: warning: automake does not support conditional
definition of sysinit in libtkgs_la_SOURCES
Here is how I would have thought things
would have worked.
libtkgs_la_SOURCES = ...
if WIN
libtkgs_la_SOURCES += tkgsWinInit.c
endif
if UNIX
libtkgs_la_SOURCES += tkgsUnixInit.c
endif
src/Makefile.am:7: libtkgs_la_SOURCES defined both conditionally and
unconditionally
The other thing that I got working (be warned this is also ugly)
is to create Makefile.am in both the unix and win subdirs and
then select the one to build based on a AC_SUBST(PLATFORM) like so:
SUBDIRS = common @PLATFORM@
I also found that if you screw up and put some thing like:
SUBDIR = dir1 dir2
It will silently fail and it does not warn you should
have put SUBDIRS.
cheers
Mo DeJong
Red Hat Inc