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