2 # This Makefile covers the bottom part of the MI build instructions
7 all: ${KERNEL}.stripped
9 _MACHINE_FWD= ${.OBJDIR}
10 .include "$S/conf/kern.fwd.mk"
11 .include "$S/conf/kern.paths.mk"
13 depend kernel-depend modules-depend: ${FORWARD_HEADERS_COOKIE}
17 cleandepend: kernel-cleandepend
19 install: kernel-install
20 reinstall: kernel-reinstall
22 # Often developers just want the kernel, don't let
23 # -j builds leak into the modules until the kernel is done.
25 .ORDER: ${KERNEL}.stripped modules
27 ${KERNEL}.stripped: ${FULLKERNEL}
28 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}.stripped
30 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
32 @echo linking ${.TARGET}
37 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
40 .for mfile in ${MFILES}
41 ${mfile:T:S/.m$/.h/}: ${mfile}
42 awk -f $S/tools/makeobjops.awk -- -h ${mfile}
46 rm -f *.o *.so *.So *.ko *.s eddep errs \
47 ${KERNEL} ${KERNEL}.debug ${KERNEL}.nodebug ${KERNEL}.stripped \
48 linterrs setdef[01].c setdefs.h tags \
49 vers.c vnode_if.c vnode_if.h \
50 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
54 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
55 # $S/platform/$P/$M/Locore.c ${CFILES} ioconf.c | \
56 # grep -v 'struct/union .* never defined' | \
57 # grep -v 'possible pointer alignment problem'
59 locore.o: $S/platform/$P/$M/locore.s assym.s
62 # This is a hack. BFD "optimizes" away dynamic mode if there are no
63 # dynamic references. We could probably do a '-Bforcedynamic' mode like
64 # in the a.out ld. For now, this works.
67 ${CC} -shared -nostdlib hack.c -o hack.So
70 # this rule stops ./assym.s in .depend from causing problems
73 assym.s: $S/kern/genassym.sh genassym.o
74 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
76 genassym.o: $S/platform/$P/$M/genassym.c ${FORWARD_HEADERS_COOKIE} \
78 ${CC} -c ${CFLAGS:N-fno-common:N-mcmodel=small} ${WERROR} \
79 $S/platform/$P/$M/genassym.c
81 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
83 # The argument list can be very long, use make -V and xargs to
85 kernel-depend: assym.s ${BEFORE_DEPEND} \
86 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
87 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
89 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
90 mkdep -a -f .newdep ${CFLAGS}
91 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
92 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
100 @[ -f .depend ] || { echo "you must make depend first"; /usr/bin/false; }
101 sh $S/conf/systags.sh
103 sed -e 's, ../, ,' tags > tags1
105 # Note: when moving the existing kernel to .old, it is by default stripped
106 # so we do not have two full debug environments sitting in / eating up space.
108 # Also note the .old might be a file and not a directory, so we have to
111 kernel-install: kernel-installable
112 @if [ ! -f ${SELECTEDKERNEL} ]; then \
113 echo "You must build a kernel first."; \
116 @if [ -f ${DESTDIR}${DESTKERNDIR}.old ]; then \
117 rm -f ${DESTDIR}${DESTKERNDIR}.old; \
119 mkdir -p ${DESTDIR}${DESTKERNDIR}.old
120 .if exists(${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME})
122 -chflags noschg ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
124 . ifdef NO_KERNEL_OLD_STRIP
125 cp -p ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME} ${DESTDIR}${DESTKERNDIR}.old/${DESTKERNNAME}
127 ${OBJCOPY} --strip-debug ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME} ${DESTDIR}${DESTKERNDIR}.old/${DESTKERNNAME}
130 @if [ -f ${DESTDIR}${DESTKERNDIR} ]; then \
131 chflags noschg ${DESTDIR}${DESTKERNDIR}; \
132 rm -f ${DESTDIR}${DESTKERNDIR}; \
134 mkdir -p ${DESTDIR}${DESTKERNDIR}
136 ${INSTALL} -m 555 -o root -g wheel \
137 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
139 ${INSTALL} -m 555 -o root -g wheel -fschg \
140 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
143 kernel-reinstall: kernel-installable
144 mkdir -p ${DESTDIR}${DESTKERNDIR}
146 ${INSTALL} -m 555 -o root -g wheel \
147 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
149 ${INSTALL} -m 555 -o root -g wheel -fschg \
150 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
154 @if [ -f ${DESTDIR}/${DESTKERNNAME} ]; then \
155 echo "You need to make buildworld, installworld, and upgrade"; \
156 echo "before you can install a new kernel, because the"; \
157 echo "kernel and modules have moved to /boot"; \
160 # Skip this step for vkernels
161 .if ${MACHINE_PLATFORM} != vkernel && ${MACHINE_PLATFORM} != vkernel64
162 @if [ ! -f ${DESTDIR}/boot/dloader.rc ]; then \
163 echo "You need to install a new ${DESTDIR}/boot before you"; \
164 echo "can install a new kernel, kernels are now installed"; \
165 echo "into a subdirectory along with their modules."; \
166 echo "You can do this with a buildworld / installworld"; \
172 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
174 depend: modules-depend
176 cleandepend: modules-cleandepend
177 cleandir: modules-cleandir
179 install: modules-install
180 reinstall: modules-reinstall
185 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
186 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
190 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
191 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
194 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
197 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
200 #modules-clobber: modules-clean
201 # rm -rf ${MKMODULESENV}
204 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
207 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
209 # Note: when moving the existing modules to .old, they are by default stripped
210 # so we do not have two full debug environments sitting in / eating up space.
212 # We may have to remove deprecated kernel.old files before we can create
213 # the kernel.old directory.
215 modules-install: kernel-installable
216 .if !defined(NO_MODULES_OLD)
217 . ifdef NO_KERNEL_OLD_STRIP
218 set -- ${DESTDIR}${DESTKERNDIR}/*.ko; \
219 if [ -f "$$1" ]; then \
220 if [ -f ${DESTDIR}${DESTKERNDIR}.old ]; then \
221 rm -f ${DESTDIR}${DESTKERNDIR}.old; \
223 mkdir -p ${DESTDIR}${DESTKERNDIR}.old; \
225 cp -p $$file ${DESTDIR}${DESTKERNDIR}.old; \
229 set -- ${DESTDIR}${DESTKERNDIR}/*.ko; \
230 if [ -f "$$1" ]; then \
231 if [ -f ${DESTDIR}${DESTKERNDIR}.old ]; then \
232 rm -f ${DESTDIR}${DESTKERNDIR}.old; \
234 mkdir -p ${DESTDIR}${DESTKERNDIR}.old; \
236 ${OBJCOPY} --strip-debug $$file ${DESTDIR}${DESTKERNDIR}.old/$${file##*/}; \
240 if [ -f ${DESTDIR}${DESTKERNDIR}/initrd.img ]; then \
241 cp -p ${DESTDIR}${DESTKERNDIR}/initrd.img ${DESTDIR}${DESTKERNDIR}.old; \
243 if [ -f ${DESTDIR}${DESTKERNDIR}/initrd.img.gz ]; then \
244 cp -p ${DESTDIR}${DESTKERNDIR}/initrd.img.gz ${DESTDIR}${DESTKERNDIR}.old; \
247 .if exists(${DESTDIR}/${OLDMODULESDIR})
248 rm -rf ${DESTDIR}/${OLDMODULESDIR} # remove deprecated
250 mkdir -p ${DESTDIR}${DESTKERNDIR} # Ensure that the modules directory exists!
251 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
254 mkdir -p ${DESTDIR}/${DESTKERNDIR} # Ensure that the modules directory exists!
255 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
258 ${NORMAL_C} ${WERROR}
261 ${NORMAL_C} ${WERROR}
263 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
264 sh $S/conf/newvers.sh $S/..
266 # XXX strictly, everything depends on Makefile because changes to ${PROF}
267 # only appear there, but we don't handle that.
269 ${NORMAL_C} ${WERROR}
271 .include "$S/conf/bsd.kern.mk"