OSDN Git Service

Add ndk-gdb script to the NDK.
[android-x86/ndk.git] / docs / APPLICATION-MK.TXT
1 Application.mk file syntax specification
2
3 Introduction:
4 -------------
5
6 This document describes the syntax of Application.mk build files
7 written to describe the native modules required by your Android
8 application. To understand what follows, it is assumed that you have
9 read the docs/OVERVIEW.TXT file that explains their role and
10 usage.
11
12 Readers of this document should have read docs/OVERVIEW.TXT and
13 docs/ANDROID-MK.TXT
14
15
16 Overview:
17 ---------
18
19 The purpose of Application.mk is to describe which native
20 'modules' (i.e. static/shared libraries) are needed by your
21 application.
22
23 An Application.mk file is usually placed under $PROJECT/jni/Application.mk,
24 where $PROJECT points to your application's project directory.
25
26 Another alternative is to place it under a sub-directory of the top-level
27 $NDK/apps directory, e.g.:
28
29    $NDK/apps/<myapp>/Application.mk
30
31 Where <myapp> is a short name used to describe your 'application'
32 to the NDK build system (this name doesn't go into your generated
33 shared libraries or your final packages).
34
35 The Application.mk is really a tiny GNU Makefile fragment that must
36 define a few variables:
37
38 APP_PROJECT_PATH
39     This variable should give the *absolute* path to your
40     Application's project root directory. This is used to copy/install
41     stripped versions of the generated JNI shared libraries to a
42     specific location known to the APK-generating tools.
43
44     Note that it is optional for $PROJECT/jni/Application.mk, but
45     *mandatory* for $NDK/apps/<myapp>/Application.mk
46
47 APP_MODULES
48     This variable is optional. If not defined, the NDK will build by
49     default _all_ the modules declared by your Android.mk, and any
50     sub-makefile it may include.
51
52     If APP_MODULES is defined, it must be a space-separated list of module
53     names as they appear in the LOCAL_MODULE definitions of Android.mk
54     files. Note that the NDK will compute module dependencies automatically.
55
56     NOTE: This variable's behaviour changed in NDK r4. Before that:
57
58       - the variable was mandatory in your Application.mk
59       - all required modules had to be listed explicitely.
60
61 APP_OPTIM
62     This optional variable can be defined to either 'release' or
63     'debug'. This is used to alter the optimization level when
64     building your application's modules.
65
66     A 'release' mode is the default, and will generate highly
67     optimized binaries. The 'debug' mode will generate un-optimized
68     binaries which are much easier to debug.
69
70     Note that it is possible to debug both 'release' and 'debug'
71     binaries, but the 'release' builds tend to provide less information
72     during debugging sessions: some variables are optimized out and
73     can't be inspected, code re-ordering can make stepping through
74     the code difficult, stack traces may not be reliable, etc...
75
76 APP_CFLAGS
77     A set of C compiler flags passed when compiling any C or C++ source code
78     of any of the modules. This can be used to change the build of a given
79     module depending on the application that needs it, instead of modifying
80     the Android.mk file itself.
81
82     IMPORTANT WARNING: +++++++++++++++++++++++++++++++++++++++++++++++++++
83     +
84     + All paths in these flags should be relative to the top-level NDK
85     + directory. For example, if you have the following setup:
86     +
87     +    sources/foo/Android.mk
88     +    sources/bar/Android.mk
89     +
90     +  To specify in foo/Android.mk that you want to add the path to the
91     + 'bar' sources during compilation, you should use:
92     +
93     +   APP_CFLAGS += -Isources/bar
94     +
95     + Or alternatively:
96     +
97     +   APP_CFLAGS += -I$(LOCAL_PATH)/../bar
98     +
99     + Using '-I../bar' will *NOT* work since it will be equivalent to
100     + '-I$NDK_ROOT/../bar' instead.
101     +
102     +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103
104     NOTE: In android-ndk-1.5_r1, this only applied to C sources, not C++ ones.
105           This has been corrected to match the full Android build system.
106
107 APP_CXXFLAGS
108     An alias for APP_CPPFLAGS, to be considered obsolete as it may disappear
109     in a future release of the NDK.
110
111 APP_CPPFLAGS
112     A set of C++ compiler flags passed when building C++ sources *only*.
113
114     NOTE: In android-ndk-1.5_r1, this applied to both C and C++ sources.
115           This has been corrected to match the full Android build system.
116           You can now use APP_CFLAGS for flags that shall apply to C and
117           C++ souces.
118
119 APP_BUILD_SCRIPT
120     By default, the NDK build system will look for a file named Android.mk
121     under $(APP_PROJECT_PATH)/jni, i.e. for the file:
122
123        $(APP_PROJECT_PATH)/jni/Android.mk
124
125     If you want to override this behaviour, you can define APP_BUILD_SCRIPT
126     to point to an alternate build script. A non-absolute path will always
127     be interpreated as relative to the NDK's top-level directory.
128
129 APP_ABI
130     By default, the NDK build system will generate machine code for the
131     'armeabi' ABI. This corresponds to an ARMv5TE based CPU with software
132     floating point operations. You can use APP_ABI to select a different
133     ABI.
134
135     For example, to support hardware FPU instructions on ARMv7 based devices,
136     use:
137
138         APP_ABI := armeabi-v7a
139
140     Or to support both ARMv5TE and ARMv7 based devices, use:
141
142         APP_ABI := armeabi armeabi-v7a
143
144     For the list of all supported ABIs and details about their usage and
145     limitations, please read docs/CPU-ARCH-ABIS.TXT
146
147
148 A trivial Application.mk file would be:
149
150 -------------- cut here -------------------------
151 APP_PROJECT_PATH := <path to project>
152 -------------- cut here -------------------------