nrelease - fix/improve livecd
[dragonfly.git] / sys / conf / kern.post.mk
blobf088dad75e50355f9fcdd08a096d79f8566d2a10
2 # This Makefile covers the bottom part of the MI build instructions
5 .PHONY: all modules
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}
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 # 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
31 @rm -f ${.TARGET}
32 @echo linking ${.TARGET}
33 ${SYSTEM_LD}
34 ${SYSTEM_LD_TAIL}
36 .if !exists(.depend)
37 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
38 .endif
40 .for mfile in ${MFILES}
41 ${mfile:T:S/.m$/.h/}: ${mfile}
42 awk -f $S/tools/makeobjops.awk -- -h ${mfile}
43 .endfor
45 kernel-clean:
46 rm -f *.o *.so *.So *.ko *.s errs \
47 ${KERNEL} ${KERNEL}.debug ${KERNEL}.nodebug ${KERNEL}.stripped \
48 tags vers.c \
49 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
50 ${CLEAN}
52 locore.o: $S/platform/$P/$M/locore.s assym.s
53 ${NORMAL_S}
55 # This is a hack. BFD "optimizes" away dynamic mode if there are no
56 # dynamic references. We could probably do a '-Bforcedynamic' mode like
57 # in the a.out ld. For now, this works.
58 hack.So: Makefile
59 touch hack.c
60 ${CC} -shared -nostdlib hack.c -o hack.So
61 rm -f hack.c
63 # this rule stops ./assym.s in .depend from causing problems
64 ./assym.s: assym.s
66 assym.s: $S/kern/genassym.sh genassym.o
67 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
69 genassym.o: $S/platform/$P/$M/genassym.c ${FORWARD_HEADERS_COOKIE} \
70 ${MFILES:T:S/.m$/.h/}
71 ${CC} -c ${CFLAGS:N-fno-common:N-flto:N-mcmodel=small} -fcommon \
72 ${WERROR} $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 .if defined(FASTER_DEPEND)
82 .if exists(hack.So)
83 @cat ${SYSTEM_OBJS:M*\.o$:S/.o$/.d/} genassym.d > .depend || \
84 echo "There were missing deps"
85 .endif
86 .else
87 rm -f .newdep
88 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
89 mkdep -a -f .newdep ${CFLAGS}
90 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
91 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
92 rm -f .depend
93 mv -f .newdep .depend
94 .endif
96 kernel-cleandepend:
97 .if defined(FASTER_DEPEND)
98 rm -f *.d
99 .endif
100 rm -f .depend
102 kernel-tags:
103 @[ -f .depend ] || { echo "you must make depend first"; /usr/bin/false; }
104 sh $S/conf/systags.sh
105 rm -f tags1
106 sed -e 's, ../, ,' tags > tags1
108 # Note: when moving the existing kernel to .old, it is by default stripped
109 # so we do not have two full debug environments sitting in / eating up space.
111 # Also note the .old might be a file and not a directory, so we have to
112 # remove it first.
114 kernel-install: kernel-installable
115 @if [ ! -f ${SELECTEDKERNEL} ]; then \
116 echo "You must build a kernel first."; \
117 /usr/bin/false; \
119 @if [ -f ${DESTDIR}${DESTKERNDIR}.old ]; then \
120 rm -f ${DESTDIR}${DESTKERNDIR}.old; \
122 mkdir -p ${DESTDIR}${DESTKERNDIR}.old
123 .if exists(${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME})
124 .ifndef NOFSCHG
125 -chflags noschg ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
126 .endif
127 . ifdef NO_KERNEL_OLD_STRIP
128 cp -p ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME} ${DESTDIR}${DESTKERNDIR}.old/${DESTKERNNAME}
129 . else
130 ${OBJCOPY} --strip-debug ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME} ${DESTDIR}${DESTKERNDIR}.old/${DESTKERNNAME}
131 . endif
132 .endif
133 @if [ -f ${DESTDIR}${DESTKERNDIR} ]; then \
134 chflags noschg ${DESTDIR}${DESTKERNDIR}; \
135 rm -f ${DESTDIR}${DESTKERNDIR}; \
137 mkdir -p ${DESTDIR}${DESTKERNDIR}
138 .ifdef NOFSCHG
139 ${INSTALL} -m 555 -o root -g wheel \
140 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
141 .else
142 ${INSTALL} -m 555 -o root -g wheel -fschg \
143 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
144 .endif
146 kernel-reinstall: kernel-installable
147 mkdir -p ${DESTDIR}${DESTKERNDIR}
148 .ifdef NOFSCHG
149 ${INSTALL} -m 555 -o root -g wheel \
150 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
151 .else
152 ${INSTALL} -m 555 -o root -g wheel -fschg \
153 ${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
154 .endif
156 kernel-installable:
157 @if [ -f ${DESTDIR}/${DESTKERNNAME} ]; then \
158 echo "You need to make buildworld, installworld, and upgrade"; \
159 echo "before you can install a new kernel, because the"; \
160 echo "kernel and modules have moved to /boot"; \
161 /usr/bin/false; \
163 # Skip this step for vkernels
164 .if ${MACHINE_PLATFORM} != vkernel64
165 @if [ ! -f ${DESTDIR}/boot/dloader.rc ]; then \
166 echo "You need to install a new ${DESTDIR}/boot before you"; \
167 echo "can install a new kernel, kernels are now installed"; \
168 echo "into a subdirectory along with their modules."; \
169 echo "You can do this with a buildworld / installworld"; \
170 echo "sequence."; \
171 /usr/bin/false; \
173 .endif
175 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
176 all: modules
177 depend: modules-depend
178 clean: modules-clean
179 cleandepend: modules-cleandepend
180 cleandir: modules-cleandir
181 tags: modules-tags
182 install: modules-install
183 reinstall: modules-reinstall
184 .endif
186 modules:
187 @mkdir -p ${.OBJDIR}
188 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
189 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
191 modules-depend:
192 @mkdir -p ${.OBJDIR}
193 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
194 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
196 modules-clean:
197 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
199 modules-cleandepend:
200 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
202 # XXX huh?
203 #modules-clobber: modules-clean
204 # rm -rf ${MKMODULESENV}
206 modules-cleandir:
207 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
209 modules-tags:
210 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
212 # Note: when moving the existing modules to .old, they are by default stripped
213 # so we do not have two full debug environments sitting in / eating up space.
215 # We may have to remove deprecated kernel.old files before we can create
216 # the kernel.old directory.
218 modules-install: kernel-installable
219 .if !defined(NO_MODULES_OLD)
220 . ifdef NO_KERNEL_OLD_STRIP
221 set -- ${DESTDIR}${DESTKERNDIR}/*.ko; \
222 if [ -f "$$1" ]; then \
223 if [ -f ${DESTDIR}${DESTKERNDIR}.old ]; then \
224 rm -f ${DESTDIR}${DESTKERNDIR}.old; \
225 fi; \
226 mkdir -p ${DESTDIR}${DESTKERNDIR}.old; \
227 for file; do \
228 cp -p $$file ${DESTDIR}${DESTKERNDIR}.old; \
229 done; \
231 . else
232 set -- ${DESTDIR}${DESTKERNDIR}/*.ko; \
233 if [ -f "$$1" ]; then \
234 if [ -f ${DESTDIR}${DESTKERNDIR}.old ]; then \
235 rm -f ${DESTDIR}${DESTKERNDIR}.old; \
236 fi; \
237 mkdir -p ${DESTDIR}${DESTKERNDIR}.old; \
238 for file; do \
239 ${OBJCOPY} --strip-debug $$file ${DESTDIR}${DESTKERNDIR}.old/$${file##*/}; \
240 done; \
242 . endif
243 if [ -f ${DESTDIR}${DESTKERNDIR}/initrd.img ]; then \
244 cp -p ${DESTDIR}${DESTKERNDIR}/initrd.img ${DESTDIR}${DESTKERNDIR}.old; \
246 if [ -f ${DESTDIR}${DESTKERNDIR}/initrd.img.gz ]; then \
247 cp -p ${DESTDIR}${DESTKERNDIR}/initrd.img.gz ${DESTDIR}${DESTKERNDIR}.old; \
249 .endif
250 .if exists(${DESTDIR}/${OLDMODULESDIR})
251 rm -rf ${DESTDIR}/${OLDMODULESDIR} # remove deprecated
252 .endif
253 mkdir -p ${DESTDIR}${DESTKERNDIR} # Ensure that the modules directory exists!
254 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
256 modules-reinstall:
257 mkdir -p ${DESTDIR}/${DESTKERNDIR} # Ensure that the modules directory exists!
258 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
260 config.o:
261 ${NORMAL_C} ${WERROR}
263 ioconf.o:
264 ${NORMAL_C} ${WERROR}
266 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
267 sh $S/conf/newvers.sh $S/..
269 vers.o:
270 ${NORMAL_C} ${WERROR}
272 .include "$S/conf/bsd.kern.mk"