-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
131 lines (105 loc) · 3.48 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
.PHONY: all clean help
.PHONY: tools u-boot linux libs hwpack hwpack-install
.PHONY: patch linux-config livesuit android
SUDO=sudo
CROSS_COMPILE=arm-linux-gnueabihf-
OUTPUT_DIR=$(CURDIR)/output
BUILD_PATH=$(CURDIR)/build
ROOTFS=rootfs/rootfs.img
Q=@
J=$(shell expr `grep ^processor /proc/cpuinfo | wc -l` \* 2)
include chosen_board.mk
DATE=$(shell date +"%4Y%2m%2d")
HWPACK=$(OUTPUT_DIR)/${BOARD}_${SOC}_hwpack_${DATE}.tar.xz
U_O_PATH=$(BUILD_PATH)/$(UBOOT_CONFIG)-u-boot
K_O_PATH=$(BUILD_PATH)/$(KERNEL_CONFIG)-linux
U_CONFIG_H=$(U_O_PATH)/include/config.h
K_DOT_CONFIG=$(K_O_PATH)/.config
all: cross_tools hwpack
clean:
rm -rf $(BUILD_PATH)
## cross_tools
cross_tools:
$(Q)scripts/check_tools.sh
## tools
tools: sunxi-tools/.git
$(Q)$(MAKE) -C sunxi-tools
## u-boot
$(U_CONFIG_H):
$(Q)mkdir -p $(U_O_PATH)
$(Q)$(MAKE) -C sc7731_u-boot $(UBOOT_CONFIG)_config O=$(U_O_PATH) CROSS_COMPILE=$(CROSS_COMPILE) -j$J
u-boot: $(U_CONFIG_H)
$(Q)$(MAKE) -C sc7731_u-boot O=$(U_O_PATH) CROSS_COMPILE=$(CROSS_COMPILE) -j$J
## linux
$(K_DOT_CONFIG):
$(Q)mkdir -p $(K_O_PATH)
$(Q)$(MAKE) -C sc7731_kernel O=$(K_O_PATH) ARCH=arm $(KERNEL_CONFIG)
linux: $(K_DOT_CONFIG)
$(Q)$(MAKE) -C sc7731_kernel O=$(K_O_PATH) ARCH=arm oldconfig
$(Q)$(MAKE) -C sc7731_kernel O=$(K_O_PATH) ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} -j$J INSTALL_MOD_PATH=output uImage modules
$(Q)$(MAKE) -C sc7731_kernel O=$(K_O_PATH) ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} -j$J INSTALL_MOD_PATH=output modules_install
cd $(K_O_PATH) && ${CROSS_COMPILE}objcopy -R .note.gnu.build-id -S -O binary vmlinux bImage
linux-config: $(K_DOT_CONFIG)
$(Q)$(MAKE) menuconfig -C sc7731_kernel O=$(K_O_PATH) ARCH=arm
## boot.scr
boot.scr:
$(Q)mkdir -p $(OUTPUT_DIR)
$(Q)[ ! -s boot.cmd ] || mkimage -A arm -O u-boot -T script -C none -n "boot" -d boot.cmd $(BUILD_PATH)/boot.scr
## hwpack
$(HWPACK): u-boot linux
$(Q)scripts/mk_hwpack.sh $@
hwpack: $(HWPACK)
## livesuit
rootfs.ext4: $(ROOTFS)
$(Q)scripts/mk_ext4_rootfs.sh $(ROOTFS) rootfs.ext4
livesuit:
$(Q)scripts/mk_livesuit_img.sh -R $(ROOTFS)
## android
#android-%:
# $(Q)scripts/mk_android.sh $*
#android: android-build
#
android:
$(Q)@echo "android is not supported yet!"
## hwpack-install
hwpack-install: $(HWPACK)
ifndef SD_CARD
$(Q)echo "Define SD_CARD variable"
$(Q)false
else
$(Q)$(SUDO) scripts/sunxi-media-create.sh $(SD_CARD) $(HWPACK) $(ROOTFS)
endif
update:
$(Q)git pull
# $(Q)git stash
# $(Q)git pull --rebase
# $(Q)git submodule -q init
# $(Q)git submodule -q foreach git stash save -q --include-untracked "make update stash"
# -$(Q)git submodule -q foreach git fetch -q
# -$(Q)git submodule -q foreach "git rebase origin HEAD || :"
# -$(Q)git submodule -q foreach "git stash pop -q || :"
# -$(Q)git stash pop -q
# $(Q)git submodule status
%/.git:
$(Q)git submodule init
$(Q)git submodule update $*
help:
@echo ""
@echo "Usage:"
@echo " make hwpack - Default 'make'"
@echo " make hwpack-install - Builds and installs hwpack and optional rootfs to sdcard"
@echo " Arguments:"
@echo " SD_CARD= - Target (ie. /dev/sdx)"
@echo " ROOTFS= - Source rootfs (ie. rootfs.tar.gz)"
@echo ""
# @echo " make android - **Experimental**"
@echo " make livesuit"
@echo " make clean"
@echo " make update"
@echo ""
@echo "Optional targets:"
@echo " make linux - Builds linux kernel"
@echo " make linux-config - Menuconfig"
@echo " make u-boot - Builds u-boot"
@echo " make libs - Download libs"
@echo ""