forked from andreasgal/B2G
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
252 lines (203 loc) · 7.39 KB
/
Makefile
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# To support gonk's build/envsetup.sh
SHELL = bash
-include .config.mk
.DEFAULT: build
MAKE_FLAGS ?= -j16
GONK_MAKE_FLAGS ?=
HEIMDALL ?= heimdall
TOOLCHAIN_HOST = linux-x86
TOOLCHAIN_PATH = ./glue/gonk/prebuilt/$(TOOLCHAIN_HOST)/toolchain/arm-eabi-4.4.3/bin
GONK_PATH = $(abspath glue/gonk)
GONK_TARGET ?= full_$(GONK)-eng
define GONK_CMD # $(call GONK_CMD,cmd)
cd $(GONK_PATH) && \
. build/envsetup.sh && \
lunch $(GONK_TARGET) && \
export USE_CCACHE="yes" && \
$(1)
endef
ANDROID_SDK_PLATFORM ?= android-13
GECKO_CONFIGURE_ARGS ?=
CCACHE ?= $(shell which ccache)
.PHONY: build
build: gecko gecko-install-hack gonk
ifeq (qemu,$(KERNEL))
build: kernel bootimg-hack
endif
KERNEL_DIR = boot/kernel-android-$(KERNEL)
GECKO_OBJDIR = gecko/objdir-prof-gonk
.PHONY: gecko
# XXX Hard-coded for prof-android target. It would also be nice if
# client.mk understood the |package| target.
gecko:
@export MAKE_FLAGS=$(MAKE_FLAGS) && \
export CONFIGURE_ARGS="$(GECKO_CONFIGURE_ARGS)" && \
export GONK_PRODUCT="$(GONK)" && \
ulimit -n 4096 && \
make -C gecko -f client.mk -s $(MAKE_FLAGS) && \
make -C $(GECKO_OBJDIR) package
.PHONY: gonk
gonk: gaia-hack
@$(call GONK_CMD,make $(MAKE_FLAGS) $(GONK_MAKE_FLAGS))
ifeq (qemu,$(KERNEL))
@cp glue/gonk/system/core/rootdir/init.rc.gonk $(GONK_PATH)/out/target/product/$(GONK)/root/init.rc
endif
.PHONY: kernel
# XXX Hard-coded for nexuss4g target
# XXX Hard-coded for gonk tool support
kernel:
ifeq (galaxy-s2,$(KERNEL))
@PATH="$$PATH:$(abspath $(TOOLCHAIN_PATH))" make -C $(KERNEL_PATH) $(MAKE_FLAGS) ARCH=arm CROSS_COMPILE="$(CCACHE) arm-eabi-" modules
(rm -rf boot/initramfs && cd boot/clockworkmod_galaxys2_initramfs && git checkout-index -a -f --prefix ../initramfs/)
find "$(KERNEL_DIR)" -name "*.ko" | xargs -I MOD cp MOD "$(PWD)/boot/initramfs/lib/modules"
endif
@PATH="$$PATH:$(abspath $(TOOLCHAIN_PATH))" make -C $(KERNEL_PATH) $(MAKE_FLAGS) ARCH=arm CROSS_COMPILE="$(CCACHE) arm-eabi-"
.PHONY: clean
clean: clean-gecko clean-gonk clean-kernel
.PHONY: clean-gecko
clean-gecko:
rm -rf $(GECKO_OBJDIR)
.PHONY: clean-gonk
clean-gonk:
@$(call GONK_CMD,make clean)
.PHONY: clean-kernel
clean-kernel:
@PATH="$$PATH:$(abspath $(TOOLCHAIN_PATH))" make -C $(KERNEL_PATH) ARCH=arm CROSS_COMPILE=arm-eabi- clean
.PHONY: config-galaxy-s2
config-galaxy-s2: config-gecko
@echo "KERNEL = galaxy-s2" > .config.mk && \
echo "KERNEL_PATH = ./boot/kernel-android-galaxy-s2" >> .config.mk && \
echo "GONK = galaxys2" >> .config.mk && \
cp -p config/kernel-galaxy-s2 boot/kernel-android-galaxy-s2/.config && \
cd $(GONK_PATH)/device/samsung/galaxys2/ && \
echo Extracting binary blobs from device, which should be plugged in! ... && \
./extract-files.sh && \
echo OK
.PHONY: config-maguro
config-maguro: config-gecko
@echo "KERNEL = msm" > .config.mk && \
echo "KERNEL_PATH = ./boot/msm" >> .config.mk && \
echo "GONK = maguro" >> .config.mk && \
cd $(GONK_PATH)/device/toro/maguro && \
echo Extracting binary blobs from device, which should be plugged in! ... && \
./extract-files.sh && \
echo OK
.PHONY: config-gecko
config-gecko:
@ln -sf ../config/gecko-prof-gonk gecko/mozconfig
%.tgz:
wget https://dl.google.com/dl/android/aosp/$@
NEXUS_S_BUILD = grj90
extract-broadcom-crespo4g.sh: broadcom-crespo4g-$(NEXUS_S_BUILD)-c4ec9a38.tgz
tar zxvf $< && ./$@
extract-imgtec-crespo4g.sh: imgtec-crespo4g-$(NEXUS_S_BUILD)-a8e2ce86.tgz
tar zxvf $< && ./$@
extract-nxp-crespo4g.sh: nxp-crespo4g-$(NEXUS_S_BUILD)-9abcae18.tgz
tar zxvf $< && ./$@
extract-samsung-crespo4g.sh: samsung-crespo4g-$(NEXUS_S_BUILD)-9474e48f.tgz
tar zxvf $< && ./$@
.PHONY: blobs-nexuss4g
blobs-nexuss4g: extract-broadcom-crespo4g.sh extract-imgtec-crespo4g.sh extract-nxp-crespo4g.sh extract-samsung-crespo4g.sh
.PHONY: config-nexuss4g
config-nexuss4g: blobs-nexuss4g config-gecko
@echo "KERNEL = samsung" > .config.mk && \
echo "KERNEL_PATH = ./boot/kernel-android-samsung" >> .config.mk && \
echo "GONK = crespo4g" >> .config.mk && \
cp -p config/kernel-nexuss4g boot/kernel-android-samsung/.config && \
make -C $(CURDIR) nexuss4g-postconfig
.PHONY: nexuss4g-postconfig
nexuss4g-postconfig:
$(call GONK_CMD,make signapk && vendor/samsung/crespo4g/reassemble-apks.sh)
.PHONY: config-qemu
config-qemu: config-gecko
@echo "KERNEL = qemu" > .config.mk && \
echo "KERNEL_PATH = ./boot/kernel-android-qemu" >> .config.mk && \
echo "GONK = generic" >> .config.mk && \
echo "GONK_TARGET = generic-eng" >> .config.mk && \
echo "GONK_MAKE_FLAGS = TARGET_ARCH_VARIANT=armv7-a" >> .config.mk && \
make -C boot/kernel-android-qemu ARCH=arm goldfish_armv7_defconfig && \
( [ -e $(GONK_PATH)/device/qemu ] || \
mkdir $(GONK_PATH)/device/qemu ) && \
echo OK
.PHONY: flash
# XXX Using target-specific targets for the time being. fastboot is
# great, but the sgs2 doesn't support it. Eventually we should find a
# lowest-common-denominator solution.
flash: flash-$(GONK)
# flash-only targets are the same as flash targets, except that they don't
# depend on building the image.
.PHONY: flash-only
flash-only: flash-only-$(GONK)
.PHONY: flash-crespo4g
flash-crespo4g: image
@$(call GONK_CMD,adb reboot bootloader && fastboot flashall -w)
.PHONY: flash-only-crespo4g
flash-only-crespo4g:
@$(call GONK_CMD,adb reboot bootloader && fastboot flashall -w)
define FLASH_GALAXYS2_CMD
adb reboot download
sleep 20
$(HEIMDALL) flash --factoryfs $(GONK_PATH)/out/target/product/galaxys2/system.img
$(FLASH_GALAXYS2_CMD_CHMOD_HACK)
endef
.PHONY: flash-galaxys2
flash-galaxys2: image
$(FLASH_GALAXYS2_CMD)
.PHONY: flash-only-galaxys2
flash-only-galaxys2:
$(FLASH_GALAXYS2_CMD)
.PHONY: bootimg-hack
bootimg-hack: kernel-$(KERNEL)
.PHONY: kernel-samsung
kernel-samsung:
cp -p boot/kernel-android-samsung/arch/arm/boot/zImage $(GONK_PATH)/device/samsung/crespo/kernel && \
cp -p boot/kernel-android-samsung/drivers/net/wireless/bcm4329/bcm4329.ko $(GONK_PATH)/device/samsung/crespo/bcm4329.ko
.PHONY: kernel-qemu
kernel-qemu:
cp -p boot/kernel-android-qemu/arch/arm/boot/zImage \
$(GONK_PATH)/device/qemu/kernel
kernel-%:
@
OUT_DIR := $(GONK_PATH)/out/target/product/$(GONK)/system
APP_OUT_DIR := $(OUT_DIR)/app
$(APP_OUT_DIR):
mkdir -p $(APP_OUT_DIR)
.PHONY: gecko-install-hack
gecko-install-hack: gecko
rm -rf $(OUT_DIR)/b2g
mkdir -p $(OUT_DIR)/lib
# Extract the newest tarball in the gecko objdir.
( cd $(OUT_DIR) && \
tar xvfz `ls -t $(PWD)/$(GECKO_OBJDIR)/dist/b2g-*.tar.gz | head -n1` )
cp $(OUT_DIR)/b2g/libmozutils.so $(OUT_DIR)/lib
find glue/gonk/out -iname "*.img" | xargs rm -f
.PHONY: gaia-hack
gaia-hack: gaia
rm -rf $(OUT_DIR)/home
mkdir -p $(OUT_DIR)/home
cp -r gaia/* $(OUT_DIR)/home
.PHONY: install-gecko
@adb shell mount -o remount,rw /system && \
adb push $(OUT_DIR)/b2g /system/b2g && \
adb push $(OUT_DIR)/lib/libmozutils.so /system/lib/libmozutils.so
# The sad hacks keep piling up... We can't set this up to be
# installed as part of the data partition because we can't flash that
# on the sgs2.
.PHONY: install-gaia
install-gaia:
@for i in `ls gaia`; do adb push gaia/$$i /data/local/$$i; done
.PHONY: image
image: build
@echo XXX stop overwriting the prebuilt nexuss4g kernel
.PHONY: unlock-bootloader
unlock-bootloader:
@$(call GONK_CMD,adb reboot bootloader && fastboot oem unlock)
# Kill the b2g process on the device.
.PHONY: kill-b2g
kill-b2g:
adb shell kill `adb shell ps | grep b2g | sed -e 's/ \+/ /g' | cut -f 2 -d ' '`
.PHONY: sync
sync:
git pull origin master
git submodule sync
git submodule update --init