forked from omnirom/android_external_busybox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Android.mk
222 lines (184 loc) · 7.09 KB
/
Android.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
LOCAL_CLANG_EXCEPTION_PROJECTS += external/busybox
LOCAL_CLANG_EXCEPTION_PROJECTS += external/busybox/android/librpc
LOCAL_PATH := $(call my-dir)
BB_PATH := $(LOCAL_PATH)
# Bionic Branches Switches (GB/ICS/L)
BIONIC_ICS := false
BIONIC_L := true
BUSYBOX_WARNING_HIDE := -Wno-error=implicit-function-declaration -Wno-implicit-function-declaration \
-Wno-sign-compare -Wno-return-type -Wno-unused-variable
# Make a static library for regex.
include $(CLEAR_VARS)
LOCAL_SRC_FILES := android/regex/bb_regex.c
LOCAL_C_INCLUDES := $(BB_PATH)/android/regex
LOCAL_CFLAGS := -Wno-sign-compare
LOCAL_MODULE := libclearsilverregex
include $(BUILD_STATIC_LIBRARY)
# Make a static library for RPC library (coming from uClibc).
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(shell cat $(BB_PATH)/android/librpc.sources)
LOCAL_C_INCLUDES := $(BB_PATH)/android/librpc
LOCAL_MODULE := libuclibcrpc
LOCAL_CFLAGS += -fno-strict-aliasing $(BUSYBOX_WARNING_HIDE)
LOCAL_CLANG := false
ifeq ($(BIONIC_L),true)
LOCAL_CFLAGS += -DBIONIC_ICS -DBIONIC_L
endif
include $(BUILD_STATIC_LIBRARY)
#####################################################################
# Execute make prepare for normal config & static lib (recovery)
LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)
BUSYBOX_CROSS_COMPILER_PREFIX := $(abspath $(TARGET_TOOLS_PREFIX))
BB_PREPARE_FLAGS:=
ifeq ($(HOST_OS),darwin)
BB_HOSTCC := $(ANDROID_BUILD_TOP)/prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1/bin/i686-apple-darwin11-gcc
BB_PREPARE_FLAGS := HOSTCC=$(BB_HOSTCC)
endif
# On aosp (master), path is relative, not on cm (kitkat)
bb_gen := $(abspath $(TARGET_OUT_INTERMEDIATES)/busybox)
busybox_prepare_full := $(bb_gen)/full/.config
$(busybox_prepare_full): $(BB_PATH)/busybox-full.config
@echo -e ${CL_YLW}"Prepare config for busybox binary"${CL_RST}
@rm -rf $(bb_gen)/full
@rm -f $(shell find $(abspath $(call intermediates-dir-for,EXECUTABLES,busybox)) -name "*.o")
@mkdir -p $(@D)
@cat $^ > $@ && echo "CONFIG_CROSS_COMPILER_PREFIX=\"$(BUSYBOX_CROSS_COMPILER_PREFIX)\"" >> $@
make -C $(BB_PATH) prepare O=$(@D) $(BB_PREPARE_FLAGS)
busybox_prepare_minimal := $(bb_gen)/minimal/.config
$(busybox_prepare_minimal): $(BB_PATH)/busybox-minimal.config
@echo -e ${CL_YLW}"Prepare config for libbusybox"${CL_RST}
@rm -rf $(bb_gen)/minimal
@rm -f $(shell find $(abspath $(call intermediates-dir-for,STATIC_LIBRARIES,libbusybox)) -name "*.o")
@mkdir -p $(@D)
@cat $^ > $@ && echo "CONFIG_CROSS_COMPILER_PREFIX=\"$(BUSYBOX_CROSS_COMPILER_PREFIX)\"" >> $@
make -C $(BB_PATH) prepare O=$(@D) $(BB_PREPARE_FLAGS)
#####################################################################
LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)
KERNEL_MODULES_DIR ?= /system/lib/modules
SUBMAKE := make -s -C $(BB_PATH) CC=$(CC)
BUSYBOX_SRC_FILES = \
$(shell cat $(BB_PATH)/busybox-$(BUSYBOX_CONFIG).sources) \
android/libc/mktemp.c \
android/libc/pty.c \
android/android.c
BUSYBOX_ASM_FILES =
ifneq ($(BIONIC_L),true)
BUSYBOX_ASM_FILES += swapon.S swapoff.S sysinfo.S
endif
ifneq ($(filter arm x86 mips,$(TARGET_ARCH)),)
BUSYBOX_SRC_FILES += \
$(addprefix android/libc/arch-$(TARGET_ARCH)/syscalls/,$(BUSYBOX_ASM_FILES))
endif
BUSYBOX_C_INCLUDES = \
$(BB_PATH)/include $(BB_PATH)/libbb \
bionic/libc/private \
bionic/libm/include \
bionic/libc \
bionic/libm \
libc/kernel/common \
external/libselinux/include \
external/selinux/libsepol/include \
$(BB_PATH)/android/regex \
$(BB_PATH)/android/librpc
BUSYBOX_CFLAGS = \
-Wno-clobbered \
-DNDEBUG \
-DANDROID \
-fno-strict-aliasing \
-fno-builtin-stpcpy \
$(BUSYBOX_WARNING_HIDE) \
-include $(bb_gen)/$(BUSYBOX_CONFIG)/include/autoconf.h \
-D'CONFIG_DEFAULT_MODULES_DIR="$(KERNEL_MODULES_DIR)"' \
-D'BB_VER="$(strip $(shell $(SUBMAKE) kernelversion)) $(BUSYBOX_SUFFIX)"' -DBB_BT=AUTOCONF_TIMESTAMP
ifeq ($(BIONIC_L),true)
BUSYBOX_CFLAGS += -DBIONIC_L
BUSYBOX_AFLAGS += -DBIONIC_L
# include changes for ICS/JB/KK
BIONIC_ICS := true
endif
ifeq ($(BIONIC_ICS),true)
BUSYBOX_CFLAGS += -DBIONIC_ICS
endif
# Build the static lib for the recovery tool
BUSYBOX_CONFIG:=minimal
BUSYBOX_SUFFIX:=static
LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
LOCAL_C_INCLUDES := $(bb_gen)/minimal/include $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := -Dmain=busybox_driver $(BUSYBOX_CFLAGS)
LOCAL_CFLAGS += \
-DRECOVERY_VERSION \
-Dgetusershell=busybox_getusershell \
-Dsetusershell=busybox_setusershell \
-Dendusershell=busybox_endusershell \
-Dgetmntent=busybox_getmntent \
-Dgetmntent_r=busybox_getmntent_r \
-Dgenerate_uuid=busybox_generate_uuid
LOCAL_ASFLAGS := $(BUSYBOX_AFLAGS)
LOCAL_MODULE := libbusybox
LOCAL_MODULE_TAGS := eng debug
LOCAL_STATIC_LIBRARIES := libcutils libc libm libselinux
LOCAL_ADDITIONAL_DEPENDENCIES := $(busybox_prepare_minimal)
include $(BUILD_STATIC_LIBRARY)
# Bionic Busybox /system/xbin
LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)
BUSYBOX_CONFIG:=full
BUSYBOX_SUFFIX:=bionic
LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
LOCAL_C_INCLUDES := $(bb_gen)/full/include $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := $(BUSYBOX_CFLAGS)
LOCAL_ASFLAGS := $(BUSYBOX_AFLAGS)
LOCAL_MODULE := busybox
LOCAL_MODULE_TAGS := eng debug
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_SHARED_LIBRARIES := libc libcutils libm
LOCAL_STATIC_LIBRARIES := libclearsilverregex libuclibcrpc libselinux
LOCAL_ADDITIONAL_DEPENDENCIES := $(busybox_prepare_full)
LOCAL_CLANG := false
include $(BUILD_EXECUTABLE)
BUSYBOX_LINKS := $(shell cat $(BB_PATH)/busybox-$(BUSYBOX_CONFIG).links)
# nc is provided by external/netcat
exclude := nc
SYMLINKS := $(addprefix $(TARGET_OUT_OPTIONAL_EXECUTABLES)/,$(filter-out $(exclude),$(notdir $(BUSYBOX_LINKS))))
$(SYMLINKS): BUSYBOX_BINARY := $(LOCAL_MODULE)
$(SYMLINKS): $(LOCAL_INSTALLED_MODULE)
@echo -e ${CL_CYN}"Symlink:"${CL_RST}" $@ -> $(BUSYBOX_BINARY)"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide) ln -sf $(BUSYBOX_BINARY) $@
ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
# We need this so that the installed files could be picked up based on the
# local module name
ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
$(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
# Static Busybox
LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)
BUSYBOX_CONFIG:=full
BUSYBOX_SUFFIX:=static
LOCAL_SRC_FILES := $(BUSYBOX_SRC_FILES)
LOCAL_C_INCLUDES := $(bb_gen)/full/include $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := $(BUSYBOX_CFLAGS)
LOCAL_CFLAGS += \
-Dgetusershell=busybox_getusershell \
-Dsetusershell=busybox_setusershell \
-Dendusershell=busybox_endusershell \
-Dgetmntent=busybox_getmntent \
-Dgetmntent_r=busybox_getmntent_r \
-Dgenerate_uuid=busybox_generate_uuid
LOCAL_ASFLAGS := $(BUSYBOX_AFLAGS)
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE := static_busybox
LOCAL_MODULE_STEM := busybox
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES := libclearsilverregex libc libcutils libm libuclibcrpc libselinux
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
$(LOCAL_MODULE): busybox_prepare
LOCAL_PACK_MODULE_RELOCATIONS := false
LOCAL_ADDITIONAL_DEPENDENCIES := $(busybox_prepare_full)
LOCAL_CLANG := false
include $(BUILD_EXECUTABLE)