-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
235 lines (197 loc) · 7.31 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
#
# Make file for compiling uomapfs
#
# (C) Copyright 2010
# Texas Instruments, <www.ti.com>
# Nishanth Menon <[email protected]>
#
# This program 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 version 2.
#
# This program is distributed .as is. WITHOUT ANY WARRANTY of any kind,
# whether express or implied; 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
# Handle verbose
ifeq ("$(origin V)", "command line")
VERBOSE = $(V)
endif
ifndef VERBOSE
VERBOSE = 0
endif
Q := $(if $(VERBOSE:1=),@)
# Our default directories
SCRIPT_DIR := scripts
CONFIG_DIR := configs
BUSYBOX := busybox
ETC_SCRIPTS :=$(CONFIG_DIR)/etc
# Our standard scripts
MAKECONFIG := $(SCRIPT_DIR)/make.config
GETVAR := $(SCRIPT_DIR)/config.var
PWD := $(shell pwd)
-include .config
target_fs_dir ?= $(PWD)/target/rootfs
target_boot_files_dir ?= $(PWD)/target/boot
host_binaries ?= $(PWD)/bin
#host_utils ?= omap-u-boot-utils
ifeq ("$(busybox_defconfig_file)", "")
busybox_defconfig_file := $(PWD)/$(CONFIG_DIR)/busybox_generic.config
endif
BUILD_TARGETS :=
DCLEAN_TARGETS :=
ifneq ("$(bootloader)", "")
BUILD_TARGETS += bootloader
DCLEAN_TARGETS += bootloader_clean
endif
ifneq ("$(BUSYBOX)", "")
BUILD_TARGETS += fs
DCLEAN_TARGETS += fs_clean
endif
ifneq ("$(kernel)", "")
BUILD_TARGETS += kernel
DCLEAN_TARGETS += kernel_clean
endif
ifneq ("$(host_utils)", "")
BUILD_TARGETS += utils
DCLEAN_TARGETS += utils_clean
endif
# Phony rules
.PHONY: all distclean .config clean bootloader bootloader_defconf fs git ramdisk utils
.EXPORT_ALL_VARIABLES:
all: git .config
$(Q)[ -f .config ] || (echo "no .config, run 'make with one of: "`ls configs/*defconfig|sed -e 's/configs\///g'` && exit 1)
$(Q)echo "Build targets=$(BUILD_TARGETS)"
$(Q)$(MAKE) $(BUILD_TARGETS)
distclean:
$(Q)$(MAKE) $(DCLEAN_TARGETS)
$(Q)rm -rf .config $(target_fs_dir) $(target_boot_files_dir) \
$(host_binaries) target
spl_bootloader_clean:
$(Q)$(MAKE) -C $(spl_bootloader) distclean
bootloader_clean:
$(Q)$(MAKE) -C $(bootloader) distclean
ifneq ("$(spl_bootloader)", "")
$(Q)$(MAKE) spl_bootloader_clean
endif
kernel_clean:
$(Q)$(MAKE) -C $(kernel) distclean
fs_clean:
$(Q)$(MAKE) -C $(BUSYBOX) distclean
utils_clean:
$(Q)$(MAKE) -C $(host_utils) distclean
git:
$(Q)git submodule status|grep '^-' && git submodule init && \
git submodule update || echo 'nothin to update'
gitsync:
$(Q)git submodule init && git submodule sync && \
git submodule update || echo 'nothin to update'
ifneq ("$(spl_bootloader)", "")
_spl_img_install:
$(Q)install -d $(target_boot_files_dir)
$(Q)install $(spl_bootloader)/$(spl_bootloader_image_location) \
$(target_boot_files_dir)
ifneq ("$(bootloader)", "$(spl_bootloader)")
spl_bootloader: git .config $(spl_bootloader)/$(spl_bootloader_image_location)
$(Q)$(MAKE) _spl_img_install
$(spl_bootloader)/$(spl_bootloader_image_location): $(spl_bootloader)/include/config.h
$(Q)$(MAKE) -C $(spl_bootloader) $(spl_bootloader_image)
$(spl_bootloader)/include/config.h: .config
$(Q)$(MAKE) -C $(spl_bootloader) $(spl_bootloader_defconfig)
else
ifneq ("$(bootloader_image)", "$(spl_bootloader_image)")
spl_bootloader: git .config $(spl_bootloader)/$(spl_bootloader_image_location)
ifneq ("$(bootloader_defconfig)", "$(spl_bootloader_defconfig)")
$(Q)$(MAKE) -C $(spl_bootloader) $(spl_bootloader_defconfig)
endif
$(Q)$(MAKE) -C $(spl_bootloader) $(spl_bootloader_image)
$(Q)$(MAKE) _spl_img_install
else
spl_bootloader:
$(Q)$(MAKE) _spl_img_install
endif
endif
endif
bootloader: git .config $(bootloader)/$(bootloader_image_location)
$(Q)install -d $(target_boot_files_dir)
$(Q)install $(bootloader)/$(bootloader_image_location) \
$(target_boot_files_dir)
ifneq ("$(spl_bootloader)", "")
$(Q)$(MAKE) spl_bootloader
endif
ifneq ("$(bootloader_cmd)", "")
$(Q)mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'bootscr'\
-d $(bootloader_cmd) $(target_boot_files_dir)/boot.scr
$(Q)install $(bootloader_cmd) $(target_boot_files_dir)/boot.cmd
endif
ifneq ("$(bootloader_env)", "")
$(Q)install $(bootloader_env) $(target_boot_files_dir)/uEnv.txt
endif
$(bootloader)/$(bootloader_image_location): $(bootloader)/include/config.h
$(Q)$(MAKE) -C $(bootloader) $(bootloader_image)
$(bootloader)/include/config.h: .config
$(Q)$(MAKE) -C $(bootloader) $(bootloader_defconfig)
fs: git .config $(BUSYBOX)/busybox busymkdir
$(Q)fakeroot $(MAKE) -C$(BUSYBOX) CONFIG_PREFIX=$(target_fs_dir) install
$(Q)./scripts/cp_libs.sh $(target_fs_dir)/bin/busybox $(target_fs_dir)/lib
$(Q)cp -rf $(PWD)/$(ETC_SCRIPTS)/* $(target_fs_dir)/etc/
busymkdir: .config
for d in lib etc dev proc sys var/log var/run var/lib/misc; do \
install -d $(target_fs_dir)/$$d;\
done
$(Q)rm -f $(target_fs_dir)/d
$(Q)ln -s /sys/kernel/debug $(target_fs_dir)/d
$(Q)ln -s /sys/devices/system/cpu/cpu0/cpufreq/ $(target_fs_dir)/cpufreq
$(Q)ln -s /sys/devices/system/cpu/cpu0/cpuidle/ $(target_fs_dir)/cpuidle
# Ensure that everything is built before we build ramdisk - e.g. tests/utils etc.
ramdisk: all
$(Q)rm -rf $(target_boot_files_dir)/ramdisk* 2>/dev/null
$(Q)mkdir -p $(target_boot_files_dir)/ramdisk-dir
$(Q)dd if=/dev/zero of=$(target_boot_files_dir)/ramdisk count=1 bs=10M
$(Q)(sleep 1|echo y)| fakeroot mkfs -t ext3 $(target_boot_files_dir)/ramdisk
$(Q) echo "NEEDS SUPER USER PERMISSIONS - could not get fusermount to work"
$(Q)sudo mount -o loop -t ext3 $(target_boot_files_dir)/ramdisk $(target_boot_files_dir)/ramdisk-dir
$(Q)sudo cp -a $(target_fs_dir)/* $(target_boot_files_dir)/ramdisk-dir
$(Q)sudo chown -R root.root $(target_boot_files_dir)/ramdisk-dir/bin $(target_boot_files_dir)/ramdisk-dir/sbin
$(Q)sudo umount $(target_boot_files_dir)/ramdisk-dir
$(Q)rmdir $(target_boot_files_dir)/ramdisk-dir
$(Q)gzip $(target_boot_files_dir)/ramdisk
$(BUSYBOX)/busybox: .config $(BUSYBOX)/.config
$(Q)$(MAKE) -C $(BUSYBOX)
$(BUSYBOX)/.config: .config git
$(Q)cp $(busybox_defconfig_file) $(BUSYBOX)/.config
$(Q)$(MAKE) -C $(BUSYBOX) oldconfig
kernel: git fs .config $(kernel)/$(kernel_image_location)
$(Q)$(MAKE) -C $(kernel) INSTALL_MOD_STRIP=1 \
INSTALL_MOD_PATH=$(target_fs_dir) modules_install
$(Q)install -d $(target_boot_files_dir)
$(Q)install $(kernel)/$(kernel_image_location) $(target_boot_files_dir)
ifneq ("$(kernel_dtb)", "")
$(Q)install $(kernel)/$(kernel_dtb) $(target_boot_files_dir)
endif
$(kernel)/$(kernel_image_location): .config $(kernel)/.config
$(Q)$(MAKE) -C $(kernel) $(kernel_image)
$(Q)$(MAKE) -C $(kernel) modules
ifneq ("$(kernel_dtb)", "")
$(Q)$(MAKE) -C $(kernel) dtbs
endif
$(kernel)/.config: .config git
$(Q)if [ -f $(kernel_defconfig) ]; then \
cp $(kernel_defconfig) $(kernel)/.config && \
$(MAKE) -C $(kernel) oldconfig;\
else\
$(MAKE) -C $(kernel) $(kernel_defconfig);\
fi;
%config: git
$(Q)$(MAKECONFIG) $(if $(VERBOSE:0=),-v) -d $(CONFIG_DIR) -c $@
utils: git
$(Q) install -d $(host_binaries)
$(Q) $(MAKE) -C $(host_utils) all usb
$(Q) install $(host_utils)/pusb $(host_utils)/pserial \
$(host_utils)/gpsign $(host_utils)/ukermit $(host_utils)/ucmd\
$(host_binaries)