drivers/ramdisk/Makefile fixup
[minix.git] / drivers / ramdisk / Makefile
blob160458bdd68d8d91dfa0deedf73180d8b8d830fd
1 # Makefile for ramdisk image
3 .include <bsd.own.mk>
5 install:
7 all:
9 # Add a few defines we are going to use during the image
10 # creation to determine what features and binaries to include
11 # in the final image
12 # ACPI do we have/include the acpi binary
13 # RAMDISK_SMALL is the script called with MKSMALL=yes
14 # DYNAMIC does the ramdisk contain dynamic binaries?
15 RAMDISK_INC_ACPI= 0
16 RAMDISK_SMALL= 0
17 RAMDISK_DYNAMIC= 0
19 RAMDISK_DEFINES= \
20 -DRAMDISK_INC_ACPI=${RAMDISK_INC_ACPI} \
21 -DRAMDISK_SMALL=${RAMDISK_SMALL} \
22 -DRAMDISK_DYNAMIC=${RAMDISK_DYNAMIC}
24 # The name of the proto file to use
25 PROTO= proto
27 # Common to all architectures
28 ETC= system.conf master.passwd
29 EXTRA= rc mtab
30 PROTO_FILES= proto.common.etc proto.common.dynamic proto.dev
31 PROG_DRIVERS=
32 PROG_COMMANDS= mount fsck.mfs sh service
33 PROG_SERVERS= mfs
34 PROG_USRSBIN=
35 PROG_BIN=
37 .if ${MACHINE_ARCH} == "i386"
38 ETC+= rs.single
39 PROG_DRIVERS+= at_wini floppy pci
40 PROG_COMMANDS+= cdprobe loadramdisk sysenv
41 PROG_SERVERS+= procfs
42 PROG_USRSBIN+= pwd_mkdb
44 .if ${MKSMALL} != "yes"
45 RAMDISK_SMALL= 1
46 PROG_DRIVERS+= ahci
47 PROG_SERVERS+= ext2
48 .endif
50 .if ${MKACPI} != "no"
51 RAMDISK_INC_ACPI= 1
52 PROG_DRIVERS+= acpi
53 .endif
54 .endif # ${MACHINE_ARCH} == "i386"
56 .if ${MACHINE_ARCH} == "earm"
57 EXTRA+= mylogin.sh
58 PROG_DRIVERS+= mmc tty
59 PROG_COMMANDS+= cp dd getty ls time sync sleep stty umount
60 PROG_BIN+= cat rm
61 PROTO= proto.arm.small
62 .endif # ${MACHINE_ARCH} == "earm"
64 .if ${LDSTATIC} == "-dynamic"
65 RAMDISK_DYNAMIC= 1
66 PROG_LIBEXEC+= ld.elf_so
67 PROG_LIBS+= libc libminlib libcompat_minix libterminfo
68 .endif
70 PROGRAMS=${PROG_DRIVERS} ${PROG_COMMANDS} ${PROG_SERVERS} \
71 ${PROG_USRSBIN} ${PROG_BIN} ${PROG_LIBEXEC}
73 CPPFLAGS+= -I${NETBSDSRCDIR}/servers
75 # LSC We have to take care of not erasing the source file, so never add EXTRA
76 # to CLEANFILES
77 CLEANFILES += ${PROGRAMS} ${SCRIPTS} ${ETC} image image.c t proto.gen
78 CLEANFILES += ${LIBRARIES}
79 CLEANFILES += ${PROG_LIBEXEC}
80 CLEANFILES += ${.OBJDIR}/etc/*
82 #############################################################
83 # LSC Below this point the rules should not be modified
84 #############################################################
86 # Tool to bootstrap the password db
87 TOOL_PWD_MKDB?= ${NETBSDSRCDIR}/usr.sbin/pwd_mkdb/pwd_mkdb
89 # Remove "drivers/ramdisk" component from path
90 PROGROOT:= ${.OBJDIR:S,drivers/ramdisk,,}
92 # Generate dependencies rules for config files
93 .for etc in ${ETC}
94 ${etc}: ${NETBSDSRCDIR}/etc/${etc}
95 ${INSTALL} $> $@
96 .endfor
98 # LSC Force the regeneration of the proto file as it seems sometimes
99 # they are not copied over as needed.
100 # LSC The test is needed; otherwise install complains about src and dst
101 # being the same, during in-tree builds
102 # LSC ramdisk rc file != /etc/rc && mtab not empty!
103 .for file in ${EXTRA} ${PROTO} ${PROTO_FILES}
104 ${file}: ${NETBSDSRCDIR}/drivers/ramdisk/${file} .PHONY
105 [ -e $@ ] || ${INSTALL} $> $@
106 .endfor
108 # Generate dependencies rules for dynamic libraries, if needed
109 .for lib in ${PROG_LIBS}
110 PROGRAMS+= ${lib}.so.0
111 CLEANFILES += ${lib}.so.0
112 ${lib}.so.0:${PROGROOT}/lib/${lib}/${lib}.so.0
113 ${INSTALL} $> $@
115 ${PROGROOT}/lib/${lib}/${lib}.so.0:
116 ${MAKE} -C ${NETBSDSRCDIR}/lib/${lib} all
117 .endfor
119 # Generate dependencies rules for binaries
120 dir.sh:= ash
121 .for srcdir in bin commands drivers libexec servers
122 .for prog in ${PROG_${srcdir:tu}}
123 ${prog}: ${PROGROOT}/${srcdir}/${dir.${prog}:U${prog}}/${prog}
124 ${INSTALL} $> $@
126 ${PROGROOT}/${srcdir}/${dir.${prog}:U${prog}}/${prog}:
127 ${MAKE} -C ${NETBSDSRCDIR}/${srcdir}/${dir.${prog}:U${prog}} all
128 .endfor # prog
129 .endfor # srcdir
131 # We have to do this as a separate loop, because USR.SBIN is not a valid
132 # make variable name.
133 .for prog in ${PROG_USRSBIN}
134 ${prog}: ${PROGROOT}/usr.sbin/${dir.${prog}:U${prog}}/${prog}
135 ${INSTALL} $> $@
137 ${PROGROOT}/usr.sbin/${dir.${prog}:U${prog}}/${prog}:
138 ${MAKE} -C ${NETBSDSRCDIR}/usr.sbin/${dir.${prog}:U${prog}} all
139 .endfor
141 image: proto.gen ${ETC} ${EXTRA} pwd.db spwd.db passwd
142 ${_MKMSG_CREATE} "Generating ramdisk image"
143 ${TOOL_MKFSMFS} image proto.gen || { rm -f image; false; }
144 # if fsck.mfs -s image | grep -q CLEAN; \
145 # then : ; \
146 # else echo "CLEAN sanity check of image failed." ; \
147 # echo "(Perhaps install current mkfs and fsck.)" ; \
148 # rm -f image; false; \
149 # fi
151 etc/master.passwd: ${NETBSDSRCDIR}/etc/master.passwd
152 rm -rf ${.OBJDIR}/etc/
153 mkdir -p ${.OBJDIR}/etc
154 ${INSTALL} $> $@
155 ${TOOL_PWD_MKDB} -V 0 -p -d . etc/master.passwd
157 # LSC We use @F because some version of make still output a full path for @,
158 # even when the target is just a file name
159 pwd.db spwd.db passwd: etc/master.passwd
160 ${INSTALL} etc/${@F} ${@F}
162 proto.gen: ${PROTO} ${PROTO_FILES} ${PROGRAMS}
163 ${STRIP} ${PROGRAMS}
164 # We are using the c preprocessor to generate proto.gen
165 # used in the mkfs tool.
166 ${TOOL_CAT} ${PROTO} | ${HOST_CC} \
167 ${RAMDISK_DEFINES} \
168 -traditional-cpp -E - | grep -v "^$$" | grep -v "#" >${.OBJDIR}/${.TARGET}
170 .include <minix.service.mk>