android-ndk-1.5_r1 の makefile

読んでみる。
まずてっぺんにある GNUmakefile から。

# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# DO NOT MODIFY THIS FILE
include build/core/main.mk
# END OF FILE

build/core/main.mk を include との事。ここでも先頭部分で include してます。

# ====================================================================
#
# Define the main configuration variables, and read the host-specific
# configuration file that is normally generated by build/host-setup.sh
#
# ====================================================================

# Include common definitions
include build/core/definitions.mk

あと、コメントにあるんですが、

  • 主な変数の定義
  • build/host-setup.sh で生成された host-specific な設定の読み込み

との事。
で、build/core/definitions.mk ですが、ここでも冒頭で include している。入れ子がどんどん深くなるので詳細略。出てきたカンジになったら掘る方向で。
とりあえず意味不明な関数が出てきたら __gmsl 見てみるという事で。定義のガン見は体に悪い。
ので、main.mk に戻ります。以下なあたり。

# The location of the build system files
BUILD_SYSTEM := build/core

# Where all generated files will be stored during a build
NDK_OUT := out

# Read the host-specific configuration file in $(NDK_OUT)
#
HOST_CONFIG_MAKE := $(NDK_OUT)/host/config.mk

ifeq ($(strip $(wildcard $(HOST_CONFIG_MAKE))),)
    $(call __ndk_info,\
    The configuration file '$(HOST_CONFIG_MAKE)' doesnt' exist.)
    $(call __ndk_info,\
       Please run 'build/host-setup.sh' to generate it.)
    $(call __ndk_error, Aborting)
endif

最後の条件分岐のあたり、微妙に意味不明。で、適当な所に以下な Makefile をでっち上げて色々確認。

NDK_OUT := out

HOST_CONFIG_MAKE := $(NDK_OUT)/host/config.mk

$(call warning, $(HOST_CONFIG_MAKE))
$(call warning, $(wildcard $(HOST_CONFIG_MAKE)))
ifeq ($(strip $(wildcard $(HOST_CONFIG_MAKE))),)
    $(call warning, $(HOST_CONFIG_MAKE))
endif

all:
	@echo OK

で、このファイルがあるディレクトリに out/host なディレクトリを掘って make したら以下な出力。

$ make
Makefile:5:  out/host/config.mk
Makefile:6:  
Makefile:8:  out/host/config.mk
OK
$

で、ファイルを作ってみる。

$ touch out/host/config.mk
$ make
Makefile:5:  out/host/config.mk
Makefile:6:  out/host/config.mk
OK
$

成程。wildcard でファイルが無ければブランク (又は空文字?) になるのか。strip 云々は GNU make のマニュアルに記述あり。実際にファイルが build/host-setup.sh で作成されてるかどうかをチェックしている、と。
# 無知をサラケ出しまくり
で、out/host/config.mk が build/host-setup.sh によって作成されているのであれば以降に進む。

include $(HOST_CONFIG_MAKE)
HOST_PREBUILT_TAG := $(HOST_TAG)

# Location where all prebuilt binaries for a given host architectures
# will be stored.
HOST_PREBUILT := build/prebuilt/$(HOST_TAG)

# Where all app-specific generated files will be stored
NDK_APP_OUT := $(NDK_OUT)/apps

# Where all host-specific generated files will be stored
NDK_HOST_OUT := $(NDK_OUT)/host/$(HOST_TAG)

out/host/config.mk は今の端末だと以下。

# This file was autogenerated by host-setup.sh. Do not edit !
HOST_OS       := darwin
HOST_ARCH     := x86
HOST_TAG      := darwin-x86
HOST_CC       := gcc
HOST_CFLAGS   := 
HOST_CXX      := g++
HOST_CXXFLAGS := 
HOST_LD       := gcc
HOST_LDFLAGS  := 
HOST_AR       := ar
HOST_ARFLAGS  := 

上記を出力する build/host-setup.sh の中身についてはとりあえず略。上記設定は ndk グローバルで全てのプロジェクトのデフォになるとの事 (組み込みプレス Vol.16 より)。プロジェクトローカルなオプションも指定可能との事ですが、そのあたりは別途で。

# Read all toolchain-specific configuration files.

との事。ABI ってなんだろ、と思いつつ build/core/add-toolchain.mk を見てみます。gmsl とか build/host-setup.sh とか確認してはいるのですが、詳細略。