forked from linux-sunxi/sunxi-bsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (103 loc) · 3.79 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
.PHONY: all clean help
.PHONY: tools u-boot linux libs hwpack hwpack-install
.PHONY: linux-config livesuit android
SUDO=sudo
CROSS_COMPILE=arm-linux-gnueabihf-
OUTPUT_DIR=$(CURDIR)/output
BUILD_PATH=$(CURDIR)/build
ROOTFS?=norootfs
ROOTFS_BASENAME=$(basename $(basename $(ROOTFS)))
Q=
J=$(shell expr `grep ^processor /proc/cpuinfo | wc -l` \* 2)
include chosen_board.mk
HWPACK=$(OUTPUT_DIR)/$(BOARD)_hwpack.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: hwpack
clean:
rm -rf $(BUILD_PATH)
rm -f chosen_board.mk
## tools
tools: sunxi-tools/.git
$(Q)$(MAKE) -C sunxi-tools
## u-boot
$(U_CONFIG_H): u-boot-sunxi/.git
$(Q)mkdir -p $(U_O_PATH)
$(Q)$(MAKE) -C u-boot-sunxi $(UBOOT_CONFIG)_config O=$(U_O_PATH) CROSS_COMPILE=$(CROSS_COMPILE) -j$J
u-boot: $(U_CONFIG_H)
$(Q)$(MAKE) -C u-boot-sunxi $(BOARD) O=$(U_O_PATH) CROSS_COMPILE=$(CROSS_COMPILE) -j$J
## linux
$(K_DOT_CONFIG): linux-sunxi/.git
$(Q)mkdir -p $(K_O_PATH)
$(Q)$(MAKE) -C linux-sunxi O=$(K_O_PATH) ARCH=arm $(KERNEL_CONFIG)
linux: $(K_DOT_CONFIG)
$(Q)$(MAKE) -C linux-sunxi O=$(K_O_PATH) ARCH=arm oldconfig
$(Q)$(MAKE) -C linux-sunxi O=$(K_O_PATH) ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} -j$J INSTALL_MOD_PATH=output uImage modules
$(Q)$(MAKE) -C linux-sunxi 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) -C linux-sunxi O=$(K_O_PATH) ARCH=arm menuconfig
## script.bin
script.bin: tools
$(Q)mkdir -p $(OUTPUT_DIR)
$(Q)sunxi-tools/fex2bin sunxi-boards/sys_config/$(SOC)/$(BOARD).fex > $(BUILD_PATH)/$(BOARD).bin
## 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 boot.scr script.bin linux libs
$(Q)scripts/mk_hwpack.sh $@
hwpack: $(HWPACK)
## livesuit
%.ext4: %.tar.gz
$(Q)scripts/mk_ext4_rootfs.sh $< $@
livesuit: allwinner-tools/.git $(ROOTFS_BASENAME).ext4 tools linux
$(Q)scripts/mk_livesuit_img.sh -R $(ROOTFS_BASENAME).ext4
## android
android-%:
$(Q)scripts/mk_android.sh $*
android: android-build
## hwpack-install
hwpack-install: $(HWPACK)
$(Q)[ -s $(SD_CARD) ] || echo "Define SD_CARD variable"
$(Q)$(SUDO) scripts/sunxi-media-create.sh $(SD_CARD) $(HWPACK) $(ROOTFS)
libs: cedarx-libs/.git
update:
$(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 - Build and install hwpack and optional rootfs to sdcard"
@echo " Arguments:"
@echo " SD_CARD= - Target (ie. /dev/sdx)"
@echo " ROOTFS= - Source rootfs (ie. rootfs.tar.gz)"
@echo " make livesuit - Build and create livesuit image"
@echo " Arguments:"
@echo " ROOTFS= - Source rootfs (ie. rootfs.tar.gz)"
@echo ""
@echo " make android - **Experimental**"
@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 " make tools - Builds open source tools"
@echo ""