• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Detect the GDK installation path by processing this Makefile's location.
2# This assumes we are located under $GDK_ROOT/build/core/main.mk
3#
4GDK_ROOT := $(dir $(lastword $(MAKEFILE_LIST)))
5GDK_ROOT := $(strip $(GDK_ROOT:%build/core/=%))
6GDK_ROOT := $(GDK_ROOT:%/=%)
7ifeq ($(GDK_ROOT),)
8    # for the case when we're invoked from the GDK install path
9    GDK_ROOT := .
10endif
11ifdef GDK_LOG
12    $(info Android GDK: GDK installation path auto-detected: '$(GDK_ROOT)')
13endif
14ifneq ($(words $(GDK_ROOT)),1)
15    $(info Android GDK: You GDK installation path contains spaces.)
16    $(info Android GDK: Please re-install to a different location to fix the issue !)
17    $(error Aborting.)
18endif
19
20include $(GDK_ROOT)/build/core/init.mk
21
22# ====================================================================
23#
24# If GDK_PROJECT_PATH is not defined, find the application's project
25# path by looking at the manifest file in the current directory or
26# any of its parents. If none is found, try again with 'jni/Android.mk'
27#
28# It turns out that some people use gdk-build to generate static
29# libraries without a full Android project tree.
30#
31# ====================================================================
32
33find-project-dir = $(strip $(call find-project-dir-inner,$1,$2))
34
35find-project-dir-inner = \
36    $(eval __found_project_path := )\
37    $(eval __find_project_path := $1)\
38    $(eval __find_project_file := $2)\
39    $(call find-project-dir-inner-2)\
40    $(__found_project_path)
41
42find-project-dir-inner-2 = \
43    $(call gdk_log,Looking for $(__find_project_file) in $(__find_project_path))\
44    $(eval __find_project_manifest := $(strip $(wildcard $(__find_project_path)/$(__find_project_file))))\
45    $(if $(__find_project_manifest),\
46        $(call gdk_log,    Found it !)\
47        $(eval __found_project_path := $(__find_project_path))\
48        ,\
49        $(eval __find_project_parent := $(patsubst %/,%,$(dir $(__find_project_path))))\
50        $(if $(__find_project_parent),\
51            $(eval __find_project_path := $(__find_project_parent))\
52            $(call find-project-dir-inner-2)\
53        )\
54    )
55
56GDK_PROJECT_PATH := $(strip $(GDK_PROJECT_PATH))
57ifndef GDK_PROJECT_PATH
58    GDK_PROJECT_PATH := $(call find-project-dir,$(strip $(shell pwd)),AndroidManifest.xml)
59endif
60ifndef GDK_PROJECT_PATH
61    GDK_PROJECT_PATH := $(call find-project-dir,$(strip $(shell pwd)),jni/Android-portable.mk)
62endif
63ifndef GDK_PROJECT_PATH
64    $(call __gdk_info,Could not find application project directory !)
65    $(call __gdk_info,Please define the GDK_PROJECT_PATH variable to point to it.)
66    $(call __gdk_error,Aborting)
67endif
68
69# Check that there are no spaces in the project path, or bad things will happen
70ifneq ($(words $(GDK_PROJECT_PATH)),1)
71    $(call __gdk_info,Your Android application project path contains spaces: '$(GDK_PROJECT_PATH)')
72    $(call __gdk_info,The Android GDK build cannot work here. Please move your project to a different location.)
73    $(call __gdk_error,Aborting.)
74endif
75
76GDK_APPLICATION_MK := $(GDK_ROOT)/build/core/default-application.mk
77
78$(call gdk_log,Found project path: $(GDK_PROJECT_PATH))
79
80# Place all generated files here
81GDK_APP_OUT := $(GDK_PROJECT_PATH)/obj
82
83# Fake an application named 'local'
84_app            := local
85_application_mk := $(GDK_APPLICATION_MK)
86GDK_APPS        := $(_app)
87
88include $(BUILD_SYSTEM)/add-application.mk
89
90# Build it
91include $(BUILD_SYSTEM)/build-all.mk
92