CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Fixed MAKEFLAGS usage (FS#56)
[initrd.git] / Makefile
CommitLineData
b70e0e65 1#
a87f2538 2# initrd/Makefile
b70e0e65
JB
3#
4
8fd2995f
JB
5TOPDIR = $(shell pwd)
6
7include $(TOPDIR)/../toolchain/vars.mk
8
a3d2f9f8 9TARGET = arm-crux-linux-gnueabihf
b70e0e65 10
b70e0e65
JB
11WORK = $(TOPDIR)/work
12CLFS = $(TOPDIR)/../toolchain/clfs
13CROSSTOOLS = $(TOPDIR)/../toolchain/crosstools
14
f28332c0 15BUSYBOX_VERSION = 1.21.1
8fd2995f
JB
16BUSYBOX_SOURCE = http://busybox.net/downloads/busybox-$(BUSYBOX_VERSION).tar.bz2
17
07e084db
JB
18DIALOG_VERSION = 1.2-20130523
19DIALOG_SOURCE = ftp://invisible-island.net/dialog/dialog-$(DIALOG_VERSION).tgz
b70e0e65 20
39efd9ba
JB
21NCURSES_HEADER = $(CLFS)/usr/include/ncurses.h
22
8fd2995f 23.PHONY: all check-root busybox dialog initrd clean distclean
b70e0e65 24
8fd2995f 25all: initrd
b70e0e65 26
8fd2995f 27clean: busybox-clean dialog-clean initrd-clean
b70e0e65 28
3787d984 29distclean: busybox-distclean dialog-distclean initrd-distclean
b70e0e65
JB
30
31check-root:
32 @if [ "$$UID" != "0" ]; then \
33 echo "You need to be root to do this."; \
8fd2995f 34 echo "Now you should run 'make initrd' as root to finish compilation or 'sudo make initrd'."; \
b70e0e65
JB
35 exit 1; \
36 fi
37
38$(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2:
8fd2995f 39 wget -P $(WORK) -c $(BUSYBOX_SOURCE)
b70e0e65 40
a87f2538 41$(WORK)/busybox-$(BUSYBOX_VERSION): $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2 $(TOPDIR)/busybox-$(BUSYBOX_VERSION).config $(WORK)/fix-resource_header.patch
b70e0e65 42 tar -C $(WORK) -xvjf $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2
99c170c7
JB
43 cd $(WORK)/busybox-$(BUSYBOX_VERSION) && \
44 patch -p1 -i $(WORK)/fix-resource_header.patch
b70e0e65 45 cp -v $(TOPDIR)/busybox-$(BUSYBOX_VERSION).config $(WORK)/busybox-$(BUSYBOX_VERSION)/.config
766ef30c 46 touch $(WORK)/busybox-$(BUSYBOX_VERSION)
b70e0e65 47
8fd2995f 48$(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox: $(WORK)/busybox-$(BUSYBOX_VERSION)
b70e0e65
JB
49 export PATH=$(CROSSTOOLS)/bin:$$PATH && \
50 export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
07bbf582 51 make -j1 -C $(WORK)/busybox-$(BUSYBOX_VERSION) ARCH=arm CROSS_COMPILE=$(TARGET)- install && \
8fd2995f
JB
52 install -D -m 0755 $(WORK)/busybox-$(BUSYBOX_VERSION)/examples/udhcp/simple.script $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/usr/share/udhcpc/default.script && \
53 $(TARGET)-strip $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox && \
54 touch $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox
b70e0e65 55
8fd2995f 56busybox: $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/bin/busybox
b70e0e65
JB
57
58busybox-clean:
59 rm -vrf $(WORK)/busybox-$(BUSYBOX_VERSION)
60
3787d984 61busybox-distclean: busybox-clean
b70e0e65
JB
62 rm -vf $(WORK)/busybox-$(BUSYBOX_VERSION).tar.bz2
63
8fd2995f
JB
64$(WORK)/dialog-$(DIALOG_VERSION).tgz:
65 wget -P $(WORK) -c $(DIALOG_SOURCE)
66
67$(WORK)/dialog-$(DIALOG_VERSION): $(WORK)/dialog-$(DIALOG_VERSION).tgz
68 tar -C $(WORK) -xvzf $(WORK)/dialog-$(DIALOG_VERSION).tgz
69 touch $(WORK)/dialog-$(DIALOG_VERSION)
70
71$(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog: $(WORK)/dialog-$(DIALOG_VERSION)
72 export PATH=$(CROSSTOOLS)/bin:$$PATH && \
73 export LD_LIBRARY_PATH=$(CROSSTOOLS)/lib:$$LD_LIBRARY_PATH && \
74 cd $(WORK)/dialog-$(DIALOG_VERSION) && \
75 ./configure --build=$(BUILD) --host=$(TARGET) --prefix=/usr --with-ncursesw && \
76 find -type f -name 'makefile' \
77 -exec sed -e "s|-I/usr|-I$(CLFS)/usr|g" -e "s|-L/usr|-L$(CLFS)/usr|g" -i {} \; && \
a03a415e 78 make CC="$(TARGET)-gcc -static" && \
8fd2995f
JB
79 make DESTDIR=$(WORK)/dialog-$(DIALOG_VERSION)/_install install && \
80 $(TARGET)-strip $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog && \
81 touch $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog
82
39efd9ba 83dialog: $(NCURSES_HEADER) $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog
8fd2995f
JB
84
85dialog-clean:
86 rm -vrf $(WORK)/dialog-$(DIALOG_VERSION)
87
3787d984
JB
88dialog-distclean: dialog-clean
89 rm -vf $(WORK)/dialog-$(DIALOG_VERSION).tgz
8fd2995f 90
b70e0e65
JB
91$(WORK)/mnt:
92 mkdir -p $(WORK)/mnt
93
ce640efc 94$(WORK)/initrd.gz: check-root busybox dialog $(WORK)/mnt $(TOPDIR)/filesystem $(TOPDIR)/mkinitrd.sh
6ad01a84
JB
95 sh mkinitrd.sh --name=$(WORK)/initrd.gz --size=4096
96 cd $(WORK) && gunzip -v initrd.gz
97 mount -v -t ext2 -o loop,rw $(WORK)/initrd $(WORK)/mnt
b70e0e65 98 cp -dRv $(WORK)/busybox-$(BUSYBOX_VERSION)/_install/* $(WORK)/mnt
8fd2995f 99 install -v -m 0755 $(WORK)/dialog-$(DIALOG_VERSION)/_install/usr/bin/dialog $(WORK)/mnt/usr/bin
8fd2995f
JB
100 cp -dRv $(CLFS)/lib/libnss_{files*,dns*} $(CLFS)/lib/libresolv* $(WORK)/mnt/lib
101 install -d $(WORK)/mnt/usr/share/terminfo
102 cp -dRv $(CLFS)/usr/share/terminfo/v $(WORK)/mnt/usr/share/terminfo
b70e0e65 103 install -v -m 0644 $(TOPDIR)/filesystem/{fstab,inittab,profile,protocols,*.conf} $(WORK)/mnt/etc
d345ec82
JB
104 install -v -m 0664 $(TOPDIR)/filesystem/group $(WORK)/mnt/etc
105 install -v -m 0600 $(TOPDIR)/filesystem/passwd $(WORK)/mnt/etc
106 install -v -m 0400 $(TOPDIR)/filesystem/shadow $(WORK)/mnt/etc
b70e0e65 107 install -v -m 0755 $(TOPDIR)/filesystem/rc $(WORK)/mnt/etc && \
d345ec82 108 install -v -m 0755 $(TOPDIR)/filesystem/{setup,setup-chroot,crux} $(WORK)/mnt/usr/bin && \
1a72982e 109 ln -s bin/busybox $(WORK)/mnt/init
b70e0e65
JB
110 /sbin/ldconfig -r $(WORK)/mnt
111 umount -v $(WORK)/mnt
6ad01a84
JB
112 cd $(WORK) && gzip -v initrd
113 touch $(WORK)/initrd.gz
b70e0e65 114
6ad01a84 115initrd: $(WORK)/initrd.gz
b70e0e65
JB
116
117initrd-clean: check-root
58823b0a 118 rm -rvf $(WORK)/initrd.gz $(WORK)/mnt
b70e0e65
JB
119
120initrd-distclean: initrd-clean
121
122# End of file