blob: 52bf0cb172bf11d630a2fe5af660b2a7c9d7954e [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building an executable file.
3##
4## Additional inputs from base_rules.make:
5## None.
6###########################################################
7
8ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
9LOCAL_MODULE_CLASS := EXECUTABLES
10endif
11ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
12LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
13endif
14
Ying Wang4c493722013-01-15 15:28:08 -080015$(call target-executable-hook)
16
17skip_build_from_source :=
18ifdef LOCAL_PREBUILT_MODULE_FILE
19ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
20include $(BUILD_PREBUILT)
21skip_build_from_source := true
22endif
23endif
24
25ifndef skip_build_from_source
Kito Cheng70dc3e12012-06-15 15:15:50 +080026####################################################
27## Add profiling libraries if aprof is turned
28####################################################
29ifeq ($(strip $(LOCAL_ENABLE_APROF)),true)
30 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE), true)
31 LOCAL_STATIC_LIBRARIES += libaprof libaprof_static libc libcutils
32 else
33 LOCAL_SHARED_LIBRARIES += libaprof libaprof_runtime libc
34 endif
35 LOCAL_WHOLE_STATIC_LIBRARIES += libaprof_aux
36endif
37
The Android Open Source Project88b60792009-03-03 19:28:42 -080038include $(BUILD_SYSTEM)/dynamic_binary.mk
39
Ying Wangc6ffc002012-09-25 17:52:10 -070040# Define PRIVATE_ variables from global vars
41my_target_global_ld_dirs := $(TARGET_GLOBAL_LD_DIRS)
42my_target_global_ldflags := $(TARGET_GLOBAL_LDFLAGS)
43my_target_fdo_lib := $(TARGET_FDO_LIB)
44my_target_libgcc := $(TARGET_LIBGCC)
45my_target_crtbegin_dynamic_o := $(TARGET_CRTBEGIN_DYNAMIC_O)
46my_target_crtbegin_static_o := $(TARGET_CRTBEGIN_STATIC_O)
47my_target_crtend_o := $(TARGET_CRTEND_O)
48ifdef LOCAL_SDK_VERSION
49# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
50# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
51my_target_global_ld_dirs := \
52 $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
53 $(my_ndk_version_root)/usr/lib) \
54 $(my_target_global_ld_dirs)
55my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
56my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_dynamic.o)
57my_target_crtbegin_static_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_static.o)
58my_target_crtend_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_android.o)
59endif
60$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
61$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
62$(linked_module): PRIVATE_TARGET_FDO_LIB := $(my_target_fdo_lib)
63$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
64$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
65$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
66$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
67
The Android Open Source Project88b60792009-03-03 19:28:42 -080068ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
Ying Wangc6ffc002012-09-25 17:52:10 -070069$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
The Android Open Source Project88b60792009-03-03 19:28:42 -080070 $(transform-o-to-static-executable)
Ying Wangc6ffc002012-09-25 17:52:10 -070071else
72$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
The Android Open Source Project88b60792009-03-03 19:28:42 -080073 $(transform-o-to-executable)
74endif
Ying Wang4c493722013-01-15 15:28:08 -080075
76endif # skip_build_from_source