forked from andreasgal/B2G
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
187 lines (152 loc) · 5.62 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
# To support gonk's build/envsetup.sh
SHELL = bash
-include .config.mk
.DEFAULT: build
MAKE_FLAGS = -j16
HEIMDALL ?= heimdall
TOOLCHAIN_HOST = linux-x86
TOOLCHAIN_PATH = ./glue/gonk/prebuilt/$(TOOLCHAIN_HOST)/toolchain/arm-eabi-4.4.3/bin
KERNEL_PATH = ./boot/kernel-android-$(KERNEL)
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) && \
$(1)
endef
# Developers can use this to define convenience rules and set global variabls
# XXX for now, this is where to put ANDROID_SDK and ANDROID_NDK macros
-include local.mk
.PHONY: build
build: gonk gecko
ifndef ANDROID_SDK
$(error Sorry, you need to set ANDROID_SDK in your environment to point at the top-level of the SDK install. For now.)
endif
ifndef ANDROID_NDK
$(error Sorry, you need to set ANDROID_NDK in your environment to point at the top-level of the NDK install. For now.)
endif
.PHONY: gecko
# XXX Hard-coded for prof-android target. It would also be nice if
# client.mk understood the |package| target.
gecko:
@export ANDROID_SDK=$(ANDROID_SDK) && \
export ANDROID_NDK=$(ANDROID_NDK) && \
export ANDROID_VERSION_CODE=`date +%Y%m%d%H%M%S` && \
make -C gecko -f client.mk -s $(MAKE_FLAGS) && \
make -C gecko/objdir-prof-android package
.PHONY: gonk
gonk: geckoapk-hack gaia-hack
@$(call GONK_CMD,make $(MAKE_FLAGS))
.PHONY: kernel
# XXX Hard-coded for nexuss4g target
# XXX Hard-coded for gonk tool support
kernel:
@PATH="$$PATH:$(abspath $(TOOLCHAIN_PATH))" make -C $(KERNEL_PATH) $(MAKE_FLAGS) ARCH=arm CROSS_COMPILE=arm-eabi-
.PHONY: clean
clean: clean-gecko clean-gonk clean-kernel
.PHONY: clean-gecko
clean-gecko:
rm -rf gecko/objdir-prof-android
.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-gonk
@echo "KERNEL = 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-gecko-gonk
config-gecko-gonk:
@cp -p config/gecko-prof-gonk gecko/.mozconfig
define INSTALL_NEXUS_S_BLOB # $(call INSTALL_BLOB,vendor,id)
wget https://dl.google.com/dl/android/aosp/$(1)-crespo4g-grj90-$(2).tgz && \
tar zxvf $(1)-crespo4g-grj90-$(2).tgz && \
./extract-$(1)-crespo4g.sh && \
rm $(1)-crespo4g-grj90-$(2).tgz extract-$(1)-crespo4g.sh
endef
.PHONY: config-nexuss4g
# XXX Hard-coded for nexuss4g target
config-nexuss4g: config-gecko-gonk
@echo "KERNEL = samsung" > .config.mk && \
echo "GONK = crespo4g" >> .config.mk && \
cp -p config/kernel-nexuss4g boot/kernel-android-samsung/.config && \
cd $(GONK_PATH) && \
$(call INSTALL_NEXUS_S_BLOB,broadcom,c4ec9a38) && \
$(call INSTALL_NEXUS_S_BLOB,imgtec,a8e2ce86) && \
$(call INSTALL_NEXUS_S_BLOB,nxp,9abcae18) && \
$(call INSTALL_NEXUS_S_BLOB,samsung,9474e48f) && \
make -C $(CURDIR) nexuss4g-postconfig
.PHONY: nexuss4g-postconfig
nexuss4g-postconfig:
$(call GONK_CMD,make signapk && vendor/samsung/crespo4g/reassemble-apks.sh)
.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)
.PHONY: flash-crespo4g
flash-crespo4g: image
@$(call GONK_CMD,adb reboot bootloader && fastboot flashall -w)
.PHONY: flash-galaxys2
flash-galaxys2: image bootimg-hack
@adb reboot download && \
sleep 20 && \
$(HEIMDALL) flash --kernel $(GONK_PATH)/out/target/product/galaxys2/boot.img && \
sleep 60 && \
adb reboot download && \
sleep 20 && \
$(HEIMDALL) flash --factoryfs $(GONK_PATH)/out/target/product/galaxys2/system.img
.PHONY: bootimg-hack
bootimg-hack: kernel
ifeq (samsung,$(KERNEL))
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
endif
ifeq (galaxy-s2,$(KERNEL))
cp -p boot/kernel-android-galaxy-s2/arch/arm/boot/zImage $(GONK_PATH)/device/samsung/galaxys2/kernel && \
cp -p `find boot/kernel-android-galaxy-s2 -name \*.ko` $(GONK_PATH)/device/samsung/galaxys2
endif
OUT_DIR := $(GONK_PATH)/out/target/product/$(GONK)/system
APP_OUT_DIR := $(OUT_DIR)/app
$(APP_OUT_DIR):
mkdir -p $(APP_OUT_DIR)
.PHONY: geckoapk-hack
geckoapk-hack: gecko
mkdir -p $(APP_OUT_DIR)
cp -p gecko/objdir-prof-android/dist/b2g-*.apk $(APP_OUT_DIR)/B2G.apk
unzip -jo gecko/objdir-prof-android/dist/b2g-*.apk lib/armeabi-v7a/libmozutils.so -d $(OUT_DIR)/lib
find glue/gonk/out -iname "*.img" | xargs rm -f no-such-file
.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
install-gecko: gecko
@adb install -r gecko/objdir-prof-android/dist/b2g-*.apk && \
adb reboot
# 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)
.PHONY: sync
sync:
@git submodule sync && \
git submodule update --init && \
git pull