1 # Makefile.i386 -- with config changes.
2 # Copyright 1990 W. Jolitz
3 # from: @(#)Makefile.i386 7.1 5/10/91
4 # $FreeBSD: src/sys/conf/Makefile.i386,v 1.179.2.16 2002/11/18 11:26:49 ru Exp $
5 # $DragonFly: src/sys/conf/Attic/Makefile.i386,v 1.16 2004/08/13 17:51:05 dillon Exp $
7 # Makefile for DragonFly BSD
9 # This makefile is constructed from a machine description:
11 # Most changes should be made in the machine description
12 # /sys/i386/conf/``machineid''
13 # after which you should do
15 # Generic makefile changes should be made in
16 # /sys/conf/Makefile.i386
17 # after which config should be rerun for all machines.
20 # Which version of config(8) is required.
23 # Can be overridden by makeoptions or /etc/make.conf
40 .if !defined(NO_CPU_COPTFLAGS)
41 COPTFLAGS+= ${_CPUCFLAGS}
43 # don't use -I- so we can use proper source-relative locality for local
45 INCLUDES= -nostdinc -I. -I$S
46 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
47 .if exists($S/../include)
48 INCLUDES+= -I$S/../include
50 INCLUDES+= -I/usr/include
53 # This hack lets us use the Intel ACPICA code without spamming a new
54 # include path into 100+ source files.
55 INCLUDES+= -I$S/contrib/dev/acpica
59 # This hack lets us use the ipfilter code without spamming a new
60 # include path into 100+ source files.
61 INCLUDES+= -I$S/contrib/ipfilter
63 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
64 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
66 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
67 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
71 CFLAGS+= -malign-functions=4
73 IDENT+= -DGPROF4 -DGUPROF
74 PROF+= -mprofiler-epilogue
78 # Put configuration-specific C flags last (except for ${PROF}) so that they
79 # can override the others.
80 CFLAGS+= ${CONF_CFLAGS}
82 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
83 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
84 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
85 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
87 NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
88 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
90 GEN_CFILES= $S/$M/$M/genassym.c
91 SYSTEM_CFILES= ioconf.c config.c
92 SYSTEM_SFILES= $S/$M/$M/locore.s
93 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
94 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
95 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
96 -export-dynamic -dynamic-linker /red/herring \
97 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
98 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
99 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
100 SYSTEM_DEP+= $S/conf/ldscript.$M
118 depend: kernel-depend
120 cleandepend: kernel-cleandepend
122 install install.debug: kernel-install
123 reinstall reinstall.debug: kernel-reinstall
126 FULLKERNEL= ${KERNEL}
128 FULLKERNEL= ${KERNEL}.debug
129 ${KERNEL}: ${FULLKERNEL}
130 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}
133 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
135 @echo linking ${.TARGET}
140 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
143 .for mfile in ${MFILES}
144 ${mfile:T:S/.m$/.h/}: ${mfile}
145 awk -f $S/tools/makeobjops.awk -- -h ${mfile}
149 rm -f *.o *.so *.So *.ko *.s eddep errs \
150 ${FULLKERNEL} ${KERNEL} linterrs makelinks \
151 setdef[01].c setdefs.h tags \
152 vers.c vnode_if.c vnode_if.h \
153 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
157 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
158 # $S/$M/$M/Locore.c ${CFILES} ioconf.c | \
159 # grep -v 'struct/union .* never defined' | \
160 # grep -v 'possible pointer alignment problem'
162 locore.o: $S/$M/$M/locore.s assym.s
165 # This is a hack. BFD "optimizes" away dynamic mode if there are no
166 # dynamic references. We could probably do a '-Bforcedynamic' mode like
167 # in the a.out ld. For now, this works.
170 ${CC} -shared -nostdlib hack.c -o hack.So
173 # this rule stops ./assym.s in .depend from causing problems
176 assym.s: $S/kern/genassym.sh genassym.o
177 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
179 genassym.o: $S/$M/$M/genassym.c
180 ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
182 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
184 # The argument list can be very long, use make -V and xargs to
186 kernel-depend: assym.s ${BEFORE_DEPEND} \
187 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
188 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
190 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
191 mkdep -a -f .newdep ${CFLAGS}
192 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
193 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
195 mv -f .newdep .depend
201 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
202 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
203 ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
204 sort -u | comm -23 - dontlink | \
205 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
206 sh makelinks && rm -f dontlink
209 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
210 sh $S/conf/systags.sh
212 sed -e 's, ../, ,' tags > tags1
214 kernel-install kernel-install.debug:
215 @if [ ! -f ${KERNEL}${.TARGET:S/kernel-install//} ] ; then \
216 echo "You must build a kernel first." ; \
219 .if exists(${DESTDIR}/${KERNEL})
220 -chflags noschg ${DESTDIR}/${KERNEL}
221 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
223 ${INSTALL} -m 555 -o root -g wheel -fschg \
224 ${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
226 kernel-reinstall kernel-reinstall.debug:
227 ${INSTALL} -m 555 -o root -g wheel -fschg \
228 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
230 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
232 depend: modules-depend
234 cleandepend: modules-cleandepend
235 cleandir: modules-cleandir
237 install install.debug: modules-install
238 reinstall reinstall.debug: modules-reinstall
241 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}
242 .if defined(MODULES_OVERRIDE)
243 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
246 MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
248 MKMODULESENV+= MACHINE=i386
252 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
253 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
257 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
258 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
261 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
264 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
267 #modules-clobber: modules-clean
268 # rm -rf ${MKMODULESENV}
271 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
274 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
276 modules-install modules-install.debug:
277 .if !defined(NO_MODULES_OLD)
278 if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
279 mkdir -p ${DESTDIR}/modules.old; \
280 cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \
283 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
285 modules-reinstall modules-reinstall.debug:
286 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
294 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
295 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
297 # XXX strictly, everything depends on Makefile because changes to ${PROF}
298 # only appear there, but we don't handle that.
302 #vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
303 # awk -f $S/tools/vnode_if.awk -- -c $S/kern/vnode_if.src
305 #vnode_if.h: $S/tools/vnode_if.awk $S/kern/vnode_if.src
306 # awk -f $S/tools/vnode_if.awk -- -h $S/kern/vnode_if.src
311 .include "$S/conf/bsd.kern.mk"
315 # DO NOT DELETE THIS LINE -- make depend uses it