* Move /kernel to /boot/kernel and /modules to /boot/modules.
[dragonfly.git] / sys / conf / kern.post.mk
CommitLineData
f4e821f3 1# $DragonFly: src/sys/conf/kern.post.mk,v 1.14 2008/09/01 19:39:47 dillon Exp $
edbe133c
SS
2#
3# This Makefile covers the bottom part of the MI build instructions
4#
5
6.PHONY: all modules
7
8all: ${KERNEL}.stripped
9
a7f2f51f 10_MACHINE_FWD= ${.OBJDIR}
49da4741
SS
11.include "$S/conf/kern.fwd.mk"
12
703521da 13depend kernel-depend modules-depend: ${FORWARD_HEADERS_COOKIE}
a7f2f51f 14
edbe133c
SS
15depend: kernel-depend
16clean: kernel-clean
17cleandepend: kernel-cleandepend
18tags: kernel-tags
19install: kernel-install
20reinstall: kernel-reinstall
21
22${KERNEL}.stripped: ${FULLKERNEL}
23 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}.stripped
24
25${FULLKERNEL}: ${SYSTEM_DEP} vers.o
26 @rm -f ${.TARGET}
27 @echo linking ${.TARGET}
28 ${SYSTEM_LD}
29 ${SYSTEM_LD_TAIL}
30
31.if !exists(.depend)
32${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
33.endif
34
35.for mfile in ${MFILES}
36${mfile:T:S/.m$/.h/}: ${mfile}
37 awk -f $S/tools/makeobjops.awk -- -h ${mfile}
38.endfor
39
40kernel-clean:
41 rm -f *.o *.so *.So *.ko *.s eddep errs \
42 ${KERNEL} ${KERNEL}.debug ${KERNEL}.nodebug ${KERNEL}.stripped \
43 linterrs makelinks setdef[01].c setdefs.h tags \
44 vers.c vnode_if.c vnode_if.h \
45 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
46 ${CLEAN}
47
48#lint: /tmp
49# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
0955fd91 50# $S/platform/$P/$M/Locore.c ${CFILES} ioconf.c | \
edbe133c
SS
51# grep -v 'struct/union .* never defined' | \
52# grep -v 'possible pointer alignment problem'
53
0955fd91 54locore.o: $S/platform/$P/$M/locore.s assym.s
edbe133c
SS
55 ${NORMAL_S}
56
57# This is a hack. BFD "optimizes" away dynamic mode if there are no
58# dynamic references. We could probably do a '-Bforcedynamic' mode like
59# in the a.out ld. For now, this works.
60hack.So: Makefile
61 touch hack.c
62 ${CC} -shared -nostdlib hack.c -o hack.So
63 rm -f hack.c
64
65# this rule stops ./assym.s in .depend from causing problems
66./assym.s: assym.s
67
68assym.s: $S/kern/genassym.sh genassym.o
69 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
70
0955fd91
MD
71genassym.o: $S/platform/$P/$M/genassym.c ${FORWARD_HEADERS_COOKIE}
72 ${CC} -c ${CFLAGS:N-fno-common} $S/platform/$P/$M/genassym.c
edbe133c
SS
73
74${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
75
76# The argument list can be very long, use make -V and xargs to
77# pass it to mkdep.
78kernel-depend: assym.s ${BEFORE_DEPEND} \
79 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
80 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
81 rm -f .newdep
82 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
83 mkdep -a -f .newdep ${CFLAGS}
84 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
85 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
86 rm -f .depend
87 mv -f .newdep .depend
88
89kernel-cleandepend:
90 rm -f .depend
91
92links:
93 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
94 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
95 ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
96 sort -u | comm -23 - dontlink | \
97 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
98 sh makelinks && rm -f dontlink
99
100kernel-tags:
101 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
102 sh $S/conf/systags.sh
103 rm -f tags1
104 sed -e 's, ../, ,' tags > tags1
105
9200f41c 106# Note: when moving the existing kernel to .old, it is by default stripped
edbe133c
SS
107# so we do not have two full debug environments sitting in / eating up space.
108#
de45fd49 109kernel-install: kernel-installable
edbe133c
SS
110 @if [ ! -f ${SELECTEDKERNEL} ] ; then \
111 echo "You must build a kernel first." ; \
112 exit 1 ; \
113 fi
588a679c 114. if exists(${DESTDIR}/${DESTKERNNAME})
f2728908
SW
115.ifndef NOFSCHG
116 -chflags noschg ${DESTDIR}/${DESTKERNNAME}
117.endif
9200f41c 118. ifdef NO_KERNEL_OLD_STRIP
588a679c 119 cp -p ${DESTDIR}/${DESTKERNNAME} ${DESTDIR}/${DESTKERNNAME}.old
9200f41c 120. else
588a679c 121 ${OBJCOPY} --strip-debug ${DESTDIR}/${DESTKERNNAME} ${DESTDIR}/${DESTKERNNAME}.old
9200f41c
SS
122. endif
123. endif
f2728908 124.ifdef NOFSCHG
edbe133c 125 ${INSTALL} -m 555 -o root -g wheel \
588a679c 126 ${SELECTEDKERNEL} ${DESTDIR}/${DESTKERNNAME}
edbe133c 127.else
edbe133c 128 ${INSTALL} -m 555 -o root -g wheel -fschg \
588a679c 129 ${SELECTEDKERNEL} ${DESTDIR}/${DESTKERNNAME}
edbe133c
SS
130.endif
131
de45fd49 132kernel-reinstall: kernel-installable
edbe133c
SS
133.ifdef NOFSCHG
134 ${INSTALL} -m 555 -o root -g wheel \
588a679c 135 ${SELECTEDKERNEL} ${DESTDIR}/${DESTKERNNAME}
edbe133c
SS
136.else
137 ${INSTALL} -m 555 -o root -g wheel -fschg \
588a679c 138 ${SELECTEDKERNEL} ${DESTDIR}/${DESTKERNNAME}
edbe133c
SS
139.endif
140
de45fd49
MD
141# Require DESTDIR to be manually specified when installing a
142# virtual kernel.
143#
144kernel-installable:
145.if ${P} == vkernel
146.if !defined(DESTDIR)
147 @echo "When installing a virtual kernel, DESTDIR must be manually specified"
148 @exit 1
149.endif
150.endif
f4e821f3
MD
151 @if [ -f ${DESTDIR}/${CHECKKERNNAME} ]; then \
152 echo "You need to make buildworld, installworld, and upgrade"; \
153 echo "before you can install a new kernel, because the"; \
154 echo "kernel and modules have moved to /boot"; \
155 exit 1; \
156 fi
de45fd49
MD
157 @exit 0
158
edbe133c
SS
159.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
160all: modules
161depend: modules-depend
162clean: modules-clean
163cleandepend: modules-cleandepend
164cleandir: modules-cleandir
165tags: modules-tags
166install: modules-install
167reinstall: modules-reinstall
168.endif
169
170modules:
171 @mkdir -p ${.OBJDIR}
172 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
173 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
174
175modules-depend:
176 @mkdir -p ${.OBJDIR}
177 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
178 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
179
180modules-clean:
181 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
182
183modules-cleandepend:
184 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
185
186# XXX huh?
187#modules-clobber: modules-clean
188# rm -rf ${MKMODULESENV}
189
190modules-cleandir:
191 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
192
193modules-tags:
194 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
195
9200f41c 196# Note: when moving the existing modules to .old, they are by default stripped
edbe133c
SS
197# so we do not have two full debug environments sitting in / eating up space.
198#
199modules-install:
200.if !defined(NO_MODULES_OLD)
9200f41c 201. ifdef NO_KERNEL_OLD_STRIP
f4e821f3 202 set -- ${DESTDIR}/boot/modules/*; \
9200f41c 203 if [ -f "$$1" ]; then \
f4e821f3 204 mkdir -p ${DESTDIR}/boot/modules.old; \
9200f41c 205 for file; do \
f4e821f3 206 cp -p $$file ${DESTDIR}/boot/modules.old; \
9200f41c
SS
207 done; \
208 fi
209. else
f4e821f3 210 set -- ${DESTDIR}/boot/modules/*; \
edbe133c 211 if [ -f "$$1" ]; then \
f4e821f3 212 mkdir -p ${DESTDIR}/boot/modules.old; \
edbe133c 213 for file; do \
f4e821f3 214 ${OBJCOPY} --strip-debug $$file ${DESTDIR}/boot/modules.old/$${file##*/}; \
edbe133c
SS
215 done; \
216 fi
9200f41c 217. endif
edbe133c 218.endif
f4e821f3 219 mkdir -p ${DESTDIR}/boot/modules # Ensure that the modules directory exists!
edbe133c
SS
220 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
221
222modules-reinstall:
223 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
224
225config.o:
226 ${NORMAL_C}
227
228ioconf.o:
229 ${NORMAL_C}
230
231vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
232 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
233
234# XXX strictly, everything depends on Makefile because changes to ${PROF}
235# only appear there, but we don't handle that.
236vers.o:
237 ${NORMAL_C}
238
239#vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
240# awk -f $S/tools/vnode_if.awk -- -c $S/kern/vnode_if.src
241#
242#vnode_if.h: $S/tools/vnode_if.awk $S/kern/vnode_if.src
243# awk -f $S/tools/vnode_if.awk -- -h $S/kern/vnode_if.src
244#
245#vnode_if.o:
246# ${NORMAL_C}
247
248.include "$S/conf/bsd.kern.mk"