1# Makefile for ramdisk image 2.include <bsd.own.mk> 3 4USE_BITCODE:=no 5 6install: 7 8all: 9 10# Add a few defines we are going to use during the image 11# creation to determine what features and binaries to include 12# in the final image 13# ACPI do we have/include the acpi binary 14# RAMDISK_SMALL is the script called with MKSMALL=yes 15# DYNAMIC does the ramdisk contain dynamic binaries? 16RAMDISK_INC_ACPI= 0 17RAMDISK_SMALL= 0 18RAMDISK_DYNAMIC= 0 19 20RAMDISK_DEFINES= \ 21 -DRAMDISK_INC_ACPI=${RAMDISK_INC_ACPI} \ 22 -DRAMDISK_SMALL=${RAMDISK_SMALL} \ 23 -DRAMDISK_DYNAMIC=${RAMDISK_DYNAMIC} 24 25# The name of the proto file to use 26PROTO= proto 27 28# Common to all architectures 29ETC= system.conf group 30EXTRA= rc 31PROTO_FILES= proto.common.etc 32PROTO_FILES+= proto.common.dynamic 33PROGRAMS= # defined 34PROGRAMS+= fsck_mfs 35dir.fsck_mfs:= minix/commands/fsck.mfs 36PROGRAMS+= grep 37dir.grep:= minix/usr.bin/grep 38PROGRAMS+= input 39dir.input:= minix/servers/input 40PROGRAMS+= loadramdisk 41dir.loadramdisk:= minix/commands/loadramdisk 42PROGRAMS+= mfs 43dir.mfs:= minix/fs/mfs 44PROGRAMS+= mount 45dir.mount:= minix/commands/mount 46PROGRAMS+= procfs 47dir.procfs:= minix/fs/procfs 48PROGRAMS+= service 49dir.service:= minix/commands/service 50PROGRAMS+= sh 51dir.sh:= bin/sh 52PROGRAMS+= sysenv 53dir.sysenv:= minix/commands/sysenv 54PROGRAMS+= umount 55dir.umount:= minix/commands/umount 56 57.if ${MKSMALL} != "yes" 58RAMDISK_SMALL= 1 59.endif 60 61.if ${MACHINE_ARCH} == "i386" 62ETC+= rs.single 63PROGRAMS+= at_wini 64dir.at_wini:= minix/drivers/storage/at_wini 65PROGRAMS+= floppy 66dir.floppy:= minix/drivers/storage/floppy 67PROGRAMS+= pci 68dir.pci:= minix/drivers/bus/pci 69PROGRAMS+= pckbd 70dir.pckbd:= minix/drivers/hid/pckbd 71PROGRAMS+= cdprobe 72dir.cdprobe:= minix/commands/cdprobe 73PROGRAMS+= pwd_mkdb 74dir.pwd_mkdb:= usr.sbin/pwd_mkdb 75 76.if ${MKSMALL} != "yes" 77PROGRAMS+= ahci 78dir.ahci:= minix/drivers/storage/ahci 79PROGRAMS+= virtio_blk 80dir.virtio_blk:= minix/drivers/storage/virtio_blk 81PROGRAMS+= ext2 82dir.ext2:= minix/fs/ext2 83.endif 84 85.if ${MKACPI} != "no" 86RAMDISK_INC_ACPI= 1 87PROGRAMS+= acpi 88dir.acpi:= minix/drivers/power/acpi 89.endif 90.endif # ${MACHINE_ARCH} == "i386" 91 92.if ${MACHINE_ARCH} == "earm" 93PROGRAMS+= mmc 94dir.mmc:= minix/drivers/storage/mmc 95.endif # ${MACHINE_ARCH} == "earm" 96 97.if ${LDSTATIC} == "-dynamic" 98RAMDISK_DYNAMIC= 1 99PROGRAMS+= ld.elf_so 100PROG_LIBS+= libc 101PROG_MINIXLIBS+= libterminfo 102.endif 103 104CPPFLAGS+= -I${NETBSDSRCDIR}/servers 105 106# LSC We have to take care of not erasing the source file, so never add EXTRA 107# to CLEANFILES 108CLEANFILES += ${PROGRAMS} ${SCRIPTS} ${ETC} image image.c 109CLEANFILES += proto.gen proto.dev proto.dev.mtree 110CLEANFILES += ${PROG_LIBEXEC} 111CLEANFILES += ${.OBJDIR}/etc/* 112 113############################################################# 114# LSC Below this point the rules should not be modified 115############################################################# 116 117# Tool to bootstrap the password db 118TOOL_PWD_MKDB?= ${NETBSDSRCDIR}/usr.sbin/pwd_mkdb/pwd_mkdb 119 120# Remove "drivers/storage/ramdisk" component from path 121PROGROOT:= ${.OBJDIR:S,/minix/drivers/storage/ramdisk,,} 122 123# Generate dependencies rules for config files 124.for etc in ${ETC} 125etc/${etc}: ${NETBSDSRCDIR}/etc/${etc} 126 mkdir -p ${.OBJDIR}/etc 127 ${INSTALL} $> $@ 128.endfor 129 130# LSC Force the regeneration of the proto file as it seems sometimes 131# they are not copied over as needed. 132# LSC ramdisk rc file != /etc/rc 133# BJG if ${.CURDIR} == ${.OBJDIR}, we are building in-tree and install 134# shouldn't try to install the originals over the originals. Otherwise 135# we are building out-of-tree and the contents should be copied 136# unconditionally in case the contents have changed after the first copy. 137.if ${.CURDIR} != ${.OBJDIR} 138.for file in ${EXTRA} ${PROTO} ${PROTO_FILES} 139CLEANFILES += ${.OBJDIR}/${file} 140${file}: ${NETBSDSRCDIR}/minix/drivers/storage/ramdisk/${file} .PHONY 141 ${INSTALL} $> $@ 142.endfor 143.endif 144 145# Generate dependencies rules for dynamic libraries, if needed 146.for lib in ${PROG_LIBS} 147PROGRAMS+= ${lib}.so.0 148CLEANFILES += ${lib}.so.0 149${lib}.so.0:${PROGROOT}/lib/${lib}/${lib}.so.0 150 ${INSTALL} $> $@ 151 152# BJG - Don't invoke parallel Makes 153#${PROGROOT}/lib/${lib}/${lib}.so.0: 154# ${MAKE} -C ${NETBSDSRCDIR}/lib/${lib} all 155.endfor 156 157.for lib in ${PROG_MINIXLIBS} 158PROGRAMS+= ${lib}.so.0 159CLEANFILES += ${lib}.so.0 160${lib}.so.0:${PROGROOT}/minix/lib/${lib}/${lib}.so.0 161 ${INSTALL} $> $@ 162 163# BJG - Don't invoke parallel Makes 164#${PROGROOT}/minix/lib/${lib}/${lib}.so.0: 165# ${MAKE} -C ${NETBSDSRCDIR}/minix/lib/${lib} all 166.endfor 167 168# Generate dependencies rules for binaries 169.for prog in ${PROGRAMS} 170${prog}: ${PROGROOT}/${dir.${prog}}/${prog} 171 ${INSTALL} $> $@ 172 173# BJG - don't invoke parallel Makes 174#${PROGROOT}/${dir.${prog}}/${prog}: 175# ${MAKE} -C ${NETBSDSRCDIR}/${dir.${prog}} all 176.endfor # prog 177 178realall image: proto.gen ${ETC:C/^/etc\//} ${EXTRA} \ 179 etc/master.passwd etc/pwd.db etc/spwd.db etc/passwd etc/group 180 ${_MKMSG_CREATE} "Generating ramdisk image" 181 ${TOOL_MKFSMFS} image proto.gen || { rm -f image; false; } 182 183etc/pwd.db etc/spwd.db etc/passwd: etc/master.passwd 184 185etc/master.passwd: ${NETBSDSRCDIR}/etc/master.passwd 186 mkdir -p ${.OBJDIR}/etc 187 ${INSTALL} $> $@ 188 ${TOOL_PWD_MKDB} -V 0 -p -d . etc/master.passwd 189 190proto.dev.mtree: 191 @echo ". type=dir uname=root gname=operator mode=0755" \ 192 >${.TARGET}.tmp && \ 193 echo "./dev type=dir uname=root gname=operator mode=0755" \ 194 >>${.TARGET}.tmp && \ 195 ${NETBSDSRCDIR}/minix/commands/MAKEDEV/MAKEDEV.sh -m -r \ 196 >> ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} 197 198# We have to remove the two first entries of the generated proto file, as 199# well as the two last ones (closing $). 200# Do not forget to double $ so that make doesn't try to expand it. 201proto.dev: proto.dev.mtree etc/pwd.db etc/spwd.db etc/passwd etc/group 202 ${TOOL_MTREE} -f ${.TARGET}.mtree -N ${.OBJDIR}/etc -C -K device | \ 203 ${TOOL_TOPROTO} | ${TOOL_SED} -e '1,4d' | \ 204 ${TOOL_SED} -e '$$d' |${TOOL_SED} -e '$$d' > ${.TARGET}.tmp 205 grep console ${.TARGET}.tmp # sanity check; is there a console entry? 206 mv ${.TARGET}.tmp ${.TARGET} 207 208proto.gen: ${PROTO} ${PROTO_FILES} proto.dev ${PROGRAMS} 209 ${STRIP} ${PROGRAMS} 210 # We are using the c preprocessor to generate proto.gen 211 # used in the mkfs tool. 212 ${TOOL_CAT} ${PROTO} | ${CC} \ 213 ${RAMDISK_DEFINES} \ 214 -E - | grep -v "^$$" | grep -v "#" >${.TARGET} 215 216.include <minix.service.mk> 217