Files
graphene/Scripts/Makefile.configs
2020-10-13 01:56:27 +02:00

74 lines
1.5 KiB
Makefile

MAKEFILE_CONFIGS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(origin CC),default)
CC = gcc
endif
ifeq ($(origin AS),default)
AS = gcc
endif
ifeq ($(origin AR),default)
AR = ar
endif
ifeq ($(origin ARFLAGS),default)
ARFLAGS = rcs
endif
ifeq ($(origin LD),default)
LD = ld
endif
ifeq ($(origin CXX),default)
CXX = g++
endif
OBJCOPY ?= objcopy
# Workaround for clang: unlike gcc, 'clang -dumpmachine' reports 'machine-vendor-operatingsystem'
# and we want 'machine-operatingsystem'.
# See e.g. https://bugs.launchpad.net/ubuntu/+source/clang/+bug/1827175
ifeq ($(findstring clang,$(CC)),clang)
SYS ?= $(shell $(CC) -dumpmachine | cut -d- -f1,3-)
else
SYS ?= $(shell $(CC) -dumpmachine)
endif
export SYS
ARCH := $(word 1,$(subst -, -, $(SYS)))
ifneq ($(ARCH),$(filter $(ARCH),x86_64))
$(error $(ARCH) is not supported)
endif
# where libraries are found, e.g., /lib/x86_64-linux-gnu
ARCH_LIBDIR := /lib/$(SYS)
ifeq ($(wildcard $(ARCH_LIBDIR)/*),)
ARCH_LIBDIR := /lib64
endif
# part of filenames and dirs like /usr/lib/gcc/$(ARCH_LONG)
ARCH_LONG := $(SYS)
DEBUG ?=
export DEBUG
CFLAGS += -Wall -std=c11 -Wmissing-prototypes
CXXFLAGS += -Wall -std=c++14
ifeq ($(DEBUG),1)
CFLAGS += -gdwarf-2 -g3
CXXFLAGS += -gdwarf-2 -g3
ASFLAGS += -gdwarf-2 -g3
CFLAGS += -DDEBUG
ASFLAGS += -DDEBUG
CXXFLAGS += -DDEBUG
endif
ifeq ($(DEBUG),)
CFLAGS += -O2
CXXFLAGS += -O2
endif
ifeq ($(WERROR),1)
CFLAGS += -Werror
CXXFLAGS += -Werror
endif
MAKEFILE_CONFIGS_INCLUDED = y
include $(MAKEFILE_CONFIGS_DIR)/Makefile.Host