On Mon, 29 Jan 2018 10:05:51 +0000
Nick <suckless-dev_AT_njw.me.uk> wrote:
> Quoth Yuri:
> > You should also change your config.mk files to allow external optimization
> > and other flags. For example:
> >
> > > CFLAGS = -std=c99 -Wall -pedantic -O2
> >
> > should be changed to
> >
> > > CFLAGS ?= -O2
> >
> > > CFLAGS += -std=c99 -Wall -pedantic -O2
> >
> > This way you can allow externally supplied optimization flags while still
> > being able to add your own flags. Same with CPPFLAGS and LDFLAGS.
>
> I believe the reason suckless projects stick to = rather than += or
> ?= is that they aren't POSIX / OSI standard. I don't think there's a
> compelling reason to switch to your syntax, as distribution builders
> or whoever can still easily see what the CFLAGS were and add to them
> if they want or need to.
>
> Nick
>
Indeed POSIX only defines =. An alternative would be to do
_CFLAGS = -std=c99 -Wall -pedantic -O2 $(CFLAGS)
but I think it is preferable if the package maintainer just
take the values found in config.mk, made necessary changes
(such as add flags for specific OSes), add the package
managers flags, and invoke make(1) with those values. However,
if the package maintainer is comfortable with assuming make(1)
supports ?= and +=, use sed(1) on config.mk, and he will not
have to change if config.mk has changed when a new version is
published.
Mattias Andrée
Received on Mon Jan 29 2018 - 11:17:24 CET