CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Added missing files (setup, setup-chroot)
[initramfs.git] / Makefile
1 #
2 # initramfs/Makefile
3 #
4
5 TOPDIR = $(shell pwd)
6
7 include $(TOPDIR)/../toolchain/vars.mk
8
9 TARGET = arm-crux-linux-gnueabi
10 DEVICE = versatile
11
12 WORK = $(TOPDIR)/work
13 CLFS = $(TOPDIR)/../toolchain/clfs
14 CROSSTOOLS = $(TOPDIR)/../toolchain/crosstools
15
16
17 KERNEL_PATH = $(PWD)/../kernel/$(DEVICE)
18 KERNEL_VERSION = $(shell grep '^KERNEL_VERSION = ' $(KERNEL_PATH)/Makefile | sed 's|KERNEL_VERSION = ||')
19
20 BUSYBOX_VERSION = 1.19.4
21 BUSYBOX_SOURCE = http://busybox.net/downloads/busybox-$(BUSYBOX_VERSION).tar.bz2
22
23 DIALOG_VERSION = 1.1-20120215
24 DIALOG_SOURCE = ftp://dickey.his.com/dialog/dialog-$(DIALOG_VERSION).tgz
25
26 NCURSES_HEADER = $(CLFS)/usr/include/ncurses.h
27
28 .PHONY: all check-root busybox dialog initramfs clean distclean
29
30 all: busybox dialog initramfs
31
32 clean: busybox-clean dialog-clean initramfs-clean
33
34 dist-clean: busybox-distclean dialog-distclean gen_init_cpio-distclean initramfs-distclean
35
36 check-root:
37 @if [ "$$UID" != "0" ]; then \
38 echo "You need to be root to do this."; \
39 echo "Now you should run 'make initramfs' as root to finish compilation or 'sudo make initramfs'."; \
40 exit 1; \
41 fi
42
43 $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2:
44 wget -P $(WORK) -c http://busybox.net/downloads/busybox-$(BUSYBOX_VERSION).tar.bz2
45
46 $(WORK)/busybox-$(BUSYBOX_VERSION): $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2 $(PWD)/busybox-$(BUSYBOX_VERSION).config
47 tar -C $(WORK) -xvjf $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2
48 cp -v $(PWD)/busybox-$(BUSYBOX_VERSION).config $(WORK)/busybox-$(BUSYBOX_VERSION)/.config
49 touch $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2
50
51 $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox: $(WORK)/busybox-$(BUSYBOX_VERSION)
52 export PATH=$(CROSSTOOLS)/bin:$$PATH && \
53 export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
54 make -C $(WORK)/busybox-$(BUSYBOX_VERSION) ARCH=arm CROSS_COMPILE=$(TARGET)- install && \
55 install -D -m 0755 $(WORK)/busybox-$(BUSYBOX_VERSION)/examples/udhcp/simple.script $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/usr/share/udhcpc/default.script && \
56 $(TARGET)-strip $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox && \
57 touch $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox
58
59 busybox: $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox
60
61 busybox-clean:
62 rm -vrf $(WORK)/busybox-$(BUSYBOX_VERSION)
63
64 busybox-distclean: busybox-clean
65 rm -vf $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2
66
67 $(WORK)/dialog-$(DIALOG_VERSION).tgz:
68 wget -P $(WORK) -c $(DIALOG_SOURCE)
69
70 $(WORK)/dialog-$(DIALOG_VERSION): $(WORK)/dialog-$(DIALOG_VERSION).tgz
71 tar -C $(WORK) -xvzf $(WORK)/dialog-$(DIALOG_VERSION).tgz
72 touch $(WORK)/dialog-$(DIALOG_VERSION)
73
74 $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog: $(WORK)/dialog-$(DIALOG_VERSION)
75 export PATH=$(CROSSTOOLS)/bin:$$PATH && \
76 export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
77 cd $(WORK)/dialog-$(DIALOG_VERSION) && \
78 ./configure --build=$(BUILD) --host=$(TARGET) --prefix=/usr --with-ncursesw && \
79 find -type f -name 'makefile' \
80 -exec sed -e "s|-I/usr|-I$(CLFS)/usr|g" -e "s|-L/usr|-L$(CLFS)/usr|g" -i {} \; && \
81 make CC="$(TARGET)-gcc -static" && \
82 make DESTDIR=$(WORK)/dialog-$(DIALOG_VERSION)/_install install && \
83 $(TARGET)-strip $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog && \
84 touch $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog
85
86 dialog: $(NCURSES_HEADER) $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog
87
88 dialog-clean:
89 rm -vrf $(WORK)/dialog-$(DIALOG_VERSION)
90
91 dialog-distclean: dialog-clean
92 rm -vf $(WORK)/dialog-$(DIALOG_VERSION).tgz
93
94 $(WORK)/gen_init_cpio: $(WORK)/gen_init_cpio.c
95 cd $(WORK) && \
96 $(CC) $(CFLAGS) -Wall -o gen_init_cpio gen_init_cpio.c
97
98 gen_init_cpio: $(WORK)/gen_init_cpio
99
100 gen_init_cpio-clean:
101 rm -rf $(WORK)/gen_init_cpio
102
103 gen_init_cpio-distclean: gen_init_cpio-clean
104
105 $(WORK)/initramfs.cpio.gz-$(KERNEL_VERSION): check-root busybox dialog $(TOPDIR)/filesystem $(WORK)/gen_init_cpio $(WORK)/initramfs.lst
106 mkdir -p $(WORK)/mnt/{etc,lib,usr/share/terminfo}
107 cp -dRv $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/* $(WORK)/mnt
108 install -v -m 0755 $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog $(WORK)/mnt/usr/bin
109 cp -dRv $(CLFS)/lib/libnss_{files*,dns*} $(CLFS)/lib/libresolv* $(WORK)/mnt/lib
110 cp -dRv $(CLFS)/usr/share/terminfo/v $(WORK)/mnt/usr/share/terminfo
111 install -v -m 0644 $(TOPDIR)/filesystem/{fstab,inittab,profile,protocols,*.conf} $(WORK)/mnt/etc
112 install -v -m 0755 $(TOPDIR)/filesystem/rc $(WORK)/mnt/etc
113 install -v -m 0755 $(TOPDIR)/filesystem/{setup,crux} $(WORK)/mnt/usr/bin
114 /sbin/ldconfig -r $(WORK)/mnt
115 cd $(WORK)/mnt && \
116 sed -e "s/#KERNEL_VERSION#/$(KERNEL_VERSION)/g; s/#BUSYBOX_VERSION#/$(BUSYBOX_VERSION)/g" \
117 $(WORK)/initramfs.lst > $(WORK)/initramfs.lst-sed && \
118 $(WORK)/gen_init_cpio $(WORK)/initramfs.lst-sed | cpio -id && \
119 find * | cpio -H newc -o > $(WORK)/initramfs.cpio && \
120 gzip -v9 $(WORK)/initramfs.cpio
121 mv $(WORK)/initramfs.cpio.gz{,-$(KERNEL_VERSION)}
122 rm -rf $(WORK)/mnt
123
124 initramfs: $(WORK)/initramfs.cpio.gz-$(KERNEL_VERSION)
125
126 initramfs-clean:
127 rm -rf $(WORK)/initramfs-$(KERNEL_VERSION) $(WORK)/mnt $(WORK)/initramfs.cpio.gz-$(KERNEL_VERSION)
128
129 initramfs-distclean: initramfs-clean
130
131 # End of file