forked from VanirAOSP/external_busybox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Android.mk
228 lines (191 loc) · 6.98 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
223
224
225
226
227
228
LOCAL_PATH := $(call my-dir)
BB_PATH := $(LOCAL_PATH)
# Bionic Branches Switches (CM7/AOSP/ICS)
BIONIC_ICS := true
# Make a static library for regex.
include $(CLEAR_VARS)
LOCAL_SRC_FILES := android/regex/regex.c
LOCAL_C_INCLUDES := $(BB_PATH)/android/regex
LOCAL_CFLAGS := -Wno-error -Wno-sign-compare -fno-strict-aliasing
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_CFLAGS := -Wno-error -fno-strict-aliasing
LOCAL_MODULE := libuclibcrpc
LOCAL_CFLAGS += -fno-strict-aliasing
include $(BUILD_STATIC_LIBRARY)
LOCAL_PATH := $(BB_PATH)
include $(CLEAR_VARS)
LOCAL_CFLAGS := -Wno-error -fno-strict-aliasing
# Explicitly set an architecture specific CONFIG_CROSS_COMPILER_PREFIX
ifeq ($(TARGET_ARCH),arm)
BUSYBOX_CROSS_COMPILER_PREFIX := "arm-eabi-"
endif
ifeq ($(TARGET_ARCH),x86)
BUSYBOX_CROSS_COMPILER_PREFIX := "i686-linux-android-"
endif
# Each profile require a compressed usage/config, outside the source tree for git history
# We keep the uncompressed headers in local include-<profile> to track config changes.
# TODO: generate includes in out/
# BB_INCLUDES_OUT := $(TARGET_OUT_INTERMEDIATES)/include
# $(BB_INCLUDES_OUT):
# mkdir -p $(ANDROID_BUILD_TOP)/$(BB_INCLUDES_OUT)
# Execute make clean, make prepare and copy profiles required for normal & static lib (recovery)
KERNEL_MODULES_DIR ?= /system/lib/modules
BUSYBOX_CONFIG := minimal full
$(BUSYBOX_CONFIG):
@echo -e ${CL_PFX}"prepare config for busybox $@ profile"${CL_RST}
@cd $(BB_PATH) && make clean
@cd $(BB_PATH) && git clean -f -- ./include-$@/
cp $(BB_PATH)/.config-$@ $(BB_PATH)/.config
echo "CONFIG_CROSS_COMPILER_PREFIX=\"$(BUSYBOX_CROSS_COMPILER_PREFIX)\"" >> $(BB_PATH)/.config
cd $(BB_PATH) && make prepare
@#cp $(BB_PATH)/.config $(BB_PATH)/.config-$@
@mkdir -p $(BB_PATH)/include-$@
cp $(BB_PATH)/include/*.h $(BB_PATH)/include-$@/
@rm $(BB_PATH)/include/usage_compressed.h
@rm $(BB_PATH)/include/autoconf.h
@rm -f $(BB_PATH)/.config-old
busybox_prepare: $(BUSYBOX_CONFIG)
LOCAL_MODULE := busybox_prepare
LOCAL_MODULE_TAGS := eng debug
include $(BUILD_STATIC_LIBRARY)
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) \
libbb/android.c
ifeq ($(TARGET_ARCH),arm)
BUSYBOX_SRC_FILES += \
android/libc/arch-arm/syscalls/adjtimex.S \
android/libc/arch-arm/syscalls/getsid.S \
android/libc/arch-arm/syscalls/stime.S \
android/libc/arch-arm/syscalls/swapon.S \
android/libc/arch-arm/syscalls/swapoff.S \
android/libc/arch-arm/syscalls/sysinfo.S
endif
ifeq ($(TARGET_ARCH),x86)
BUSYBOX_SRC_FILES += \
android/libc/arch-x86/syscalls/adjtimex.S \
android/libc/arch-x86/syscalls/getsid.S \
android/libc/arch-x86/syscalls/stime.S \
android/libc/arch-x86/syscalls/swapon.S \
android/libc/arch-x86/syscalls/swapoff.S \
android/libc/arch-x86/syscalls/sysinfo.S
endif
ifeq ($(TARGET_ARCH),mips)
BUSYBOX_SRC_FILES += \
android/libc/arch-mips/syscalls/adjtimex.S \
android/libc/arch-mips/syscalls/getsid.S \
android/libc/arch-mips/syscalls/stime.S \
android/libc/arch-mips/syscalls/swapon.S \
android/libc/arch-mips/syscalls/swapoff.S \
android/libc/arch-mips/syscalls/sysinfo.S
endif
BUSYBOX_C_INCLUDES = \
$(BB_PATH)/include-$(BUSYBOX_CONFIG) \
$(BB_PATH)/include $(BB_PATH)/libbb \
bionic/libc/private \
bionic/libm/include \
bionic/libm \
libc/kernel/common \
$(BB_PATH)/android/regex \
$(BB_PATH)/android/librpc
BUSYBOX_CFLAGS = \
-Werror=implicit \
-Wno-error=format-security \
-fno-strict-aliasing \
-DNDEBUG \
-DANDROID \
-fno-strict-aliasing \
-include include-$(BUSYBOX_CONFIG)/autoconf.h \
-D'CONFIG_DEFAULT_MODULES_DIR="$(KERNEL_MODULES_DIR)"' \
-D'BB_VER="$(strip $(shell $(SUBMAKE) kernelversion)) $(BUSYBOX_SUFFIX)"' -DBB_BT=AUTOCONF_TIMESTAMP
# to handle differences in ICS (ipv6)
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 := $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := -Dmain=busybox_driver $(BUSYBOX_CFLAGS)
LOCAL_CFLAGS += \
-Dgetusershell=busybox_getusershell \
-Dsetusershell=busybox_setusershell \
-Dendusershell=busybox_endusershell \
-Dttyname_r=busybox_ttyname_r \
-Dgetmntent=busybox_getmntent \
-Dgetmntent_r=busybox_getmntent_r \
-Dgenerate_uuid=busybox_generate_uuid
LOCAL_MODULE := libbusybox
LOCAL_MODULE_TAGS := eng debug
LOCAL_STATIC_LIBRARIES := libcutils libc libm
$(LOCAL_MODULE): busybox_prepare
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)
ifeq ($(BIONIC_ICS),true)
LOCAL_SRC_FILES += android/libc/__set_errno.c
endif
LOCAL_C_INCLUDES := $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := $(BUSYBOX_CFLAGS)
LOCAL_LDFLAGS += -Wl,--no-fatal-warnings
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
$(LOCAL_MODULE): busybox_prepare
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 "Symlink: $@ -> $(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 := $(BUSYBOX_C_INCLUDES)
LOCAL_CFLAGS := $(BUSYBOX_CFLAGS)
LOCAL_CFLAGS += \
-Dgetusershell=busybox_getusershell \
-Dsetusershell=busybox_setusershell \
-Dendusershell=busybox_endusershell \
-Dttyname_r=busybox_ttyname_r \
-Dgetmntent=busybox_getmntent \
-Dgetmntent_r=busybox_getmntent_r \
-Dgenerate_uuid=busybox_generate_uuid
LOCAL_LDFLAGS += -Wl,--no-fatal-warnings
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
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/utilities
LOCAL_UNSTRIPPED_PATH := $(PRODUCT_OUT)/symbols/utilities
$(LOCAL_MODULE): busybox_prepare
include $(BUILD_EXECUTABLE)