From: Aaron Kling Date: Thu, 24 Jun 2021 20:41:13 +0000 (-0500) Subject: Replace android makefile with one to build modules inline X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4454f43b8cbc4c5e19054e02675da8c92acac312;p=GitHub%2FLineageOS%2FG12%2Fandroid_hardware_amlogic_kernel-modules_optee.git Replace android makefile with one to build modules inline Change-Id: I3ed6ce47161f6fb28aeb1581c65463f94ccfb6b4 --- diff --git a/Android.mk b/Android.mk index c37b0d8..b9d3d18 100644 --- a/Android.mk +++ b/Android.mk @@ -1,83 +1,45 @@ -LOCAL_PATH := $(call my-dir) - -ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), false) - -OPTEE_MODULES := $(shell pwd)/$(PRODUCT_OUT)/obj/optee_modules/ -OPTEE_DRIVERS := $(shell pwd)/vendor/amlogic/common/tdk_linuxdriver/ -KERNEL_OUT_DIR := $(shell pwd)/$(PRODUCT_OUT)/obj/KERNEL_OBJ/ - -############################################################################## -### -### Build tee modules for Android. Since is in Android.mk, not standalone -### module build script, all kernel related configurations(e.g:CROSS_COMPILE), -### PLEASE PLEASE extends from the build system, DO NOT customization here! -############################################################################## -ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29 && echo OK),OK) -define build_optee_modules - echo "$(1) $(2) $(3)" - mkdir -p $(2)/ - cp -rfa $(1)/* $(2)/ - PATH=$$(cd ./$(TARGET_HOST_TOOL_PATH); pwd):$$PATH \ - $(MAKE) -C $(KERNEL_OUT_DIR) M=$(strip $(2)) \ - KERNEL_A32_SUPPORT=$(KERNEL_A32_SUPPORT) ARCH=$(KERNEL_ARCH) \ - CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) -endef -else -define build_optee_modules - echo "$(1) $(2) $(3)" - mkdir -p $(2)/ - cp -rfa $(1)/* $(2)/ - $(MAKE) -C $(KERNEL_OUT_DIR) M=$(strip $(2)) \ - KERNEL_A32_SUPPORT=$(KERNEL_A32_SUPPORT) ARCH=$(KERNEL_ARCH) \ - CROSS_COMPILE=$(PREFIX_CROSS_COMPILE) -endef -endif +# +# Copyright (C) 2021 The LineageOS Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -$(PRODUCT_OUT)/obj/optee_modules/optee.ko: $(INSTALLED_KERNEL_TARGET) - $(call build_optee_modules, $(OPTEE_DRIVERS), $(OPTEE_MODULES)) - -endif +LOCAL_PATH := $(call my-dir) +ifeq ($(TARGET_PREBUILT_KERNEL),) +OPTEE_PATH := $(abspath $(call my-dir)) include $(CLEAR_VARS) -LOCAL_MODULE := optee_armtz -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := SHARED_LIBRARIES - -ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), false) -GEN_OPTEE_ARMTZ := $(local-generated-sources-dir)/optee_armtz.ko -$(GEN_OPTEE_ARMTZ): $(PRODUCT_OUT)/obj/optee_modules/optee.ko | $(ACP) - cp $(PRODUCT_OUT)/obj/optee_modules/optee/optee_armtz.ko $(GEN_OPTEE_ARMTZ) - -LOCAL_PREBUILT_MODULE_FILE := $(GEN_OPTEE_ARMTZ) -else -# TARGET_BOOTLOADER_BOARD_NAME currently defined the same as platform device name -LOCAL_SRC_FILES := device/amlogic/$(TARGET_BOOTLOADER_BOARD_NAME)-kernel/optee_armtz.ko -endif +LOCAL_MODULE := optee-module LOCAL_MODULE_SUFFIX := .ko -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib -LOCAL_STRIP_MODULE := false -include $(BUILD_PREBUILT) - - -include $(CLEAR_VARS) -LOCAL_MODULE := optee -LOCAL_MODULE_CLASS := SHARED_LIBRARIES - -ifneq ($(TARGET_KERNEL_BUILT_FROM_SOURCE), false) -GEN_OPTEE := $(local-generated-sources-dir)/optee.ko -$(GEN_OPTEE): $(PRODUCT_OUT)/obj/optee_modules/optee.ko | $(ACP) - cp $(PRODUCT_OUT)/obj/optee_modules/optee.ko $(GEN_OPTEE) - -LOCAL_PREBUILT_MODULE_FILE := $(GEN_OPTEE) -else -LOCAL_SRC_FILES := \ - device/amlogic/$(TARGET_BOOTLOADER_BOARD_NAME)-kernel/optee.ko - +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules + +_optee_intermediates := $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE)) +_optee_ko := $(_optee_intermediates)/$(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX) +KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ + +$(_optee_ko): $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME) + @mkdir -p $(dir $@) + @cp -R $(OPTEE_PATH)/* $(_optee_intermediates)/ + $(hide) +$(KERNEL_MAKE_CMD) $(PATH_OVERRIDE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_OUT) M=$(abspath $(_optee_intermediates)) ARCH=$(TARGET_KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) modules + modules=$$(find $(_optee_intermediates) -type f -name '*.ko'); \ + for f in $$modules; do \ + $(KERNEL_TOOLCHAIN_PATH)strip --strip-unneeded $$f; \ + cp $$f $(KERNEL_MODULES_OUT)/lib/modules; \ + done; + touch $(_optee_intermediates)/optee-module.ko + +include $(BUILD_SYSTEM)/base_rules.mk endif -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_SUFFIX := .ko -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib -LOCAL_STRIP_MODULE := false -include $(BUILD_PREBUILT)