From 916efa0f7d93f7fd65552640dfea488d3d59d198 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sun, 31 Oct 2021 15:00:24 -0400 Subject: [PATCH] Use clang when possible for tools (#990) * Use clang when possible for tools * Add LLD ?= 0 --- tools/Makefile | 18 ++++++++++++++++-- tools/vtxdis.c | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 9b545d1a83..d0af5c3715 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,7 +1,21 @@ -CC := gcc CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2 PROGRAMS := yaz0 makeromfs elf2rom mkldscript vtxdis -ZAPD := ZAPD/ZAPD.out + +ifeq ($(shell command -v clang >/dev/null 2>&1; echo $$?),0) + CC := clang +else + CC := gcc +endif + +LLD ?= 0 + +ifeq ($(shell command -v ld.lld >/dev/null 2>&1; echo $$?),0) + LLD := 1 +endif + +ifneq ($(LLD),0) + CFLAGS += -fuse-ld=lld +endif all: $(PROGRAMS) cd ZAPD && $(MAKE) diff --git a/tools/vtxdis.c b/tools/vtxdis.c index 1ba6969635..8debd89e0c 100644 --- a/tools/vtxdis.c +++ b/tools/vtxdis.c @@ -254,4 +254,4 @@ int main(int argc, char **argv) } return 0; -} \ No newline at end of file +}