1# Copyright (C) 2018 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16LOCAL_DIR := $(GET_LOCAL_DIR)
17
18MODULE := $(LOCAL_DIR)
19
20# Default syscall stub gen tool
21SYSCALL_STUBGEN_TOOL ?= trusty/kernel/lib/syscall/stubgen/stubgen.py
22
23# syscall table definition
24SYSCALL_TABLE ?= trusty/kernel/lib/trusty/include/syscall_table.h
25
26# include common-inc.mk to set SYSCALL_SRCS and friends
27include $(LOCAL_DIR)/common-inc.mk
28
29$(SYSCALL_S): ARCH:=$(ARCH)
30$(SYSCALL_S): SYSCALL_H:=$(SYSCALL_H)
31$(SYSCALL_S): SYSCALL_S:=$(SYSCALL_S)
32$(SYSCALL_S): SYSCALL_RS:=$(SYSCALL_RS)
33$(SYSCALL_S): $(SYSCALL_TABLE) $(SYSCALL_STUBGEN_TOOL)
34	@$(MKDIR)
35	@echo generating syscalls stubs $@
36	$(NOECHO)$(SYSCALL_STUBGEN_TOOL) --arch $(ARCH) -d $(SYSCALL_H) -s $(SYSCALL_S) -r $(SYSCALL_RS) $<
37
38$(SYSCALL_H): $(SYSCALL_S)
39$(SYSCALL_RS): $(SYSCALL_S)
40
41# Track them as generated
42GENERATED += $(SYSCALL_SRCS)
43
44# Add generated trusty_syscall.S to build
45MODULE_SRCS += $(SYSCALL_S)
46
47# Add path to generated .h to module includes.
48# Because we are not exporting all generated files to MODULE_EXPORT_INCLUDES
49# this module must be part of TRUSTY_SDK_MODULES define in user-tasks.mk
50# otherwise build would break.
51MODULE_SDK_HEADERS += $(SYSCALL_H)
52
53MODULE_ADD_IMPLICIT_DEPS := false
54
55include make/library.mk
56