Commit | Line | Data |
---|---|---|
b70e0e65 | 1 | # |
a87f2538 | 2 | # initrd/Makefile |
b70e0e65 JB |
3 | # |
4 | ||
00c769e1 VM |
5 | SHELL = /bin/bash |
6 | ||
8fd2995f JB |
7 | TOPDIR = $(shell pwd) |
8 | ||
9 | include $(TOPDIR)/../toolchain/vars.mk | |
10 | ||
a3d2f9f8 | 11 | TARGET = arm-crux-linux-gnueabihf |
b70e0e65 | 12 | |
b70e0e65 JB |
13 | WORK = $(TOPDIR)/work |
14 | CLFS = $(TOPDIR)/../toolchain/clfs | |
15 | CROSSTOOLS = $(TOPDIR)/../toolchain/crosstools | |
16 | ||
00c769e1 | 17 | BUSYBOX_VERSION = 1.26.2 |
8fd2995f JB |
18 | BUSYBOX_SOURCE = http://busybox.net/downloads/busybox-$(BUSYBOX_VERSION).tar.bz2 |
19 | ||
00c769e1 | 20 | E2FSPROGS_VERSION = 1.43.4 |
908a5d6e JB |
21 | E2FSPROGS_SOURCE = http://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v$(E2FSPROGS_VERSION)/e2fsprogs-$(E2FSPROGS_VERSION).tar.gz |
22 | ||
00c769e1 | 23 | DIALOG_VERSION = 1.3-20160828 |
07e084db | 24 | DIALOG_SOURCE = ftp://invisible-island.net/dialog/dialog-$(DIALOG_VERSION).tgz |
b70e0e65 | 25 | |
39efd9ba JB |
26 | NCURSES_HEADER = $(CLFS)/usr/include/ncurses.h |
27 | ||
908a5d6e | 28 | .PHONY: all check-root busybox e2fsprogs dialog initrd clean distclean |
b70e0e65 | 29 | |
8fd2995f | 30 | all: initrd |
b70e0e65 | 31 | |
908a5d6e | 32 | clean: busybox-clean e2fsprogs-clean dialog-clean initrd-clean |
b70e0e65 | 33 | |
908a5d6e | 34 | distclean: busybox-distclean e2fsprogs-clean dialog-distclean initrd-distclean |
b70e0e65 JB |
35 | |
36 | check-root: | |
37 | @if [ "$$UID" != "0" ]; then \ | |
38 | echo "You need to be root to do this."; \ | |
8fd2995f | 39 | echo "Now you should run 'make initrd' as root to finish compilation or 'sudo make initrd'."; \ |
b70e0e65 JB |
40 | exit 1; \ |
41 | fi | |
42 | ||
43 | $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2: | |
8fd2995f | 44 | wget -P $(WORK) -c $(BUSYBOX_SOURCE) |
b70e0e65 | 45 | |
a87f2538 | 46 | $(WORK)/busybox-$(BUSYBOX_VERSION): $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2 $(TOPDIR)/busybox-$(BUSYBOX_VERSION).config $(WORK)/fix-resource_header.patch |
b70e0e65 | 47 | tar -C $(WORK) -xvjf $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2 |
99c170c7 JB |
48 | cd $(WORK)/busybox-$(BUSYBOX_VERSION) && \ |
49 | patch -p1 -i $(WORK)/fix-resource_header.patch | |
b70e0e65 | 50 | cp -v $(TOPDIR)/busybox-$(BUSYBOX_VERSION).config $(WORK)/busybox-$(BUSYBOX_VERSION)/.config |
766ef30c | 51 | touch $(WORK)/busybox-$(BUSYBOX_VERSION) |
b70e0e65 | 52 | |
8fd2995f | 53 | $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox: $(WORK)/busybox-$(BUSYBOX_VERSION) |
b70e0e65 JB |
54 | export PATH=$(CROSSTOOLS)/bin:$$PATH && \ |
55 | export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \ | |
07bbf582 | 56 | make -j1 -C $(WORK)/busybox-$(BUSYBOX_VERSION) ARCH=arm CROSS_COMPILE=$(TARGET)- install && \ |
8fd2995f JB |
57 | install -D -m 0755 $(WORK)/busybox-$(BUSYBOX_VERSION)/examples/udhcp/simple.script $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/usr/share/udhcpc/default.script && \ |
58 | $(TARGET)-strip $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox && \ | |
59 | touch $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox | |
b70e0e65 | 60 | |
8fd2995f | 61 | busybox: $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox |
b70e0e65 JB |
62 | |
63 | busybox-clean: | |
64 | rm -vrf $(WORK)/busybox-$(BUSYBOX_VERSION) | |
65 | ||
3787d984 | 66 | busybox-distclean: busybox-clean |
b70e0e65 JB |
67 | rm -vf $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2 |
68 | ||
908a5d6e JB |
69 | $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION).tar.gz: |
70 | wget -P $(WORK) -c $(E2FSPROGS_SOURCE) | |
71 | ||
72 | $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION): $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION).tar.gz | |
73 | tar -C $(WORK) -xvzf $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION).tar.gz | |
74 | touch $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION) | |
75 | ||
76 | $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION)/misc/mke2fs: $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION) | |
77 | export PATH=$(CROSSTOOLS)/bin:$$PATH && \ | |
78 | export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \ | |
79 | cd $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION) && \ | |
80 | ./configure --build=$(BUILD) --host=$(TARGET) --prefix=/usr --with-root-prefix= \ | |
81 | --mandir=/usr/man --disable-symlink-install --disable-nls --disable-compression \ | |
82 | --disable-htree --disable-elf-shlibs --disable-bsd-shlibs --disable-profile \ | |
83 | --disable-checker --disable-jbd-debug --disable-blkid-debug --disable-testio-debug \ | |
84 | --enable-libuuid --enable-libblkid --disable-libquota --disable-debugfs --disable-imager \ | |
85 | --disable-resizer --disable-defrag --disable-fsck --disable-e2initrd-helper \ | |
86 | --disable-tls --disable-rpath && \ | |
87 | make V=1 CFLAGS="$(CFLAGS) -static" LDFLAGS="$(LDFLAGS) -static" && \ | |
88 | $(TARGET)-strip $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION)/misc/mke2fs && \ | |
89 | touch $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION)/misc/mke2fs | |
90 | ||
91 | e2fsprogs: $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION)/misc/mke2fs | |
92 | ||
93 | e2fsprogs-clean: | |
94 | rm -vrf $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION) | |
95 | ||
96 | e2fsprogs-distclean: | |
97 | rm -vf $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION).tar.bz2 | |
98 | ||
8fd2995f JB |
99 | $(WORK)/dialog-$(DIALOG_VERSION).tgz: |
100 | wget -P $(WORK) -c $(DIALOG_SOURCE) | |
101 | ||
102 | $(WORK)/dialog-$(DIALOG_VERSION): $(WORK)/dialog-$(DIALOG_VERSION).tgz | |
103 | tar -C $(WORK) -xvzf $(WORK)/dialog-$(DIALOG_VERSION).tgz | |
104 | touch $(WORK)/dialog-$(DIALOG_VERSION) | |
105 | ||
106 | $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog: $(WORK)/dialog-$(DIALOG_VERSION) | |
107 | export PATH=$(CROSSTOOLS)/bin:$$PATH && \ | |
108 | export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \ | |
109 | cd $(WORK)/dialog-$(DIALOG_VERSION) && \ | |
110 | ./configure --build=$(BUILD) --host=$(TARGET) --prefix=/usr --with-ncursesw && \ | |
111 | find -type f -name 'makefile' \ | |
112 | -exec sed -e "s|-I/usr|-I$(CLFS)/usr|g" -e "s|-L/usr|-L$(CLFS)/usr|g" -i {} \; && \ | |
a03a415e | 113 | make CC="$(TARGET)-gcc -static" && \ |
8fd2995f JB |
114 | make DESTDIR=$(WORK)/dialog-$(DIALOG_VERSION)/_install install && \ |
115 | $(TARGET)-strip $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog && \ | |
116 | touch $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog | |
117 | ||
39efd9ba | 118 | dialog: $(NCURSES_HEADER) $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog |
8fd2995f JB |
119 | |
120 | dialog-clean: | |
121 | rm -vrf $(WORK)/dialog-$(DIALOG_VERSION) | |
122 | ||
3787d984 JB |
123 | dialog-distclean: dialog-clean |
124 | rm -vf $(WORK)/dialog-$(DIALOG_VERSION).tgz | |
8fd2995f | 125 | |
b70e0e65 JB |
126 | $(WORK)/mnt: |
127 | mkdir -p $(WORK)/mnt | |
128 | ||
908a5d6e | 129 | $(WORK)/initrd.gz: check-root busybox e2fsprogs dialog $(WORK)/mnt $(TOPDIR)/filesystem $(TOPDIR)/mkinitrd.sh |
00c769e1 | 130 | ./mkinitrd.sh --name=$(WORK)/initrd.gz --size=4096 |
6ad01a84 JB |
131 | cd $(WORK) && gunzip -v initrd.gz |
132 | mount -v -t ext2 -o loop,rw $(WORK)/initrd $(WORK)/mnt | |
b70e0e65 | 133 | cp -dRv $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/* $(WORK)/mnt |
908a5d6e JB |
134 | install -v -m 0755 $(WORK)/e2fsprogs-$(E2FSPROGS_VERSION)/misc/mke2fs $(WORK)/mnt/sbin |
135 | for i in 2 3 4 4dev; do \ | |
136 | ln -s mke2fs $(WORK)/mnt/sbin/mkfs.ext$$i; \ | |
137 | done | |
8fd2995f | 138 | install -v -m 0755 $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog $(WORK)/mnt/usr/bin |
8fd2995f JB |
139 | cp -dRv $(CLFS)/lib/libnss_{files*,dns*} $(CLFS)/lib/libresolv* $(WORK)/mnt/lib |
140 | install -d $(WORK)/mnt/usr/share/terminfo | |
141 | cp -dRv $(CLFS)/usr/share/terminfo/v $(WORK)/mnt/usr/share/terminfo | |
b70e0e65 | 142 | install -v -m 0644 $(TOPDIR)/filesystem/{fstab,inittab,profile,protocols,*.conf} $(WORK)/mnt/etc |
d345ec82 JB |
143 | install -v -m 0664 $(TOPDIR)/filesystem/group $(WORK)/mnt/etc |
144 | install -v -m 0600 $(TOPDIR)/filesystem/passwd $(WORK)/mnt/etc | |
145 | install -v -m 0400 $(TOPDIR)/filesystem/shadow $(WORK)/mnt/etc | |
b70e0e65 | 146 | install -v -m 0755 $(TOPDIR)/filesystem/rc $(WORK)/mnt/etc && \ |
d345ec82 | 147 | install -v -m 0755 $(TOPDIR)/filesystem/{setup,setup-chroot,crux} $(WORK)/mnt/usr/bin && \ |
1a72982e | 148 | ln -s bin/busybox $(WORK)/mnt/init |
b70e0e65 JB |
149 | /sbin/ldconfig -r $(WORK)/mnt |
150 | umount -v $(WORK)/mnt | |
6ad01a84 JB |
151 | cd $(WORK) && gzip -v initrd |
152 | touch $(WORK)/initrd.gz | |
b70e0e65 | 153 | |
6ad01a84 | 154 | initrd: $(WORK)/initrd.gz |
b70e0e65 JB |
155 | |
156 | initrd-clean: check-root | |
58823b0a | 157 | rm -rvf $(WORK)/initrd.gz $(WORK)/mnt |
b70e0e65 JB |
158 | |
159 | initrd-distclean: initrd-clean | |
160 | ||
161 | # End of file |