From 3f097396a1642bb7033002d0bdd37e194afce06a Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 3 May 2017 14:35:20 -0500 Subject: [PATCH] Android: push driver build details to driver makefiles src/gallium/targets/dri/Android.mk contains lots of conditional for individual drivers. Let's move these details into the individual driver makefiles. In the process, align the make driver conditionals with automake (i.e. HAVE_GALLIUM_*). Signed-off-by: Rob Herring [Emil Velikov: add the radeon winsys for radeonsi] Signed-off-by: Emil Velikov --- Android.mk | 50 ++++++++++--------- src/egl/Android.mk | 18 +++---- src/gallium/Android.mk | 13 +++-- src/gallium/drivers/freedreno/Android.mk | 5 ++ src/gallium/drivers/i915/Android.mk | 4 ++ src/gallium/drivers/nouveau/Android.mk | 5 ++ src/gallium/drivers/r300/Android.mk | 4 ++ src/gallium/drivers/r600/Android.mk | 9 ++++ src/gallium/drivers/radeon/Android.mk | 7 ++- src/gallium/drivers/radeonsi/Android.mk | 13 ++++- src/gallium/drivers/softpipe/Android.mk | 4 ++ src/gallium/drivers/svga/Android.mk | 4 ++ src/gallium/drivers/vc4/Android.mk | 4 ++ src/gallium/drivers/virgl/Android.mk | 4 ++ src/gallium/state_trackers/dri/Android.mk | 2 +- src/gallium/targets/dri/Android.mk | 60 +++-------------------- src/gallium/winsys/amdgpu/drm/Android.mk | 5 ++ src/gallium/winsys/i915/drm/Android.mk | 4 ++ 18 files changed, 121 insertions(+), 94 deletions(-) diff --git a/Android.mk b/Android.mk index 08daf770f26..71140df02c6 100644 --- a/Android.mk +++ b/Android.mk @@ -40,19 +40,31 @@ MESA_DRI_MODULE_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$(M MESA_COMMON_MK := $(MESA_TOP)/Android.common.mk MESA_PYTHON2 := python -classic_drivers := i915 i965 -gallium_drivers := swrast freedreno i915g nouveau r300g r600g radeonsi vmwgfx vc4 virgl +# Lists to convert driver names to boolean variables +# in form of . +classic_drivers := i915.HAVE_I915_DRI i965.HAVE_I965_DRI +gallium_drivers := \ + swrast.HAVE_GALLIUM_SOFTPIPE \ + freedreno.HAVE_GALLIUM_FREEDRENO \ + i915g.HAVE_GALLIUM_I915 \ + nouveau.HAVE_GALLIUM_NOUVEAU \ + r300g.HAVE_GALLIUM_R300 \ + r600g.HAVE_GALLIUM_R600 \ + radeonsi.HAVE_GALLIUM_RADEONSI \ + vmwgfx.HAVE_GALLIUM_VMWGFX \ + vc4.HAVE_GALLIUM_VC4 \ + virgl.HAVE_GALLIUM_VIRGL -MESA_GPU_DRIVERS := $(strip $(BOARD_GPU_DRIVERS)) - -# warn about invalid drivers -invalid_drivers := $(filter-out \ - $(classic_drivers) $(gallium_drivers), $(MESA_GPU_DRIVERS)) -ifneq ($(invalid_drivers),) -$(warning invalid GPU drivers: $(invalid_drivers)) -# tidy up -MESA_GPU_DRIVERS := $(filter-out $(invalid_drivers), $(MESA_GPU_DRIVERS)) -endif +# Warn if we have any invalid driver names +$(foreach d, $(BOARD_GPU_DRIVERS), \ + $(if $(findstring $(d).,$(classic_drivers) $(gallium_drivers)), \ + , \ + $(warning invalid GPU driver: $(d)) \ + ) \ +) +MESA_BUILD_CLASSIC := $(strip $(foreach d, $(BOARD_GPU_DRIVERS), $(patsubst $(d).%,%, $(filter $(d).%, $(classic_drivers))))) +MESA_BUILD_GALLIUM := $(strip $(foreach d, $(BOARD_GPU_DRIVERS), $(patsubst $(d).%,%, $(filter $(d).%, $(gallium_drivers))))) +$(foreach d, $(MESA_BUILD_CLASSIC) $(MESA_BUILD_GALLIUM), $(eval $(d) := true)) # host and target must be the same arch to generate matypes.h ifeq ($(TARGET_ARCH),$(HOST_ARCH)) @@ -61,20 +73,10 @@ else MESA_ENABLE_ASM := false endif -ifneq ($(filter $(classic_drivers), $(MESA_GPU_DRIVERS)),) -MESA_BUILD_CLASSIC := true -else -MESA_BUILD_CLASSIC := false +ifneq ($(filter true, $(HAVE_GALLIUM_RADEONSI)),) +MESA_ENABLE_LLVM := true endif -ifneq ($(filter $(gallium_drivers), $(MESA_GPU_DRIVERS)),) -MESA_BUILD_GALLIUM := true -else -MESA_BUILD_GALLIUM := false -endif - -MESA_ENABLE_LLVM := $(if $(filter radeonsi,$(MESA_GPU_DRIVERS)),true,false) - # add subdirectories SUBDIRS := \ src/gbm \ diff --git a/src/egl/Android.mk b/src/egl/Android.mk index a122c1d971a..00553226773 100644 --- a/src/egl/Android.mk +++ b/src/egl/Android.mk @@ -58,16 +58,16 @@ LOCAL_SHARED_LIBRARIES := \ libgralloc_drm \ libsync -ifeq ($(strip $(MESA_BUILD_CLASSIC)),true) -# require i915_dri and/or i965_dri -LOCAL_REQUIRED_MODULES += \ - $(addsuffix _dri, $(filter i915 i965, $(MESA_GPU_DRIVERS))) -endif # MESA_BUILD_CLASSIC - -ifeq ($(strip $(MESA_BUILD_GALLIUM)),true) +# This controls enabling building of driver libraries +ifneq ($(HAVE_I915_DRI),) +LOCAL_REQUIRED_MODULES += i915_dri +endif +ifneq ($(HAVE_I965_DRI),) +LOCAL_REQUIRED_MODULES += i965_dri +endif +ifneq ($(MESA_BUILD_GALLIUM),) LOCAL_REQUIRED_MODULES += gallium_dri -endif # MESA_BUILD_GALLIUM - +endif LOCAL_MODULE := libGLES_mesa LOCAL_MODULE_RELATIVE_PATH := egl diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 7c6bda68d59..09155791273 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -37,12 +37,17 @@ SUBDIRS += winsys/sw/dri drivers/softpipe SUBDIRS += winsys/freedreno/drm drivers/freedreno SUBDIRS += winsys/i915/drm drivers/i915 SUBDIRS += winsys/nouveau/drm drivers/nouveau -SUBDIRS += drivers/r300 drivers/r600 drivers/radeon drivers/radeonsi -SUBDIRS += winsys/amdgpu/drm winsys/radeon/drm +SUBDIRS += winsys/radeon/drm drivers/r300 +SUBDIRS += winsys/radeon/drm drivers/r600 drivers/radeon +SUBDIRS += winsys/radeon/drm winsys/amdgpu/drm drivers/radeonsi drivers/radeon SUBDIRS += winsys/vc4/drm drivers/vc4 SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl SUBDIRS += winsys/svga/drm drivers/svga +SUBDIRS += state_trackers/dri -SUBDIRS += state_trackers/dri targets/dri +# sort to eliminate any duplicates +INC_DIRS := $(call all-named-subdir-makefiles,$(sort $(SUBDIRS))) +# targets/dri must be included last +INC_DIRS += $(call all-named-subdir-makefiles,targets/dri) -include $(call all-named-subdir-makefiles,$(SUBDIRS)) +include $(INC_DIRS) diff --git a/src/gallium/drivers/freedreno/Android.mk b/src/gallium/drivers/freedreno/Android.mk index 5c97d9ef290..330e8242042 100644 --- a/src/gallium/drivers/freedreno/Android.mk +++ b/src/gallium/drivers/freedreno/Android.mk @@ -48,3 +48,8 @@ LOCAL_MODULE := libmesa_pipe_freedreno include $(LOCAL_PATH)/Android.gen.mk include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_FREEDRENO),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_freedreno) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/drivers/i915/Android.mk b/src/gallium/drivers/i915/Android.mk index fece3053e37..6860770167f 100644 --- a/src/gallium/drivers/i915/Android.mk +++ b/src/gallium/drivers/i915/Android.mk @@ -34,3 +34,7 @@ LOCAL_MODULE := libmesa_pipe_i915 include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_I915),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_i915) +endif diff --git a/src/gallium/drivers/nouveau/Android.mk b/src/gallium/drivers/nouveau/Android.mk index d499d9918d8..af379bcc4b3 100644 --- a/src/gallium/drivers/nouveau/Android.mk +++ b/src/gallium/drivers/nouveau/Android.mk @@ -41,3 +41,8 @@ LOCAL_MODULE := libmesa_pipe_nouveau include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_NOUVEAU),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_nouveau) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/drivers/r300/Android.mk b/src/gallium/drivers/r300/Android.mk index e2939ac4043..0c89cdbb147 100644 --- a/src/gallium/drivers/r300/Android.mk +++ b/src/gallium/drivers/r300/Android.mk @@ -41,3 +41,7 @@ LOCAL_MODULE := libmesa_pipe_r300 include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) +ifneq ($(HAVE_GALLIUM_R300),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_radeon) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/drivers/r600/Android.mk b/src/gallium/drivers/r600/Android.mk index cc89d8f6aed..26c00f6ccd9 100644 --- a/src/gallium/drivers/r600/Android.mk +++ b/src/gallium/drivers/r600/Android.mk @@ -31,8 +31,17 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(C_SOURCES) $(CXX_SOURCES) LOCAL_STATIC_LIBRARIES := libmesa_amd_common + LOCAL_SHARED_LIBRARIES := libdrm_radeon LOCAL_MODULE := libmesa_pipe_r600 include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_R600),) +$(eval GALLIUM_LIBS += \ + $(LOCAL_MODULE) \ + $(LOCAL_STATIC_LIBRARIES) \ + libmesa_winsys_radeon) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/drivers/radeon/Android.mk b/src/gallium/drivers/radeon/Android.mk index 2bddac832a2..64815f6f084 100644 --- a/src/gallium/drivers/radeon/Android.mk +++ b/src/gallium/drivers/radeon/Android.mk @@ -34,8 +34,13 @@ ifeq ($(MESA_ENABLE_LLVM),true) LOCAL_CFLAGS += -DFORCE_BUILD_AMDGPU # instructs LLVM to declare LLVMInitializeAMDGPU* functions endif -LOCAL_SHARED_LIBRARIES := libdrm_radeon +LOCAL_SHARED_LIBRARIES := libdrm_radeon libLLVM LOCAL_MODULE := libmesa_pipe_radeon include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_R600)$(HAVE_GALLIUM_RADEONSI),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE)) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/drivers/radeonsi/Android.mk b/src/gallium/drivers/radeonsi/Android.mk index b6f9e26fccc..cd768751518 100644 --- a/src/gallium/drivers/radeonsi/Android.mk +++ b/src/gallium/drivers/radeonsi/Android.mk @@ -38,8 +38,19 @@ LOCAL_C_INCLUDES := \ $(MESA_TOP)/src/amd/common \ $(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_amd_common,,)/common -LOCAL_SHARED_LIBRARIES := libdrm_radeon +LOCAL_STATIC_LIBRARIES := libmesa_amd_common + +LOCAL_SHARED_LIBRARIES := libdrm_radeon libLLVM LOCAL_MODULE := libmesa_pipe_radeonsi include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_RADEONSI),) +$(eval GALLIUM_LIBS += \ + $(LOCAL_MODULE) \ + $(LOCAL_STATIC_LIBRARIES) \ + libmesa_winsys_radeon \ + libmesa_winsys_amdgpu) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/drivers/softpipe/Android.mk b/src/gallium/drivers/softpipe/Android.mk index 5d3a93bcee4..dc0fe9dcdbd 100644 --- a/src/gallium/drivers/softpipe/Android.mk +++ b/src/gallium/drivers/softpipe/Android.mk @@ -35,3 +35,7 @@ LOCAL_MODULE := libmesa_pipe_softpipe include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_SOFTPIPE),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_sw_dri) +endif diff --git a/src/gallium/drivers/svga/Android.mk b/src/gallium/drivers/svga/Android.mk index 7d23fd500ef..c50743d5094 100644 --- a/src/gallium/drivers/svga/Android.mk +++ b/src/gallium/drivers/svga/Android.mk @@ -36,3 +36,7 @@ LOCAL_MODULE := libmesa_pipe_svga include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_VMWGFX),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_svga) +endif diff --git a/src/gallium/drivers/vc4/Android.mk b/src/gallium/drivers/vc4/Android.mk index de9d5e3f5b3..0dd70e5a0a5 100644 --- a/src/gallium/drivers/vc4/Android.mk +++ b/src/gallium/drivers/vc4/Android.mk @@ -36,3 +36,7 @@ LOCAL_MODULE := libmesa_pipe_vc4 include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_VC4),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_vc4) +endif diff --git a/src/gallium/drivers/virgl/Android.mk b/src/gallium/drivers/virgl/Android.mk index 7c1ba42a5f6..010e15144c9 100644 --- a/src/gallium/drivers/virgl/Android.mk +++ b/src/gallium/drivers/virgl/Android.mk @@ -32,3 +32,7 @@ LOCAL_MODULE := libmesa_pipe_virgl include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_VIRGL),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) libmesa_winsys_virgl libmesa_winsys_virgl_vtest) +endif diff --git a/src/gallium/state_trackers/dri/Android.mk b/src/gallium/state_trackers/dri/Android.mk index 97cf9376e19..a867e50d86c 100644 --- a/src/gallium/state_trackers/dri/Android.mk +++ b/src/gallium/state_trackers/dri/Android.mk @@ -42,7 +42,7 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ LOCAL_STATIC_LIBRARIES := \ libmesa_dri_common -ifneq ($(filter swrast,$(MESA_GPU_DRIVERS)),) +ifneq ($(HAVE_GALLIUM_SOFTPIPE),) LOCAL_SRC_FILES += $(drisw_SOURCES) endif diff --git a/src/gallium/targets/dri/Android.mk b/src/gallium/targets/dri/Android.mk index f5f0124882f..e95e24a2317 100644 --- a/src/gallium/targets/dri/Android.mk +++ b/src/gallium/targets/dri/Android.mk @@ -37,62 +37,11 @@ LOCAL_SHARED_LIBRARIES := \ libglapi \ libexpat -ifneq ($(filter freedreno,$(MESA_GPU_DRIVERS)),) -LOCAL_CFLAGS += -DGALLIUM_FREEDRENO -gallium_DRIVERS += libmesa_winsys_freedreno libmesa_pipe_freedreno -LOCAL_SHARED_LIBRARIES += libdrm_freedreno -endif -ifneq ($(filter i915g,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_winsys_i915 libmesa_pipe_i915 -LOCAL_SHARED_LIBRARIES += libdrm_intel -LOCAL_CFLAGS += -DGALLIUM_I915 -endif -ifneq ($(filter nouveau,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_winsys_nouveau libmesa_pipe_nouveau -LOCAL_CFLAGS += -DGALLIUM_NOUVEAU -LOCAL_SHARED_LIBRARIES += libdrm_nouveau -endif - -ifneq ($(filter r%,$(MESA_GPU_DRIVERS)),) -ifneq ($(filter r300g,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_pipe_r300 -LOCAL_CFLAGS += -DGALLIUM_R300 -endif -ifneq ($(filter r600g,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_pipe_r600 libmesa_pipe_radeon -LOCAL_CFLAGS += -DGALLIUM_R600 -endif -ifneq ($(filter radeonsi,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_pipe_radeonsi libmesa_winsys_amdgpu libmesa_amd_common libmesa_pipe_radeon -LOCAL_SHARED_LIBRARIES += libLLVM libdrm_amdgpu -LOCAL_CFLAGS += -DGALLIUM_RADEONSI -endif -gallium_DRIVERS += libmesa_winsys_radeon libmesa_amdgpu_addrlib -LOCAL_SHARED_LIBRARIES += libdrm_radeon -endif - -ifneq ($(filter swrast,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_pipe_softpipe libmesa_winsys_sw_dri -LOCAL_CFLAGS += -DGALLIUM_SOFTPIPE -endif -ifneq ($(filter vc4,$(MESA_GPU_DRIVERS)),) -LOCAL_CFLAGS += -DGALLIUM_VC4 -gallium_DRIVERS += libmesa_winsys_vc4 libmesa_pipe_vc4 -endif -ifneq ($(filter virgl,$(MESA_GPU_DRIVERS)),) -LOCAL_CFLAGS += -DGALLIUM_VIRGL -gallium_DRIVERS += libmesa_winsys_virgl libmesa_winsys_virgl_vtest libmesa_pipe_virgl -endif -ifneq ($(filter vmwgfx,$(MESA_GPU_DRIVERS)),) -gallium_DRIVERS += libmesa_winsys_svga libmesa_pipe_svga -LOCAL_CFLAGS += -DGALLIUM_VMWGFX -endif -ifneq ($(filter nouveau r600g,$(MESA_GPU_DRIVERS)),) -LOCAL_SHARED_LIBRARIES += libc++ -endif +$(foreach d, $(MESA_BUILD_GALLIUM), $(eval LOCAL_CFLAGS += $(patsubst HAVE_%,-D%,$(d)))) +# sort GALLIUM_LIBS to remove any duplicates LOCAL_WHOLE_STATIC_LIBRARIES := \ - $(gallium_DRIVERS) \ + $(sort $(GALLIUM_LIBS)) \ libmesa_st_dri \ libmesa_st_mesa \ libmesa_glsl \ @@ -105,6 +54,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \ libmesa_util \ libmesa_loader +# sort GALLIUM_SHARED_LIBS to remove any duplicates +LOCAL_SHARED_LIBRARIES += $(sort $(GALLIUM_SHARED_LIBS)) + LOCAL_STATIC_LIBRARIES := ifeq ($(MESA_ENABLE_LLVM),true) diff --git a/src/gallium/winsys/amdgpu/drm/Android.mk b/src/gallium/winsys/amdgpu/drm/Android.mk index 1b9439c4f88..75a4a15809f 100644 --- a/src/gallium/winsys/amdgpu/drm/Android.mk +++ b/src/gallium/winsys/amdgpu/drm/Android.mk @@ -41,3 +41,8 @@ LOCAL_MODULE := libmesa_winsys_amdgpu include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_RADEONSI),) +$(eval GALLIUM_LIBS += $(LOCAL_MODULE) $(LOCAL_STATIC_LIBRARIES)) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif diff --git a/src/gallium/winsys/i915/drm/Android.mk b/src/gallium/winsys/i915/drm/Android.mk index b38bd8dca06..bab3e85c5dd 100644 --- a/src/gallium/winsys/i915/drm/Android.mk +++ b/src/gallium/winsys/i915/drm/Android.mk @@ -35,3 +35,7 @@ LOCAL_MODULE := libmesa_winsys_i915 include $(GALLIUM_COMMON_MK) include $(BUILD_STATIC_LIBRARY) + +ifneq ($(HAVE_GALLIUM_I915),) +$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) +endif -- 2.30.2