Re: [hackers] [sent] [PATCH 3/3] Makefile: config.mk: Improve Makefile and config.mk

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Wed, 29 Jun 2022 12:21:44 +0200

> Hi Quentin,

Hi Tom o/

> > > # includes and libs
> > > -INCS = -I. -I/usr/include -I/usr/include/freetype2 -I${X11INC}
> > > -LIBS = -L/usr/lib -lc -lm -L${X11LIB} -lXft -lfontconfig -lX11
> > > +INCS = -I/usr/include/freetype2 -I${X11INC}
> > > +LIBS = -lm -L${X11LIB} -lXft -lfontconfig -lX11
> >
> > The -L option should go into LDFLAGS
>
> Since $LIBS is only used to provide $LDFLAGS, we could copy it's contents
> directly into $LDFLAGS and drop $LIBS. Good catch.

No, those are two different things.

LDFLAGS are linker configuration parameters,
like indeed where to search libraries amongst other things.

The LIBS macro is to indicate what libraries to link against;
those are not configuration parameters,
but actual ordered operands in the linking chain.

> > > # flags
> > > CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600
> > > -CFLAGS += -g -std=c99 -pedantic -Wall ${INCS} ${CPPFLAGS}
> > > -LDFLAGS += -g ${LIBS}
> > > -#CFLAGS += -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
> > > -#LDFLAGS += ${LIBS}
> > > +CFLAGS = -std=c99 -pedantic -Wall -Wstrict-prototypes -Wold-style-definition -Os ${INCS} ${CPPFLAGS}
> >
> > The -std option isn't necessary with the default CC.
> > I'd remove any warning from production build,
> > warnings are for development,
> > then developpers can set whatever warnings they like.
> >
> > > # compiler and linker
> > > -CC ?= cc
> > > +CC = cc
> >
> > This should be removed altogether if you want a standard Makefile,
> > then CC will just be the expected c99.
>
> I'd keep the `-std` option and the CC assignment.
> We want to be C99 compliant regardless of which compiler the user decides to use.
> Additionally, CC is a configuration option in all suckless programs and
> to be consistent here seems reasonable, in my opinion.

That's the point. To be compliant with C99, use a c99 compiler,
which is the default compiler called by standard Makefiles.
By defining CC to something non-standard,
we introduce an indirection change here,
that then forces the (non-standard) -std option to be passed to random compiler
in the hope that it'll compatible with it.
If the user decides to replace the standard compiler
with another one, then they'll know which option to pass to it to make it respecting
the original contract.

As for some of the other suckless programs that specify CC,
that's just a legacy format that should be replaced anyway IMO.
Received on Wed Jun 29 2022 - 12:21:44 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 29 2022 - 12:24:30 CEST