1 # Makefile for ramdisk image
11 # Add a few defines we are going to use during the image
12 # creation to determine what features and binaries to include
14 # ACPI do we have/include the acpi binary
15 # RAMDISK_SMALL is the script called with MKSMALL=yes
16 # DYNAMIC does the ramdisk contain dynamic binaries?
22 -DRAMDISK_INC_ACPI
=${RAMDISK_INC_ACPI} \
23 -DRAMDISK_SMALL
=${RAMDISK_SMALL} \
24 -DRAMDISK_DYNAMIC
=${RAMDISK_DYNAMIC}
26 # The name of the proto file to use
29 # Common to all architectures
30 ETC
= system.conf group
32 PROTO_FILES
= proto.common.etc proto.common.dynamic
34 PROG_COMMANDS
= mount umount grep fsck_mfs sh service loadramdisk sysenv
35 PROG_SERVERS
= input mfs procfs
41 .if
${MKSMALL} != "yes"
45 .if
${MACHINE_ARCH} == "i386"
48 PROG_DRIVERS
+= at_wini floppy pci pckbd
49 PROG_COMMANDS
+= cdprobe
50 PROG_USR.SBIN
+= pwd_mkdb
52 .if
${MKSMALL} != "yes"
54 PROG_DRIVERS
+= virtio_blk
62 .
endif # ${MACHINE_ARCH} == "i386"
64 .if
${MACHINE_ARCH} == "earm"
66 .
endif # ${MACHINE_ARCH} == "earm"
68 .if
${LDSTATIC} == "-dynamic"
70 PROG_LIBEXEC
+= ld.elf_so
71 PROG_LIBS
+= libc libminlib libcompat_minix libterminfo
74 PROGRAMS
=${PROG_COMMANDS} \
75 ${PROG_BIN} ${PROG_SBIN} ${PROG_USR.BIN
} ${PROG_USR.SBIN
} \
76 ${PROG_DRIVERS} ${PROG_SERVERS} \
79 CPPFLAGS
+= -I
${NETBSDSRCDIR}/servers
81 # LSC We have to take care of not erasing the source file, so never add EXTRA
83 CLEANFILES
+= ${PROGRAMS} ${SCRIPTS} ${ETC} image image.c t
84 CLEANFILES
+= proto.gen proto.dev proto.dev.mtree
85 CLEANFILES
+= ${PROG_LIBEXEC}
86 CLEANFILES
+= ${.OBJDIR
}/etc
/*
88 #############################################################
89 # LSC Below this point the rules should not be modified
90 #############################################################
92 # Tool to bootstrap the password db
93 TOOL_PWD_MKDB?
= ${NETBSDSRCDIR}/usr.sbin
/pwd_mkdb
/pwd_mkdb
95 # Remove "drivers/ramdisk" component from path
96 PROGROOT
:= ${.OBJDIR
:S
,/drivers
/ramdisk
,,}
98 # Generate dependencies rules for config files
100 etc
/${etc}: ${NETBSDSRCDIR}/etc
/${etc}
101 mkdir
-p
${.OBJDIR
}/etc
105 # LSC Force the regeneration of the proto file as it seems sometimes
106 # they are not copied over as needed.
107 # LSC ramdisk rc file != /etc/rc
108 # BJG if ${.CURDIR} == ${.OBJDIR}, we are building in-tree and install
109 # shouldn't try to install the originals over the originals. Otherwise
110 # we are building out-of-tree and the contents should be copied
111 # unconditionally in case the contents have changed after the first copy.
112 .if
${.CURDIR
} != ${.OBJDIR
}
113 .for file in
${EXTRA} ${PROTO} ${PROTO_FILES}
114 CLEANFILES
+= ${.OBJDIR
}/${file}
115 ${file}: ${NETBSDSRCDIR}/drivers
/ramdisk
/${file} .PHONY
120 # Generate dependencies rules for dynamic libraries, if needed
121 .for lib in
${PROG_LIBS}
122 PROGRAMS
+= ${lib}.so
.0
123 CLEANFILES
+= ${lib}.so
.0
124 ${lib}.so
.0:${PROGROOT}/lib
/${lib}/${lib}.so
.0
127 ${PROGROOT}/lib
/${lib}/${lib}.so
.0:
128 ${MAKE} -C
${NETBSDSRCDIR}/lib
/${lib} all
131 # Generate dependencies rules for binaries
133 dir.fsck_mfs
:= fsck.mfs
134 .for
srcdir in bin sbin commands drivers libexec servers usr.bin usr.sbin
135 .for prog in
${PROG_
${srcdir:tu
}}
136 ${prog}: ${PROGROOT}/${srcdir}/${dir.
${prog}:U
${prog}}/${prog}
139 ${PROGROOT}/${srcdir}/${dir.
${prog}:U
${prog}}/${prog}:
140 ${MAKE} -C
${NETBSDSRCDIR}/${srcdir}/${dir.
${prog}:U
${prog}} all
144 realall image
: proto.gen
${ETC
:C
/^
/etc\
//} ${EXTRA} etc
/master.passwd etc
/pwd.db etc
/spwd.db etc
/passwd etc
/group
145 ${_MKMSG_CREATE} "Generating ramdisk image"
146 ${TOOL_MKFSMFS} image proto.gen ||
{ rm -f image
; false
; }
147 # if fsck.mfs -s image | grep -q CLEAN; \
149 # else echo "CLEAN sanity check of image failed." ; \
150 # echo "(Perhaps install current mkfs and fsck.)" ; \
151 # rm -f image; false; \
154 etc
/pwd.db etc
/spwd.db etc
/passwd
: etc
/master.passwd
156 etc
/master.passwd
: ${NETBSDSRCDIR}/etc
/master.passwd
157 rm -rf
${.OBJDIR
}/etc
/
158 mkdir
-p
${.OBJDIR
}/etc
160 ${TOOL_PWD_MKDB} -V
0 -p
-d . etc
/master.passwd
163 @echo
". type=dir uname=root gname=operator mode=0755" \
165 echo
"./dev type=dir uname=root gname=operator mode=0755" \
166 >>${.TARGET
}.tmp
&& \
167 ${NETBSDSRCDIR}/commands
/MAKEDEV
/MAKEDEV.sh
-m
-r \
168 >> ${.TARGET
}.tmp
&& mv
${.TARGET
}.tmp
${.TARGET
}
170 # We have to remove the two first entries of the generated proto file, as
171 # well as the two last ones (closing $).
172 # Do not forget to double $ so that make doesn't try to expand it.
173 proto.dev
: proto.dev.mtree etc
/pwd.db etc
/spwd.db etc
/passwd etc
/group
174 ${TOOL_MTREE} -f
${.TARGET
}.mtree
-N
${.OBJDIR
}/etc
-C
-K device | \
175 ${TOOL_TOPROTO} |
${TOOL_SED} -e
'1,4d' | \
176 ${TOOL_SED} -e
'$$d' |
${TOOL_SED} -e
'$$d' > ${.TARGET
}.tmp
&& \
177 mv
${.TARGET
}.tmp
${.TARGET
}
179 proto.gen
: ${PROTO} ${PROTO_FILES} proto.dev
${PROGRAMS}
181 # We are using the c preprocessor to generate proto.gen
182 # used in the mkfs tool.
183 ${TOOL_CAT} ${PROTO} |
${CC} \
185 -E
- | grep
-v
"^$$" | grep
-v
"#" >${.TARGET
}
187 .
include <minix.service.mk
>