CFLAGS and other flag variables

2024-07-16 Thread Alejandro Colomar
Hi Paul! Usual compilation in a makefile is something like foo.o: foo.c; $(CC) $(CFLAGS) $< -o $@ If a project needs some CFLAGS, I guess it would do the following CFLAGS ?= $(shell pkgconf --cflags somedep) But then, a user must not blindly overwrite CFLAGS. Those missing fla

Re: CFLAGS and other flag variables

2024-07-16 Thread Sébastien Hinderer
Hello, I'd say to keep all your C compiler flags in a separate variable, MY_CFLAGS, say. Then your rule shoudlmention the two variables, e.g.: %.o: %.c $(CC) $(MY_CFLAGS) $(CFLAGS) -c $< In this way, users can specify the CFLAGS they want without risking to accidentally override somethi

Re: CFLAGS and other flag variables

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 15:37 +0200, Alejandro Colomar wrote: > However, I think this is not standard practise.  Is there any > standard (or de-facto standard) practice regarding these variables? Generally users who want to have more sophisticated build systems don't try to re-use the built-in recip

Re: CFLAGS and other flag variables

2024-07-16 Thread Alejandro Colomar
Hi Paul, On Tue, Jul 16, 2024 at 10:16:27AM GMT, Paul Smith wrote: > On Tue, 2024-07-16 at 15:37 +0200, Alejandro Colomar wrote: > > However, I think this is not standard practise.  Is there any > > standard (or de-facto standard) practice regarding these variables? > > Generally users who want t

Re: CFLAGS and other flag variables

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 16:27 +0200, Alejandro Colomar wrote: > > Instead these standards recommend creating your own pattern rules > > to > > avoid being limited to only the default settings; for example: > > > > EXTRA_CFLAGS := $(shell pkgconf --cflags somedep) > > > > %.o : %.c > >    

Re: CFLAGS and other flag variables

2024-07-16 Thread Alejandro Colomar
Hi Paul, On Tue, Jul 16, 2024 at 10:37:59AM GMT, Paul Smith wrote: > On Tue, 2024-07-16 at 16:27 +0200, Alejandro Colomar wrote: > > > Instead these standards recommend creating your own pattern rules > > > to > > > avoid being limited to only the default settings; for example: > > > > > > E

CC ?= gcc

2024-07-16 Thread Alejandro Colomar
[I'm not subscribed to the list; please keep me in CC] Hi Paul, Am I doing anything wrong? alx@debian:~/tmp/make$ env | grep CC QT_ACCESSIBILITY=1 alx@debian:~/tmp/make$ cat GNUmakefile GNUMAKEFLAGS += --no-builtin-rules GNUMAKEFLAGS += --no-builtin-varia

Re: CC ?= gcc

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 17:34 +0200, Alejandro Colomar wrote: > Hi Paul, > > Am I doing anything wrong? I don't know because you didn't actually tell me what you expected to see or what you were trying to accomplish.

Re: CC ?= gcc

2024-07-16 Thread Alejandro Colomar
On Tue, Jul 16, 2024 at 05:34:42PM GMT, Alejandro Colomar wrote: > [I'm not subscribed to the list; please keep me in CC] > > Hi Paul, Hi Paul, > Am I doing anything wrong? Sorry for not saying it explicitly. > > alx@debian:~/tmp/make$ env | grep CC > QT_ACCESSIBILITY=1 > al

Re: CC ?= gcc

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 17:53 +0200, Alejandro Colomar wrote: > And now I say:  If CC is not set in the Makefile (I didn't) nor in > the > environment (I didn't either), set it to foo. > > > >   $(info $(CC)) > > I expect this should print "foo". > > >   alx@debian:~/tmp/make$ make > >   cc > > B

Re: CC ?= gcc

2024-07-16 Thread Alejandro Colomar
Hi Paul, On Tue, Jul 16, 2024 at 12:52:05PM GMT, Paul Smith wrote: > On Tue, 2024-07-16 at 17:53 +0200, Alejandro Colomar wrote: > > And now I say:  If CC is not set in the Makefile (I didn't) nor in > > the > > environment (I didn't either), set it to foo. > > > > > >   $(info $(CC)) > > > > I

Re: CC ?= gcc

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 19:43 +0200, Alejandro Colomar wrote: > I used the following: > > < < > < <   alx@debian:~/tmp/make$ env | grep CC > < <   QT_ACCESSIBILITY=1 > < <   alx@debian:~/tmp/make$ cat GNUmakefile > < <   GNUMAKEFLAGS += --no-builtin-rules > < <   GNUMAKEFLAGS +=

Re: CC ?= gcc

2024-07-16 Thread Alejandro Colomar
Hi Paul, On Tue, Jul 16, 2024 at 01:56:46PM GMT, Paul Smith wrote: > On Tue, 2024-07-16 at 19:43 +0200, Alejandro Colomar wrote: > > I used the following: > > > > < < > > < <   alx@debian:~/tmp/make$ env | grep CC > > < <   QT_ACCESSIBILITY=1 > > < <   alx@debian:~/tmp/make$ cat GNUma

GNUMAKEFLAGS vs MAKEFLAGS

2024-07-16 Thread Alejandro Colomar
Hi! As discussed in a different thread, the docs claim that GNUMAKEFLAGS and MAKEFLAGS are treated in the same way. All else equal, since I'm using GNU-specific flags, I think I should be using GNUMAKEFLAGS. However, Paul said that I should use MAKEFLAGS, because GNUMAKEFLAGS is not special when

Re: GNUMAKEFLAGS vs MAKEFLAGS

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 20:27 +0200, Alejandro Colomar wrote: > As discussed in a different thread, the docs claim that GNUMAKEFLAGS > and > MAKEFLAGS are treated in the same way. > > All else equal, since I'm using GNU-specific flags, I think I should > be > using GNUMAKEFLAGS. > > However, Paul s

Re: GNUMAKEFLAGS vs MAKEFLAGS

2024-07-16 Thread Alejandro Colomar
Hi Paul, On Tue, Jul 16, 2024 at 02:39:11PM GMT, Paul Smith wrote: > On Tue, 2024-07-16 at 20:27 +0200, Alejandro Colomar wrote: > > As discussed in a different thread, the docs claim that GNUMAKEFLAGS > > and > > MAKEFLAGS are treated in the same way. > > > > All else equal, since I'm using GNU-

Re: GNUMAKEFLAGS vs MAKEFLAGS

2024-07-16 Thread Paul Smith
On Tue, 2024-07-16 at 20:56 +0200, Alejandro Colomar wrote: > > That is, this does what you expect: > > > >    $ GNUMAKEFLAGS=-Rr make -f Makefile > > But this would be quite insane, isn't it?  (Except during recursive > make(1), which is also insane in its own way.)  :-) Yes, very likely this w

Re: CFLAGS and other flag variables

2024-07-16 Thread Kaz Kylheku
On 2024-07-16 06:37, Alejandro Colomar wrote: > Hi Paul! > > Usual compilation in a makefile is something like > > foo.o: foo.c; $(CC) $(CFLAGS) $< -o $@ You should only need: foo.o: foo.c because there is a built-in recipe for making .o files from .c which uses $(CC) and $(CFLAGS), al