I want to compile my project with autoconf/automake. There are 2 conditions defined in my configure.ac
AM_CONDITIONAL(HAVE_CLIENT, test $enable-client -eq 1)
AM_CONDITIONAL(HAVE_SERVER, test $enable-server -eq 1)
I want to separate _LIBS from these 2 conditions in Makefile.am
if HAVE_CLIENT
libtest_LIBS = \
$(top_builddir)/libclient.la
else if HAVE_SERVER
libtest_LIBS = \
$(top_builddir)/libserver.la
else
libtest_LIBS =
endif
but else if HAVE_SERVER
does NOT work.
How to write 'else if' in makefile.am?
I would accept ldav1s' answer if I were you, but I just want to point out that 'else if' can be written in terms of 'else's and 'if's in any language:
(The indentation is for clarity. Don't indent the lines, they won't work.)
As you've discovered, you can't do that. You can do:
...
NOTE: DO NOT indent the if then it don't work!
ptomato's code can also be written in a cleaner manner like:
This doesn't answer OP's question but as it's the top result on google, I'm adding it here in case it's useful to anyone else.