1# Copyright 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
16# Check that we have at least GNU Make 3.81
17# We do this by detecting whether 'lastword' is supported
18#
19MAKE_TEST := $(lastword a b c d e f)
20ifneq ($(MAKE_TEST),f)
21    $(error,This build system requires GNU Make 3.81 or higher to run !)
22endif
23
24# Find the source installation path, should be this file's location.
25_BUILD_ROOT := $(dir $(lastword $(MAKEFILE_LIST)))
26_BUILD_ROOT := $(_BUILD_ROOT:%/=%)
27
28# Complain if the path contains spaces
29ifneq ($(words $(_BUILD_ROOT)),1)
30    $(info,The source installation path contains spaces: '$(_BUILD_ROOT)')
31    $(error,Please fix the problem by reinstalling to a different location.)
32endif
33
34# We are going to generate a JSON representation from the build
35GOLDFISH_OPENGL_BUILD_FOR_HOST := true
36CMAKE_GENERATE := true
37_BUILD_CORE_DIR  := ../../../external/qemu/android/build
38
39# We need the emulator's android makefile defs, so we can understand
40# the makefiles.
41include $(_BUILD_CORE_DIR)/emulator/definitions.make
42
43# We need the ability to dump json.
44include $(_BUILD_ROOT)/json-dump.mk
45
46# And we are going to build like we are an emulator host.
47include $(_BUILD_ROOT)/common.mk
48include $(_BUILD_ROOT)/Android.mk
49
50JSON_FILE := /tmp/build.json
51JSON_DUMP := [ "" $(JSON_DUMP) ]
52
53# And we are going to transform our generated json list into a set of
54# cmake files.
55
56# This is the first target, so also the default target
57cmake:
58	@rm -f $(JSON_FILE)
59	$(call write-to-file,$(JSON_FILE),30,$(JSON_DUMP))
60	$(hide) python cmake_transform.py -i $(JSON_FILE) -c $(JSON_FILE) -o ${_BUILD_ROOT}
61