xref: /dragonfly/initrd/Makefile (revision 9560d18cc62dd91f76f6c0a6148284006d07a7b9)
1INITRD_MAKE=        LC_ALL=C \
2                    make -m ${.CURDIR}/../share/mk
3INITRD_SUBDIRS=     etc
4RESCUE_SUBDIRS=     oinit rescue rescue.libcrypto
5
6# Temporary directory to stage the files for creating the initrd image.
7#
8# NOTE: Do not place this directory in the object tree, so that the entire
9#       object tree can be exported read-only for upgrading other machines.
10#
11TMPDIR?=  /tmp
12STAGEDIR:=          ${TMPDIR}/initrd_staged.${.MAKE.PID}
13
14
15all:
16          @echo "--------------------------------------------------------------"
17          @echo ">>> building rescue tools and initrd contents ..."
18          @echo "--------------------------------------------------------------"
19.for _dir in ${RESCUE_SUBDIRS} ${INITRD_SUBDIRS}
20          (cd ${.CURDIR}/${_dir}; \
21              ${INITRD_MAKE} obj; \
22              ${INITRD_MAKE} depend all)
23.endfor
24          @echo "--------------------------------------------------------------"
25          @echo ">>> complete building rescue and initrd"
26          @echo "--------------------------------------------------------------"
27
28
29install:
30          # If called by 'installworld' (i.e., 'WORLDINSTALL' defined),
31          # do not overwrite the existing ones.
32.if !(defined(WORLDINSTALL) && exists(${DESTDIR}/rescue/rescue))
33          @echo "--------------------------------------------------------------"
34          @echo ">>> installing rescue tools to ${DESTDIR}/rescue ..."
35          @echo "--------------------------------------------------------------"
36.for _dir in ${RESCUE_SUBDIRS}
37          (cd ${.CURDIR}/${_dir}; \
38              ${INITRD_MAKE} BINDIR=/rescue install)
39.endfor
40.endif
41
42.if !(defined(WORLDINSTALL) && exists(${DESTDIR}/boot/kernel/initrd.img.gz))
43          @echo "--------------------------------------------------------------"
44          @echo ">>> setting up ${DESTDIR}/boot/kernel/initrd.img.gz ..."
45          @echo "--------------------------------------------------------------"
46          rm -rf ${STAGEDIR}
47.for _dir in ${INITRD_SUBDIRS}
48          (cd ${.CURDIR}/${_dir}; \
49              mkdir -p ${STAGEDIR}/${_dir}; \
50              ${INITRD_MAKE} BINDIR=${STAGEDIR}/${_dir} DESTDIR="" install)
51.endfor
52          sh ${.CURDIR}/mkinitrd.sh \
53              -b ${DESTDIR}/boot \
54              -r ${DESTDIR}/rescue \
55              -c ${STAGEDIR}
56          rm -rf ${STAGEDIR}
57.endif
58
59
60clean:
61.for _dir in ${RESCUE_SUBDIRS} ${INITRD_SUBDIRS}
62          (cd ${.CURDIR}/${_dir} && ${INITRD_MAKE} clean cleandepend)
63.endfor
64
65
66.ORDER: all install
67.MAIN: all
68