Home | History | Annotate | Download | only in core
      1 # Copyright (C) 2009 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 # ====================================================================
     17 #
     18 # Define the main configuration variables, and read the host-specific
     19 # configuration file that is normally generated by build/host-setup.sh
     20 #
     21 # ====================================================================
     22 
     23 # Detect the NDK installation path by processing this Makefile's location.
     24 # This assumes we are located under $NDK_ROOT/build/core/main.mk
     25 #
     26 NDK_ROOT := $(lastword $(MAKEFILE_LIST))
     27 NDK_ROOT := $(strip $(NDK_ROOT:%build/core/main.mk=%))
     28 ifeq ($(NDK_ROOT),)
     29     # for the case when we're invoked from the NDK install path
     30     NDK_ROOT := .
     31 else
     32     # get rid of trailing slash
     33     NDK_ROOT := $(NDK_ROOT:%/=%)
     34 endif
     35 ifdef NDK_LOG
     36     $(info Android NDK: NDK installation path auto-detected: '$(NDK_ROOT)')
     37 endif
     38 
     39 include $(NDK_ROOT)/build/core/init.mk
     40 
     41 # ====================================================================
     42 #
     43 # Read all application configuration files
     44 #
     45 # Each 'application' must have a corresponding Application.mk file
     46 # located in apps/<name> where <name> is a liberal name that doesn't
     47 # contain any space in it, used to uniquely identify the
     48 #
     49 # See docs/ANDROID-MK.TXT for their specification.
     50 #
     51 # ====================================================================
     52 
     53 NDK_ALL_APPS :=
     54 NDK_APPS_ROOT := $(NDK_ROOT)/apps
     55 
     56 # Get the list of apps listed under apps/*
     57 NDK_APPLICATIONS := $(wildcard $(NDK_APPS_ROOT)/*)
     58 NDK_ALL_APPS     := $(NDK_APPLICATIONS:$(NDK_APPS_ROOT)/%=%)
     59 
     60 # Check that APP is not empty
     61 APP := $(strip $(APP))
     62 ifndef APP
     63   $(call __ndk_info,\
     64     The APP variable is undefined or empty.)
     65   $(call __ndk_info,\
     66     Please define it to one of: $(NDK_ALL_APPS))
     67   $(call __ndk_info,\
     68     You can also add new applications by writing an Application.mk file.)
     69   $(call __ndk_info,\
     70     See docs/APPLICATION-MK.TXT for details.)
     71   $(call __ndk_error, Aborting)
     72 endif
     73 
     74 # Check that all apps listed in APP do exist
     75 _bad_apps := $(strip $(filter-out $(NDK_ALL_APPS),$(APP)))
     76 ifdef _bad_apps
     77   $(call __ndk_info,\
     78     APP variable defined to unknown applications: $(_bad_apps))
     79   $(call __ndk_info,\
     80     You might want to use one of the following: $(NDK_ALL_APPS))
     81   $(call __ndk_error, Aborting)
     82 endif
     83 
     84 # Check that all apps listed in APP have an Application.mk
     85 
     86 $(foreach _app,$(APP),\
     87   $(eval _application_mk := $(strip $(wildcard $(NDK_ROOT)/apps/$(_app)/Application.mk))) \
     88   $(call ndk_log,Parsing $(_application_mk))\
     89   $(if $(_application_mk),\
     90     $(eval include $(BUILD_SYSTEM)/add-application.mk)\
     91   ,\
     92     $(call __ndk_info,\
     93       Missing file: apps/$(_app)/Application.mk !)\
     94     $(call __ndk_error, Aborting)\
     95   )\
     96 )
     97 
     98 # clean up environment, just to be safe
     99 $(call clear-vars, $(NDK_APP_VARS))
    100 
    101 ifeq ($(strip $(NDK_ALL_APPS)),)
    102   $(call __ndk_info,\
    103     The NDK could not find a proper application description under apps/*/Application.mk)
    104   $(call __ndk_info,\
    105     Please follow the instructions in docs/NDK-APPS.TXT to write one.)
    106   $(call __ndk_error, Aborting)
    107 endif
    108 
    109 # now check that APP doesn't contain an unknown app name
    110 # if it does, we ignore them if there is at least one known
    111 # app name in the list. Otherwise, abort with an error message
    112 #
    113 _unknown_apps := $(filter-out $(NDK_ALL_APPS),$(APP))
    114 _known_apps   := $(filter     $(NDK_ALL_APPS),$(APP))
    115 
    116 NDK_APPS := $(APP)
    117 
    118 $(if $(_unknown_apps),\
    119   $(if $(_known_apps),\
    120     $(call __ndk_info,WARNING:\
    121         Removing unknown names from APP variable: $(_unknown_apps))\
    122     $(eval NDK_APPS := $(_known_apps))\
    123    ,\
    124     $(call __ndk_info,\
    125         The APP variable contains unknown app names: $(_unknown_apps))\
    126     $(call __ndk_info,\
    127         Please use one of: $(NDK_ALL_APPS))\
    128     $(call __ndk_error, Aborting)\
    129   )\
    130 )
    131 
    132 $(call __ndk_info,Building for application '$(NDK_APPS)')
    133 
    134 # Where all app-specific generated files will be stored
    135 NDK_APP_OUT := $(NDK_ROOT)/out/apps
    136 
    137 include $(BUILD_SYSTEM)/setup-imports.mk
    138 include $(BUILD_SYSTEM)/build-all.mk
    139