-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (60 loc) · 1.82 KB
/
Copy pathMakefile
File metadata and controls
76 lines (60 loc) · 1.82 KB
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
#######################################################
# Makefile for upgrade.bin
# Suitable for: NP1380 <1.6.0 template>
# Created by zhiyb @ GT-Soft
#
PKGCFG = pkg.cfg
LEBSIZE = 516096
PAGESIZE = 4096
TARG = upgrade.bin
DIRS =
INIT = -mmc
IMGS = $(addsuffix .img, $(DIRS))
OBJS = $(addsuffix .ref, $(DIRS))
MKUBIFS = ./mkfs.ubifs
UBIREFIMG = ./ubirefimg
MKPKG = ./mkpkg
.PHONY: $(INIT:%=initramfs%)
$(TARG): $(PKGCFG) $(INIT:%=uImage%) $(OBJS)
$(MKPKG) $<
mv *_*.bin $@
.PHONY: mnt
mnt: $(TARG) init.tar.bz2
mkdir -p mnt
mount -t vfat /dev/sdd1 mnt
cp -a $(TARG) $(INIT:%=uImage%) mnt/
mkdir -p mnt/rootfs
cp -a init.tar.bz2 mnt/rootfs/
umount -l mnt
rmdir mnt
CLEAN += init.tar.bz2
init.tar.bz2:
find rootfs/ -name '.*~' -delete
tar jcvf $@ -C rootfs/ .
%.img: %
$(MKUBIFS) -r $(basename $@) -m $(PAGESIZE) -e $(LEBSIZE) -o $@
%.ref: %.img
$(UBIREFIMG) $< $@
CLEAN += $(INIT:%=initramfs%.gz)
initramfs%.gz:
$(MAKE) initramfs$*
$(INIT:%=initramfs%):
(cd $@; find -name '.*~' -delete; find . | cpio -o -H newc -R 0:0) | gzip -9 > $@.gz
CLEAN += vmlinux.bin.head
vmlinux.bin.head: vmlinux.bin
dd if=$< of=$@ count=1 bs=$(shell bash -c "grep -ab -m 1 -o -F $$'\x1F\x8B\x08' $< | head -1 | cut -f 1 -d :")
CLEAN += $(INIT:%=vmlinux%.bin.new)
vmlinux%.bin.new: vmlinux.bin.head initramfs%.gz vmlinux%.bin.zero
cat $^ > $@
CLEAN += $(INIT:%=vmlinux%.bin.zero)
vmlinux%.bin.zero: vmlinux.bin vmlinux.bin.head initramfs%.gz
dd if=/dev/zero of=$@ count=1 bs=$$(($(shell stat -c %s $<) - $(shell stat -c %s $(word 2,$^)) - $(shell stat -c %s $(word 3,$^))))
CLEAN += $(INIT:%=uImage%.gz)
uImage%.gz: vmlinux%.bin.new
gzip -c $< -9 > $@
CLEAN += $(INIT:%=uImage%)
uImage%: uImage%.gz
mkimage -A mips -O linux -T kernel -C gzip -a 80010000 -e 802e3800 -n Linux-2.6.24.3 -d $< $@
.PHONY: clean
clean:
rm -f $(CLEAN) $(IMGS) $(OBJS) $(TARG)