1# 2# Copyright (c) 2018, Google, Inc. All rights reserved 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# 18# This makefile contains rules for building QEMU for running Trusty. 19# It is expected that it will be included by the project that uses QEMU 20# and the caller will configure the following variables: 21# 22# QEMU_ROOT - Root of qemu project 23# QEMU_BUILD_BASE - location that will be used to store temp files and 24# build results. 25# QEMU_ARCH - qemu arch to build 26# QEMU_TARGET - targets to build, use comma to separate targets 27# if multiple targets are specified. 28# 29# The following variable is returned to the caller: 30# QEMU_BIN - resulting qemu image 31# QEMU_BUILD_BASE - location that will be used to store temp files and 32# build results. 33# 34# 35 36QEMU_BIN:=$(QEMU_BUILD_BASE)/$(QEMU_ARCH)-softmmu/qemu-system-$(QEMU_ARCH) 37QEMU_MAKEFILE:=$(QEMU_BUILD_BASE)/Makefile 38 39# Set of features disabled by the AOSP emulator. We don't need these features 40# either, and we want minimal dependencies. 41QEMU_AOSP_DISABLES := \ 42 --disable-attr \ 43 --disable-blobs \ 44 --disable-curl \ 45 --disable-curses \ 46 --disable-docs \ 47 --disable-glusterfs \ 48 --disable-gtk \ 49 --disable-guest-agent \ 50 --disable-libnfs \ 51 --disable-libiscsi \ 52 --disable-libssh2 \ 53 --disable-libusb \ 54 --disable-seccomp \ 55 --disable-spice \ 56 --disable-usb-redir \ 57 --disable-user \ 58 --disable-vde \ 59 --disable-vhdx \ 60 --disable-vhost-net \ 61 --disable-opengl \ 62 63# Warnings which pollute the build output and which can make us miss 64# warnings in non-external code that we should be paying attention to. 65QEMU_EXTRA_CFLAGS := \ 66 -Wno-address-of-packed-member \ 67 -Wno-format-truncation \ 68 -Wno-stringop-truncation \ 69 -Wno-array-bounds \ 70 71# Newer capstone releases have the headers under include/capstone 72QEMU_EXTRA_CFLAGS += -I$(TRUSTY_TOP)/$(QEMU_ROOT)/capstone/include/capstone 73 74$(QEMU_MAKEFILE): QEMU_ROOT:=$(QEMU_ROOT) 75$(QEMU_MAKEFILE): QEMU_BUILD_BASE:=$(QEMU_BUILD_BASE) 76$(QEMU_MAKEFILE): QEMU_TARGET:=$(QEMU_TARGET) 77$(QEMU_MAKEFILE): QEMU_AOSP_DISABLES:=$(QEMU_AOSP_DISABLES) 78$(QEMU_MAKEFILE): QEMU_EXTRA_CFLAGS:=$(QEMU_EXTRA_CFLAGS) 79$(QEMU_MAKEFILE): 80 mkdir -p $(QEMU_BUILD_BASE) 81 #--with-git=true sets the "git" program to /bin/true - it essentially disables git 82 #--disable-git-update may look like what we want, but it requests manual intervention, not disables git 83 # TODO(b/148904400): Our prebuilt Clang can't build QEMU yet, and there is no 84 # prebuilts GCC, i.e. currently we can only build QEMU with host toolchain. On 85 # some hosts compiler will complain about stringop truncation. 86 cd $(QEMU_BUILD_BASE) && $(abspath $(QEMU_ROOT)/configure) \ 87 --target-list=$(QEMU_TARGET) --with-git=true --disable-werror \ 88 --extra-cflags="$(QEMU_EXTRA_CFLAGS)" \ 89 --disable-gcrypt --disable-vnc-png $(QEMU_AOSP_DISABLES) \ 90 --python=$(BUILDTOOLS_BINDIR)/py3-cmd 91 92$(QEMU_BIN): QEMU_BUILD_BASE:=$(QEMU_BUILD_BASE) 93$(QEMU_BIN): $(QEMU_MAKEFILE) .PHONY 94 $(MAKE) -C $(QEMU_BUILD_BASE) 95 96# Add QEMU_BIN to the list of project dependencies 97EXTRA_BUILDDEPS += $(QEMU_BIN) 98 99QEMU_ARCH:= 100QEMU_ROOT:= 101QEMU_TARGET:= 102QEMU_AOSP_DISABLES:= 103QEMU_EXTRA_CFLAGS:= 104