When setting package/lib _SOURCES or per-package/lib flags (CFLAGS, LDFLAGS, LDADD, etc.) conditionally, is it better to conditionally append to the package's flags, e.g.:
bin_PPROGRAMS = mypkg
mypkg_SOURCES = mypkg.c
if OS1
mypkg_SOURCES += os1.c
else
if OS2
mypkg_SOURCES += os2.c
endif
endif
or to conditionally assign variables and concatenate them all into the package's flags (whether populated or null), e.g.:
if OS1
os1_src = os1.c
else
if OS2
os2_src = os2.c
endif
endif
bin_PROGRAMS = mypkg
mypkg_SOURCES = mypkg.c $(os1_src) $(os2_src)
I've seen it both ways and I can see advantages to each. With the former, the actual final action of adding those flags to the package are clear in the conditional, and you haven't crowded the line with variables that don't actually mean anything in a given build. In the latter, what's actually included in the package is consolidated on one line and you don't have unseen appendment happening somewhere else, but you might not really know what's going on in that opaque variable name.
I guess another option is to do something like option 2, but assign the variables with the configure script (configure.ac with AC_SUBST). But I've been keeping my configure scripts purely detecting features available, and choosing which to use in Makefiles.
Does one of them have a technical downside or nasty side-effect?