Home | History | Annotate | Download | only in core
      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 #
      4 GDK_ROOT := $(dir $(lastword $(MAKEFILE_LIST)))
      5 GDK_ROOT := $(strip $(GDK_ROOT:%build/core/=%))
      6 GDK_ROOT := $(GDK_ROOT:%/=%)
      7 ifeq ($(GDK_ROOT),)
      8     # for the case when we're invoked from the GDK install path
      9     GDK_ROOT := .
     10 endif
     11 ifdef GDK_LOG
     12     $(info Android GDK: GDK installation path auto-detected: '$(GDK_ROOT)')
     13 endif
     14 ifneq ($(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.)
     18 endif
     19 
     20 include $(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 
     33 find-project-dir = $(strip $(call find-project-dir-inner,$1,$2))
     34 
     35 find-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 
     42 find-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 
     56 GDK_PROJECT_PATH := $(strip $(GDK_PROJECT_PATH))
     57 ifndef GDK_PROJECT_PATH
     58     GDK_PROJECT_PATH := $(call find-project-dir,$(strip $(shell pwd)),AndroidManifest.xml)
     59 endif
     60 ifndef GDK_PROJECT_PATH
     61     GDK_PROJECT_PATH := $(call find-project-dir,$(strip $(shell pwd)),jni/Android-portable.mk)
     62 endif
     63 ifndef 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)
     67 endif
     68 
     69 # Check that there are no spaces in the project path, or bad things will happen
     70 ifneq ($(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.)
     74 endif
     75 
     76 GDK_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
     81 GDK_APP_OUT := $(GDK_PROJECT_PATH)/obj
     82 
     83 # Fake an application named 'local'
     84 _app            := local
     85 _application_mk := $(GDK_APPLICATION_MK)
     86 GDK_APPS        := $(_app)
     87 
     88 include $(BUILD_SYSTEM)/add-application.mk
     89 
     90 # Build it
     91 include $(BUILD_SYSTEM)/build-all.mk
     92