forked from Oline/cubieboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
188 lines (144 loc) · 6.23 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
# Copyright (c) 2013-2014, Sylvain Leroy <[email protected]>
# 2014, Jean-Marc Lacroix <[email protected]>
# This file is part of CBoard.
# CBoard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# CBoard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with CBoard. If not, see <http://www.gnu.org/licenses/>.
SED := sed
export
include makefile.vars
.PHONY: help all initsm updatesm patch_grsecurity prepare_grsecurity kernel_menuconfig
.PHONY: kernel_gconfig kernel_defconfig kernel_compile with_grsecurity with_lesser_grsecurity
.PHONY: u-boot debootstrap prepare_sdcard check kernel_clean kernel_distclean clean distclean
help:
@echo "What you can do:"
@echo ""
@echo "all: Will do all the job for you."
@echo ""
@echo " -- git submodule management --"
@echo "initsm: git submodule init"
@echo "updatesm: git submodule update"
@echo ""
# @echo " -- grsecurity patch management --"
# @echo "patch_grsecurity: make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX)"
# @echo "prepare_grsecurity: make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX)"
# @echo ""
@echo " -- kernel configuration --"
@echo "kernel_menuconfig: make menuconfig in LINUX_DIR"
@echo "kernel_gconfig: make gconfig in LINUX_DIR"
@echo ""
@echo " -- kernel compilation --"
@echo "kernel_defconfig: Write the default kernel configuration for cubieboard or cubieboard2"
@echo "kernel_compile: make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) uImage modules"
@echo "with_grsecurity: make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) uImage modules"
@echo "with_lesser_grsecurity: make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) DISABLE_PAX_PLUGINS=y uImage modules"
@echo ""
@echo " -- u-boot compilation --"
@echo "u-boot: make CROSS_COMPILE=$(GCC_PREFIX) $(CUBIEBOARD_NAME)_config"
@echo ""
@echo " -- root_fs & sdcard partitionning --"
@echo "debootstrap: create the root_fs (need testing)"
@echo "prepare_sdcard: install u-boot and the root_fs to the sdcard"
@echo ""
@echo " -- checking targets --"
@echo "check: Use qemu to check the generated image"
@echo " $(QEMU_SYSTEM_ARM) -machine cubieboard -m $(QEMU_MEMORY_SIZE) -nographic -serial stdio -kernel $(LINUX_DIR)/arch/arm/boot/uImage -append \"root=/dev/mmcblk0p1 rootwait panic=10\""
@echo ""
@echo " -- cleaning targets --"
@echo "kernel_clean: "
@echo "kernel_distclean: "
@echo "clean: clean the compiled files"
@echo "distclean: clean the compiled files and the chroot directory"
@echo ""
@echo " -- Environnement variables --"
@echo " LINUX_DIR = $(LINUX_DIR)"
@echo " UBOOT_DIR = $(UBOOT_DIR)"
@echo " CHROOT_DIR = $(CHROOT_DIR)"
@echo " GCC_PREFIX = $(GCC_PREFIX)"
@echo " JOBS = $(JOBS)"
@echo " HOSTNAME = $(HOSTNAME)"
@echo " PACKAGES = $(PACKAGES)"
@echo " CUBIEBOARD_NAME = $(CUBIEBOARD_NAME)"
@echo " DTB = $(DTB)"
@echo " DEB_ARCH = $(DEB_ARCH)"
@echo " DEB_SUITE = $(DEB_SUITE)"
@echo " HTTP_PROXY = $(HTTP_PROXY)"
@echo ""
@echo " You can and MUST configure these variables from the file : makefile.vars"
@echo ""
all: u-boot kernel_defconfig kernel_compile debootstrap prepare_sdcard
@echo "Done. You can now use your $(CUBIEBOARD_NAME) :)"
# repositories update
initsm:
git submodule init
updatesm:
git submodule update
# grsecurity patch management
# patch_grsecurity:
# cd $(LINUX_DIR) && git checkout -b 3.2.42
# cd $(LINUX_DIR) && patch -p1 < ../grsecurity/grsecurity-2.9.1-3.2.42-201304061343.patch
# prepare_grsecurity:
# cp conf/config_cubieboard_3.2.42_grsec linux-stable/.config
# Kernel compile
kernel_defconfig: $(LINUX_DIR)/.config
$(LINUX_DIR)/.config:
ifeq ($(findstring .config,$(wildcard $(LINUX_DIR)/.config)), ) # check if .config can be erased, else do not erase it
cd $(LINUX_DIR) && make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) sunxi_defconfig
else
@echo "File .config already exists."
endif
kernel_menuconfig: $(LINUX_DIR)/.config
cd $(LINUX_DIR) && make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) menuconfig
kernel_gconfig: $(LINUX_DIR)/.config
cd $(LINUX_DIR) && make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) gconfig
kernel_compile: $(LINUX_DIR)/arch/arm/boot/uImage $(LINUX_DIR)/arch/arm/boot/dts/$(DTB)
$(LINUX_DIR)/arch/arm/boot/uImage: $(LINUX_DIR)/.config
cd $(LINUX_DIR) && make \
ARCH=arm \
CROSS_COMPILE=$(GCC_PREFIX) \
-j $(JOBS) \
uImage modules LOADADDR=0x40008000
$(LINUX_DIR)/arch/arm/boot/dts/$(DTB): $(LINUX_DIR)/arch/arm/boot/dts/$(DTB) $(LINUX_DIR)/.config
cd $(LINUX_DIR) && make \
ARCH=arm \
CROSS_COMPILE=$(GCC_PREFIX) \
-j $(JOBS) \
dtbs LOADADDR=0x40008000
# with_grsecurity:
# cd $(LINUX_DIR) && make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) -j $(JOBS) uImage modules
# with_lesser_grsecurity:
# cd $(LINUX_DIR) && make ARCH=arm CROSS_COMPILE=$(GCC_PREFIX) DISABLE_PAX_PLUGINS=y -j $(JOBS) uImage modules
kernel_clean:
cd $(LINUX_DIR) && make CROSS_COMPILE=$(GCC_PREFIX) clean
kernel_distclean:
cd $(LINUX_DIR) && make CROSS_COMPILE=$(GCC_PREFIX) mrproper
# bootloader u-boot compile
u-boot: $(UBOOT_DIR)/u-boot-sunxi-with-spl.bin
$(UBOOT_DIR)/u-boot-sunxi-with-spl.bin:
cd $(UBOOT_DIR) && make CROSS_COMPILE=$(GCC_PREFIX) -j $(JOBS) $(CUBIEBOARD_NAME)_config
cd $(UBOOT_DIR) && make CROSS_COMPILE=$(GCC_PREFIX) -j $(JOBS)
u-boot_clean:
cd $(UBOOT_DIR) && make CROSS_COMPILE=$(GCC_PREFIX) clean
u-boot_distclean:
cd $(UBOOT_DIR) && make CROSS_COMPILE=$(GCC_PREFIX) distclean
# Debootstrap
boot.cmd: boot.cmd.in makefile.vars
$(SED) 's/@DTB@/$(DTB)/g' $< > $@
debootstrap: boot.cmd
./make_debootstrap.sh all
prepare_sdcard:
./prepare_sdcard.sh all
# Check
check: $(LINUX_DIR)/arch/arm/boot/uImage
$(QEMU_SYSTEM_ARM) -machine cubieboard -m $(QEMU_MEMORY_SIZE) -nographic -serial stdio -kernel $(LINUX_DIR)/arch/arm/boot/uImage -append "root=/dev/mmcblk0p1 rootwait panic=10"
# Cleaning stuff
clean: u-boot_clean kernel_clean
distclean: u-boot_distclean kernel_distclean
sudo rm -rf $(CHROOT_DIR)