Android: push driver build details to driver makefiles
authorRob Herring <robh@kernel.org>
Wed, 3 May 2017 19:35:20 +0000 (14:35 -0500)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 11 May 2017 12:52:21 +0000 (13:52 +0100)
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 <robh@kernel.org>
[Emil Velikov: add the radeon winsys for radeonsi]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
18 files changed:
Android.mk
src/egl/Android.mk
src/gallium/Android.mk
src/gallium/drivers/freedreno/Android.mk
src/gallium/drivers/i915/Android.mk
src/gallium/drivers/nouveau/Android.mk
src/gallium/drivers/r300/Android.mk
src/gallium/drivers/r600/Android.mk
src/gallium/drivers/radeon/Android.mk
src/gallium/drivers/radeonsi/Android.mk
src/gallium/drivers/softpipe/Android.mk
src/gallium/drivers/svga/Android.mk
src/gallium/drivers/vc4/Android.mk
src/gallium/drivers/virgl/Android.mk
src/gallium/state_trackers/dri/Android.mk
src/gallium/targets/dri/Android.mk
src/gallium/winsys/amdgpu/drm/Android.mk
src/gallium/winsys/i915/drm/Android.mk

index 08daf770f26b6930432e572dbfc72f0683cc35fc..71140df02c63a296cb9fcbe411acc9d906910ea9 100644 (file)
@@ -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 <driver name>.<boolean make variable>
+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 \
index a122c1d971a397bbaed89e324b026ffaf1ec62da..00553226773e9ba8be87e495be88c9cbf2637d0d 100644 (file)
@@ -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
index 7c6bda68d59f8183a997fd2242c62f530bb308f0..09155791273b6317f4e52fbd83307bc13fdea0de 100644 (file)
@@ -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)
index 5c97d9ef290698c7c33e777f97b43b33b248ea43..330e824204264ade1cdd8a03e5028bdfeaf0dee2 100644 (file)
@@ -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
index fece3053e375587fd57fc65c3c45a347eb7b5374..6860770167fcbf6a19676820230f63b985144aeb 100644 (file)
@@ -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
index d499d9918d86c2c836ebe3340ee2f48cb47271ae..af379bcc4b3e93d0061bbb238bda9e49cc129503 100644 (file)
@@ -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
index e2939ac4043d75d96eb5b75e5b39f2c5676c76b3..0c89cdbb147274ba9322d6a3705803314d74ee0d 100644 (file)
@@ -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
index cc89d8f6aedac181fd3afada5ca0042d9d58c350..26c00f6ccd9cf0edc662ee0c07c7c3f42f2b5ab5 100644 (file)
@@ -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
index 2bddac832a2ebdbd2763bd641fb3cf75f6f731b2..64815f6f08476436665ebb94f8a7698af79d4247 100644 (file)
@@ -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
index b6f9e26fcccce7a1d679ff87c491e1e1450773cc..cd768751518c39093c22ab4ca22ca8a2cad97b8a 100644 (file)
@@ -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
index 5d3a93bcee450bd58607189ccfd92f0366da7702..dc0fe9dcdbd9c8abc7f1eb81ef54f685f1be07c9 100644 (file)
@@ -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
index 7d23fd500ef529ace0e53889db748027441d4f75..c50743d50948204856efd1811f3a283b6ece65bd 100644 (file)
@@ -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
index de9d5e3f5b3c534d3ec3a39b4a4b35b701c7678e..0dd70e5a0a5a3651f1a3b636e310709359d2f9d7 100644 (file)
@@ -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
index 7c1ba42a5f6ca7c0b647845eba9454a5008efc90..010e15144c9be39e68647b9c9a003493afb21d69 100644 (file)
@@ -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
index 97cf9376e199383b1a66e1cb32eba130b4aa23b8..a867e50d86c6055e67bf5f093ac50adfe596deb7 100644 (file)
@@ -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
 
index f5f0124882fdbd71e68cd33f5d2995bc35785376..e95e24a23177519e1c174ab9f0c4baae271cd85e 100644 (file)
@@ -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)
index 1b9439c4f88606576c61e647c5322137784032cb..75a4a15809fe67fa2d88c5e9a75bb86424f269de 100644 (file)
@@ -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
index b38bd8dca06af5ef86378a5aac7b10ff9be0fd27..bab3e85c5dd0806f02b2199d98b5bca524c2e26e 100644 (file)
@@ -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