1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-03-21 16:42:35 +00:00
Files
Interlisp.maiko/bin/linux-compiler.mk

38 lines
1.0 KiB
Makefile

# Select whether to use clang or gcc
# Priority
# 1. If -DUSE_GCC or -DUSE_CLANG on command line (but not both) use the requested compiler.
# 2. If one compiler is installed but not the other, use the installed compiler.
# 3. Use clang
EXISTS_GCC := $(shell command -v gcc)
EXISTS_CLANG := $(shell command -v clang)
ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),)
$(error "Cannot find compiler: neither gcc nor clang. Exiting.")
endif
COMPILER :=
ifeq ($(USE_COMPILER),clang)
ifeq ($(EXISTS_CLANG),)
$(error "USE_COMPILER=clang, but cannot find the clang compiler. Exiting")
endif
COMPILER := clang
else ifeq ($(USE_COMPILER),gcc)
ifeq ($(EXISTS_GCC),)
$(error "USE_COMPILER=gcc given, but cannot find the gcc compiler. Exiting")
endif
COMPILER := gcc
else ifneq ($(EXISTS_CLANG),)
COMPILER := clang
else
COMPILER := gcc
endif
ifeq ($(COMPILER),)
$(error "Oops. Trying to select gcc or clang but should never get here")
endif
ifeq ($(COMPILER),gcc)
CC := gcc $(GCC_CFLAGS)
else
CC := clang $(CLANG_CFLAGS)
endif