1# Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
2#
3# This program is free software; you can redistribute it and/or
4# modify it under the terms of the GNU General Public License
5# as published by the Free Software Foundation; either version 2
6# of the License, or (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17ifeq ($(PARAM_FILE), )
18    PARAM_FILE:=../../mpp/Makefile.param
19    include $(PARAM_FILE)
20endif
21
22src = $(PWD)
23EXTRA_CFLAGS := -I$(src)
24EXTRA_CFLAGS += -I$(src)/himedia
25EXTRA_CFLAGS += -I$(src)/../include/
26EXTRA_CFLAGS += -DHICHIP=$(HICHIP)
27ifeq ($(MPP_BUILD), y)
28    EXTRA_CFLAGS += $(MPP_CFLAGS)
29else
30    EXTRA_CFLAGS += -I$(CBB_ROOT)/include
31    EXTRA_CFLAGS += -I$(CBB_ROOT)/include/adapt
32    EXTRA_CFLAGS += -I$(CBB_ROOT)/based/arch/$(HIARCH)/include/$(HI_SUBARCH)
33    EXTRA_CFLAGS += -I$(OHOS_ROOT_PATH)/third_party/bounds_checking_function/include
34endif
35ifeq ($(CONFIG_DRIVER_SPACE_TYPE),user_space)
36EXTRA_CFLAGS :=$(subst base/,based/,$(EXTRA_CFLAGS))
37EXTRA_CFLAGS :=$(subst sys/,sysd/,$(EXTRA_CFLAGS))
38endif
39csrcs = $(wildcard *.c ./himedia/*.c)
40oobjs = $(patsubst %.c,%.o,$(csrcs))
41
42obj-m += hi_osal.o
43hi_osal-y := osal_fileops.o osal_vmalloc.o osal_addr.o osal_init.o osal_atomic.o osal_barrier.o osal_cache.o \
44             osal_debug.o osal_device.o osal_interrupt.o osal_math.o osal_mutex.o osal_proc.o osal_schedule.o \
45             osal_semaphore.o osal_spinlock.o osal_string.o osal_task.o osal_timer.o osal_wait.o osal_workqueue.o \
46             osal_notifier.o osal_platform.o ./himedia/base.o ./himedia/himedia.o ./mmz/media_mem.o \
47             ./mmz/mmz_userdev.o ./mmz/hisi_allocator.o
48
49hi_osal-$(CONFIG_CMA) += ./mmz/cma_allocator.o
50hi_osal-$(CONFIG_CMA) += ./mmz/cmpi_mm.o
51
52all:
53	@make -C $(KERNEL_ROOT) M=$(PWD) $(COMPILER_TRIPLE) modules
54	@mkdir -p $(REL_KO) && cp hi_osal.ko $(REL_KO)
55clean:
56	@rm -f hi_osal.ko *.mod
57	@rm hi_osal.mod.c hi_osal.mod.o hi_osal.o modules.order Module.symvers -f
58	@rm $(hi_osal-y) -f
59	@rm ./mmz/*.o -f
60	@for x in `find . -name "*.mod.c"`;do rm -rf $$x;done
61	@for x in `find . -name "*.cmd"`;do rm -rf $$x;done
62	@rm .tmp_versions -rf
63
64