diff mbox series

Makefile: default to LD = CC

Message ID 20190131090724.11157-1-uwe@kleine-koenig.org (mailing list archive)
State Mainlined, archived
Headers show
Series Makefile: default to LD = CC | expand

Commit Message

Uwe Kleine-König Jan. 31, 2019, 9:07 a.m. UTC
Usually the compiler is used as linker. Assuming that if someone wants
to change the compiler the linker should be changed, too, simplify that
use case by using "$(CC)" as linker instead of the hard coded "gcc".
This also matches the behaviour of make when using the built-in rules
of GNU Make which include:

	LINK.o = $(CC) $(LDFLAGS) $(TARGET_ARCH)
	%: %.o
		$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luc Van Oostenryck Jan. 31, 2019, 12:59 p.m. UTC | #1
On Thu, Jan 31, 2019 at 10:07:24AM +0100, Uwe Kleine-König wrote:
> Usually the compiler is used as linker. Assuming that if someone wants
> to change the compiler the linker should be changed, too, simplify that
> use case by using "$(CC)" as linker instead of the hard coded "gcc".

Thanks. I'll push it later this evening.

-- Luc
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 9c4bafffcd6e..025bce296cdf 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@  OS = linux
 CC = gcc
 CFLAGS = -O2 -g
 CFLAGS += -Wall -Wwrite-strings
-LD = gcc
+LD = $(CC)
 AR = ar
 PKG_CONFIG = pkg-config
 CHECKER = CHECK=./sparse ./cgcc -no-compile