Merge branch 'vendor/DHCPCD'
[dragonfly.git] / initrd / Makefile
1 INITRD_MAKE=    LC_ALL=C \
2                 make -m ${.CURDIR}/../share/mk
3
4 # Target directory to install the rescue tools
5 RESCUE_DIR?=            /rescue
6
7 # Temporary directory to stage the initrd files (e.g., /etc)
8 # NOTE: Ignore ${DESTDIR} when staging files into this directory
9 INITRD_STAGEDIR!=       mktemp -d -t initrd-stage
10
11 .END:
12         @rm -rf ${INITRD_STAGEDIR}
13
14 _build_rescue:
15         @echo ">>> Building rescue tools ..."
16 .for _dir in oinit rescue rescue.libcrypto
17         (cd ${.CURDIR}/${_dir} && \
18             ${INITRD_MAKE} obj && \
19             ${INITRD_MAKE} depend all)
20 .endfor
21
22 _install_rescue:
23         @echo ">>> Installing rescue tools ..."
24 .for _dir in oinit rescue rescue.libcrypto
25         (cd ${.CURDIR}/${_dir} && \
26             ${INITRD_MAKE} BINDIR=${RESCUE_DIR} install)
27 .endfor
28
29 _stage_initrd:
30         @echo ">>> Staging initrd contents ..."
31         (cd ${.CURDIR}/etc && \
32             mkdir ${INITRD_STAGEDIR}/etc && \
33             ${INITRD_MAKE} obj && \
34             ${INITRD_MAKE} depend all && \
35             ${INITRD_MAKE} BINDIR=${INITRD_STAGEDIR}/etc DESTDIR="" install)
36
37 _make_initrd:
38         @echo ">>> Creating initrd.img.gz ..."
39         sh ${.CURDIR}/mkinitrd.sh \
40             -b ${DESTDIR}/boot \
41             -r ${DESTDIR}${RESCUE_DIR} \
42             -c ${INITRD_STAGEDIR}
43
44 _clean_rescue:
45         @echo ">>> Cleaning rescue ..."
46 .for _dir in oinit rescue rescue.libcrypto
47         (cd ${.CURDIR}/${_dir} && ${INITRD_MAKE} clean cleandepend)
48 .endfor
49
50 _clean_initrd:
51         @echo ">>> Cleaning initrd ..."
52         (cd ${.CURDIR}/etc && ${INITRD_MAKE} clean cleandepend)
53
54 clean: _clean_rescue _clean_initrd
55
56 _quickrescue: _build_rescue _install_rescue
57 rescue: _clean_rescue _quickrescue .PHONY
58 .ORDER: _clean_rescue _build_rescue _install_rescue
59
60 _quickinitrd: _stage_initrd _make_initrd
61 _initrd: _clean_initrd _quickinitrd
62 .ORDER: _clean_initrd _stage_initrd _make_initrd
63
64 quickrescue: _quickrescue
65 quickinitrd: _quickrescue _quickinitrd
66 initrd: rescue _initrd
67 .ORDER: _quickrescue _quickinitrd
68 .ORDER: rescue _initrd