Permalink
Find file
d343311 Mar 25, 2014
@libv @reinforce
105 lines (93 sloc) 3.21 KB
#
# This Makefile tries to autodetect some things, but since i am not that
# knowledgable about make, it probably does rather unconventional things.
#
# It tries to detect the mali driver version from the kernel, but this can
# be overridden at the commandline with VERSION=
#
# Through gcc -dumpmachine, this Makefile tries to detect whether it needs
# the 'armel' or 'armhf' ABI. Override with ABI=
#
include Makefile.setup
# Try to detect whether to install armel or armhf libs.
ifeq ($(ABI),)
dumpmachine := $(shell gcc -dumpmachine)
ifeq ($(dumpmachine),arm-linux-gnueabi) # linaro
ABI = armel
else ifeq ($(dumpmachine),armv5tel-redhat-linux-gnueabi) # fedora
ABI = armel
else ifeq ($(dumpmachine),arm-linux-gnueabihf) # linaro HF
ABI = armhf
else ifeq ($(dumpmachine),armv7hl-redhat-linux-gnueabi) # fedora HF
ABI = armhf
else ifeq ($(dumpmachine),armv7a-hardfloat-linux-gnueabi) # gentoo HF
ABI = armhf
endif
$(info ABI="$(ABI)" (Detected))
else
$(info ABI="$(ABI)" (Provided))
endif
# Sanitize ABI, even when passed from the commandline.
ifeq ($(ABI),armel)
else ifeq ($(ABI),armhf)
else
$(warning Unknown/unhandled ABI "$(ABI)")
$(warning Use ABI=armel or ABI=armhf instead)
$(error Unknown/unhandled ABI "$(ABI)")
endif
# Detect mali driver version by talking to the mali kernel driver.
ifeq ($(VERSION),)
bleh := $(shell make -C version)
VERSION = $(shell version/version)
$(info VERSION="$(VERSION)" (Detected))
else
$(info VERSION="$(VERSION)" (Provided))
endif
# Sanitize mali driver version, even when passed from the commandline.
ifeq ($(VERSION),r2p4)
else ifeq ($(VERSION),r3p0)
else ifeq ($(VERSION),r3p1)
else ifeq ($(VERSION),r3p2-01rel1)
else
$(warning Unknown/unhandled Mali Version "$(VERSION)")
$(warning Use VERSION=(r2p4,r3p0,r3p1,r3p2-01rel1) instead)
$(error Unknown/unhandled Mali Version "$(VERSION)")
endif
# Try to find autodetect which EGL libs we need to install
ifeq ($(EGL_TYPE),)
ifneq ($(wildcard $(libdir)/libX11.so),)
EGL_TYPE = x11
else ifneq ($(wildcard $(libdir)/*/libX11.so),)
EGL_TYPE = x11
else
EGL_TYPE = framebuffer
endif
$(info EGL_TYPE="$(EGL_TYPE)" (Detected))
else
$(info EGL_TYPE="$(EGL_TYPE)" (Provided))
endif
# Sanitize egl type, even when passed from the commandline.
ifeq ($(EGL_TYPE),x11)
else ifeq ($(EGL_TYPE),framebuffer)
else
$(warning Unknown/unhandled EGL type "$(EGL_TYPE)")
$(warning Use EGL_TYPE=(framebuffer,x11) instead)
$(error Unknown/unhandled EGL type "$(EGL_TYPE)")
endif
# Check whether there is an actual libMali.so for us
ifeq ($(wildcard lib/mali/$(VERSION)/$(ABI)/$(EGL_TYPE)/Makefile),)
$(error No Mali libs exist for $(VERSION), $(ABI), $(EGL_TYPE))
endif
# Check whether all library dependencies are available.
# Probably not very portable shell code.
MISSING_SPACE = $(shell ldd lib/mali/$(VERSION)/$(ABI)/$(EGL_TYPE)/*.so* | grep "not found" | sed /libMali.so/d | uniq | sed s/"^\t"//g | sed s/" => not found"/" "/)
MISSING = $(patsubst % ,%,$(MISSING_SPACE))
ifeq ($(NO_DEPS),)
ifneq ($(MISSING),)
$(error Missing library dependencies: $(MISSING))
endif
endif
config.mk:
echo "MALI_VERSION ?= $(VERSION)" > $@
echo "MALI_LIBS_ABI ?= $(ABI)" >> $@
echo "MALI_EGL_TYPE ?= $(EGL_TYPE)" >> $@