If snapshots are disabled and the snapshots directory contains no
[dragonfly.git] / sys / conf / kern.post.mk
blob96dc4e2533d87ce2124448f6a04df36f9664440f
1 # $DragonFly: src/sys/conf/kern.post.mk,v 1.15 2008/09/15 20:09:03 thomas Exp $
2 #
3 # This Makefile covers the bottom part of the MI build instructions
6 .PHONY: all modules
8 all: ${KERNEL}.stripped
10 _MACHINE_FWD= ${.OBJDIR}
11 .include "$S/conf/kern.fwd.mk"
13 depend kernel-depend modules-depend: ${FORWARD_HEADERS_COOKIE}
15 depend: kernel-depend
16 clean: kernel-clean
17 cleandepend: kernel-cleandepend
18 tags: kernel-tags
19 install: kernel-install
20 reinstall: kernel-reinstall
22 ${KERNEL}.stripped: ${FULLKERNEL}
23 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}.stripped
25 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
26 @rm -f ${.TARGET}
27 @echo linking ${.TARGET}
28 ${SYSTEM_LD}
29 ${SYSTEM_LD_TAIL}
31 .if !exists(.depend)
32 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
33 .endif
35 .for mfile in ${MFILES}
36 ${mfile:T:S/.m$/.h/}: ${mfile}
37 awk -f $S/tools/makeobjops.awk -- -h ${mfile}
38 .endfor
40 kernel-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}
48 #lint: /tmp
49 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
50 # $S/platform/$P/$M/Locore.c ${CFILES} ioconf.c | \
51 # grep -v 'struct/union .* never defined' | \
52 # grep -v 'possible pointer alignment problem'
54 locore.o: $S/platform/$P/$M/locore.s assym.s
55 ${NORMAL_S}
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.
60 hack.So: Makefile
61 touch hack.c
62 ${CC} -shared -nostdlib hack.c -o hack.So
63 rm -f hack.c
65 # this rule stops ./assym.s in .depend from causing problems
66 ./assym.s: assym.s
68 assym.s: $S/kern/genassym.sh genassym.o
69 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
71 genassym.o: $S/platform/$P/$M/genassym.c ${FORWARD_HEADERS_COOKIE}
72 ${CC} -c ${CFLAGS:N-fno-common} $S/platform/$P/$M/genassym.c
74 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
76 # The argument list can be very long, use make -V and xargs to
77 # pass it to mkdep.
78 kernel-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
89 kernel-cleandepend:
90 rm -f .depend
92 links:
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
100 kernel-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
106 # Note: when moving the existing kernel to .old, it is by default stripped
107 # so we do not have two full debug environments sitting in / eating up space.
109 kernel-install: kernel-installable
110 @if [ ! -f ${SELECTEDKERNEL} ] ; then \
111 echo "You must build a kernel first." ; \
112 exit 1 ; \
114 . if exists(${DESTDIR}/boot/${DESTKERNNAME})
115 .ifndef NOFSCHG
116 -chflags noschg ${DESTDIR}/boot/${DESTKERNNAME}
117 .endif
118 . ifdef NO_KERNEL_OLD_STRIP
119 cp -p ${DESTDIR}/boot/${DESTKERNNAME} ${DESTDIR}/boot/${DESTKERNNAME}.old
120 . else
121 ${OBJCOPY} --strip-debug ${DESTDIR}/boot/${DESTKERNNAME} ${DESTDIR}/boot/${DESTKERNNAME}.old
122 . endif
123 . endif
124 .ifdef NOFSCHG
125 ${INSTALL} -m 555 -o root -g wheel \
126 ${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
127 .else
128 ${INSTALL} -m 555 -o root -g wheel -fschg \
129 ${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
130 .endif
132 kernel-reinstall: kernel-installable
133 .ifdef NOFSCHG
134 ${INSTALL} -m 555 -o root -g wheel \
135 ${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
136 .else
137 ${INSTALL} -m 555 -o root -g wheel -fschg \
138 ${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
139 .endif
141 # Require DESTDIR to be manually specified when installing a
142 # virtual kernel.
144 kernel-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
151 @if [ -f ${DESTDIR}/${DESTKERNNAME} ]; 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; \
157 @exit 0
159 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
160 all: modules
161 depend: modules-depend
162 clean: modules-clean
163 cleandepend: modules-cleandepend
164 cleandir: modules-cleandir
165 tags: modules-tags
166 install: modules-install
167 reinstall: modules-reinstall
168 .endif
170 modules:
171 @mkdir -p ${.OBJDIR}
172 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
173 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
175 modules-depend:
176 @mkdir -p ${.OBJDIR}
177 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
178 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
180 modules-clean:
181 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
183 modules-cleandepend:
184 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
186 # XXX huh?
187 #modules-clobber: modules-clean
188 # rm -rf ${MKMODULESENV}
190 modules-cleandir:
191 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
193 modules-tags:
194 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
196 # Note: when moving the existing modules to .old, they are by default stripped
197 # so we do not have two full debug environments sitting in / eating up space.
199 modules-install:
200 .if !defined(NO_MODULES_OLD)
201 . ifdef NO_KERNEL_OLD_STRIP
202 set -- ${DESTDIR}/boot/modules/*; \
203 if [ -f "$$1" ]; then \
204 mkdir -p ${DESTDIR}/boot/modules.old; \
205 for file; do \
206 cp -p $$file ${DESTDIR}/boot/modules.old; \
207 done; \
209 . else
210 set -- ${DESTDIR}/boot/modules/*; \
211 if [ -f "$$1" ]; then \
212 mkdir -p ${DESTDIR}/boot/modules.old; \
213 for file; do \
214 ${OBJCOPY} --strip-debug $$file ${DESTDIR}/boot/modules.old/$${file##*/}; \
215 done; \
217 . endif
218 .endif
219 mkdir -p ${DESTDIR}/boot/modules # Ensure that the modules directory exists!
220 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
222 modules-reinstall:
223 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
225 config.o:
226 ${NORMAL_C}
228 ioconf.o:
229 ${NORMAL_C}
231 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
232 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
234 # XXX strictly, everything depends on Makefile because changes to ${PROF}
235 # only appear there, but we don't handle that.
236 vers.o:
237 ${NORMAL_C}
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
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
245 #vnode_if.o:
246 # ${NORMAL_C}
248 .include "$S/conf/bsd.kern.mk"