Makefile: add ability to append to CFLAGS and LDFLAGS
commit1d969afb785a86ad9851c6e1c3253cc11f8507dd
authorPatrick Steinhardt <ps@pks.im>
Mon, 10 Jun 2024 06:38:20 +0000 (10 08:38 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 23:11:43 +0000 (11 16:11 -0700)
tree4d3a7880708f081b88fc057d280c2b034b679c85
parent715ae273822aeba4cbc5c09803d1187acdf2ed86
Makefile: add ability to append to CFLAGS and LDFLAGS

There are some usecases where we may want to append CFLAGS to the
default CFLAGS set by Git. This could for example be to enable or
disable specific compiler warnings or to change the optimization level
that code is compiled with. This cannot be done without overriding the
complete CFLAGS value though and thus requires the user to redeclare the
complete defaults used by Git.

Introduce a new variable `CFLAGS_APPEND` that gets appended to the
default value of `CFLAGS`. As compiler options are last-one-wins, this
fulfills both of the usecases mentioned above. It's also common practice
across many other projects to have such a variable.

While at it, also introduce a matching `LDFLAGS_APPEND` variable. While
there isn't really any need for this variable as there are no default
`LDFLAGS`, users may expect this variable to exist, as well.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile