Re: conditionals in Makefile.am
On Wed, Jun 30, 2010 at 9:56 AM, John Calcote john.calc...@gmail.com wrote: On 6/30/2010 3:41 AM, Wesley Smith wrote: From the automake manual: You may only test a single variable in an if statement, possibly negated using ‘!’. The else statement may be omitted. Conditionals may be nested to any depth. You may specify an argument to else in which case it must be the negation of the condition used for the current if. Similarly you may specify the condition that is closed on the endif line: if DEBUG DBG = debug else !DEBUG DBG = endif !DEBUG What's the purpose of specifying the condition that is closed? I've never seen this kind of construct before. Is it a substitute for elseif? Documentation. There may be several dozen lines of code between the if and the else. A reader may be wondering... else what? John Does it matter if the endif condition is COND or !COND?
conditionals in Makefile.am
From the automake manual: You may only test a single variable in an if statement, possibly negated using ‘!’. The else statement may be omitted. Conditionals may be nested to any depth. You may specify an argument to else in which case it must be the negation of the condition used for the current if. Similarly you may specify the condition that is closed on the endif line: if DEBUG DBG = debug else !DEBUG DBG = endif !DEBUG What's the purpose of specifying the condition that is closed? I've never seen this kind of construct before. Is it a substitute for elseif? wes
Re: conditionals in Makefile.am
On 6/30/2010 3:41 AM, Wesley Smith wrote: From the automake manual: You may only test a single variable in an if statement, possibly negated using ‘!’. The else statement may be omitted. Conditionals may be nested to any depth. You may specify an argument to else in which case it must be the negation of the condition used for the current if. Similarly you may specify the condition that is closed on the endif line: if DEBUG DBG = debug else !DEBUG DBG = endif !DEBUG What's the purpose of specifying the condition that is closed? I've never seen this kind of construct before. Is it a substitute for elseif? Documentation. There may be several dozen lines of code between the if and the else. A reader may be wondering... else what? John
Re: Conditionals in Makefile.am
Pekka == Pekka Riikonen [EMAIL PROTECTED] writes: [...] Pekka I don't think changing this would be hard (haven't Pekka looked at code though), and it doesn't cause Pekka compatibility problems, and would make the conditionals Pekka a lot more flexible. Ideas? I think this would be nice; however it's probably more difficult than you might think... -- Alexandre Duret-Lutz
Re: Conditionals in Makefile.am
Pekka == Pekka Riikonen [EMAIL PROTECTED] writes: [...] Pekka FILES = \ Pekka somefile.c \ Pekka if HAVE_SOMETHING Pekka someotherfile.c \ Pekka endif Pekka if HAVE_SOMETHING_ELSE Pekka somethingelse.c \ Pekka endif Pekka something.c Pekka This sort of thing is not possible now and makes it Pekka really ugly to use the conditionals in makefiles, imo. Pekka Currently only way to do this is to conditionalize the Pekka entire FILES variable. Alternatively it could just Pekka remove the lines not to be included. Sorry, I forgot to reply to this. A simpler solution is to use a sub-variable. FILES = somefile.c $(FILES_IF_SOMETHING) $(FILES_IF_SOMETHING_ELSE) something.c if HAVE_SOMETHING FILES_IF_SOMETHING = someotherfile.c endif if HAVE_SOMETHING_ELSE FILES_IF_SOMETHING_ELSE = somethingelse.c endif [...] -- Alexandre Duret-Lutz
Re: Conditionals in Makefile.am
: Pekka This sort of thing is not possible now and makes it : Pekka really ugly to use the conditionals in makefiles, imo. : Pekka Currently only way to do this is to conditionalize the : Pekka entire FILES variable. Alternatively it could just : Pekka remove the lines not to be included. : : Sorry, I forgot to reply to this. A simpler solution is to use : a sub-variable. : : FILES = somefile.c $(FILES_IF_SOMETHING) $(FILES_IF_SOMETHING_ELSE) something.c : if HAVE_SOMETHING : FILES_IF_SOMETHING = someotherfile.c : endif : if HAVE_SOMETHING_ELSE : FILES_IF_SOMETHING_ELSE = somethingelse.c : endif : Yes, I know. This is what I've been using. The reason I posted this was that I'm creating currently three different distributions from the same code base, and it would be really nice to be able say what goes into what distribution without messing up all Makefiles and repeating everything three times in all Makefiles. :) Also, the reason was to be able to make more detailed list of what goes into a distribution (like which of the n features) by using conditionals in _SOURCES and _HEADERS, etc. Pekka Pekka Riikonen priikone at silcnet.org Secure Internet Live Conferencing (SILC) http://silcnet.org/
Conditionals in Makefile.am
A suggestion to conditionals in Makefiles. Conditionals inside Makefiles could be changed to replace the not-included lines with empty lines instead of commenting them with '#'. If it would just replace them with empty lines it would allow configuration like this: FILES = \ somefile.c \ if HAVE_SOMETHING someotherfile.c \ endif if HAVE_SOMETHING_ELSE somethingelse.c \ endif something.c This sort of thing is not possible now and makes it really ugly to use the conditionals in makefiles, imo. Currently only way to do this is to conditionalize the entire FILES variable. Alternatively it could just remove the lines not to be included. I don't think changing this would be hard (haven't looked at code though), and it doesn't cause compatibility problems, and would make the conditionals a lot more flexible. Ideas? Pekka Pekka Riikonen priikone at silcnet.org Secure Internet Live Conferencing (SILC) http://silcnet.org/
Re: Conditionals in Makefile.am
Filip == Filip Kaliski [EMAIL PROTECTED] writes: Filip I have AM_CONDITIONAL(ENABLE_BAR, ... ) in configure.in Filip and I want to have Filip if ENABLE_BAR Filip lib_LTLIBARAIES=libfoo.la Filip libfoo_la_LDADD=-lbaz Filip ... Filip else Filip noninst_LTILIBRARIES=libfoo.la Filip ... Filip endif Filip in Makefile.am, but it doesn't work, automake wants to Filip define both of ..._LTLIBRARIES and screams that it is Filip alredy defined (while parsing second) :-( This looks like a bug. Filip Does anyone know how to solve it? I think you can workaround Automake as follows (untested): EXTRA_LTLIBRARIES = libfoo.la libfoo_la_SOURCES = ... if ENABLE_BAR lib_LTLIBRARIES = @LIBFOO1@ libfoo_la_LIBADD = -lbaz libfoo_la_LDFLAGS = -rpath $(libdir) else noinst_LTLIBRARIES = @LIBFOO2@ endif and add AC_SUBST([LIBFOO1], [libfoo.la]) AC_SUBST([LIBFOO2], [libfoo.la]) to your configure.ac. -- Alexandre Duret-Lutz
Conditionals in Makefile.am
I have AM_CONDITIONAL(ENABLE_BAR, ... ) in configure.in and I want to have if ENABLE_BAR lib_LTLIBARAIES=libfoo.la libfoo_la_LDADD=-lbaz ... else noninst_LTILIBRARIES=libfoo.la ... endif in Makefile.am, but it doesn't work, automake wants to define both of ..._LTLIBRARIES and screams that it is alredy defined (while parsing second) :-( Does anyone know how to solve it? -- Filip Kaliski [EMAIL PROTECTED]