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.27 2006/01/06 15:49:01 joerg 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 # -DINSTALLSTRIPPED If debug options are present, install a
21 # stripped kernel rather then the full debug
24 # -DDESTDIR Where to install, defaults to /
26 # Which version of config(8) is required.
29 # Can be overridden by makeoptions or /etc/make.conf
33 # build this target if none is specified on the command line
49 .if !defined(NO_CPU_COPTFLAGS)
50 COPTFLAGS+= ${_CPUCFLAGS}
52 # don't use -I- so we can use proper source-relative locality for local
54 INCLUDES= -nostdinc -I. -I$S
55 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
56 .if exists($S/../include)
57 INCLUDES+= -I$S/../include
59 INCLUDES+= -I/usr/include
62 # This hack lets us use the Intel ACPICA code without spamming a new
63 # include path into 100+ source files.
64 .include "$S/conf/acpi.mk"
65 INCLUDES+= -I${.OBJDIR} -I"$S/${OSACPI_MI_DIR}" -I"$S/${ACPICA_DIR}/include"
67 # This hack lets us use the ipfilter code without spamming a new
68 # include path into 100+ source files.
69 INCLUDES+= -I$S/contrib/ipfilter
71 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
72 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
74 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
75 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
79 CFLAGS+= -falign-functions=16
81 IDENT+= -DGPROF4 -DGUPROF
82 PROF+= -mprofiler-epilogue
86 # Put configuration-specific C flags last (except for ${PROF}) so that they
87 # can override the others.
88 CFLAGS+= ${CONF_CFLAGS}
90 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
91 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
92 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
93 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
95 NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
96 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
98 GEN_CFILES= $S/$M/$M/genassym.c
99 SYSTEM_CFILES= ioconf.c config.c
100 SYSTEM_SFILES= $S/$M/$M/locore.s
101 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
102 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
103 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
104 -export-dynamic -dynamic-linker /red/herring \
105 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
106 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
107 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
108 SYSTEM_DEP+= $S/conf/ldscript.$M
124 all: ${KERNEL}.stripped
126 depend: kernel-depend
128 cleandepend: kernel-cleandepend
130 install: kernel-install
131 reinstall: kernel-reinstall
133 # Normalize output files to make it absolutely crystal clear to
134 # anyone examining the build directory.
137 FULLKERNEL= ${KERNEL}.debug
138 .if defined(INSTALLSTRIPPED)
139 SELECTEDKERNEL= ${KERNEL}.stripped
141 SELECTEDKERNEL= ${KERNEL}.debug
144 FULLKERNEL= ${KERNEL}.nodebug
145 SELECTEDKERNEL= ${KERNEL}.stripped
148 ${KERNEL}.stripped: ${FULLKERNEL}
149 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}.stripped
151 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
153 @echo linking ${.TARGET}
158 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
161 .for mfile in ${MFILES}
162 ${mfile:T:S/.m$/.h/}: ${mfile}
163 awk -f $S/tools/makeobjops.awk -- -h ${mfile}
167 rm -f *.o *.so *.So *.ko *.s eddep errs \
168 ${KERNEL} ${KERNEL}.debug ${KERNEL}.nodebug ${KERNEL}.stripped \
169 linterrs makelinks setdef[01].c setdefs.h tags \
170 vers.c vnode_if.c vnode_if.h \
171 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
175 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
176 # $S/$M/$M/Locore.c ${CFILES} ioconf.c | \
177 # grep -v 'struct/union .* never defined' | \
178 # grep -v 'possible pointer alignment problem'
180 locore.o: $S/$M/$M/locore.s assym.s
183 # This is a hack. BFD "optimizes" away dynamic mode if there are no
184 # dynamic references. We could probably do a '-Bforcedynamic' mode like
185 # in the a.out ld. For now, this works.
188 ${CC} -shared -nostdlib hack.c -o hack.So
191 # this rule stops ./assym.s in .depend from causing problems
194 assym.s: $S/kern/genassym.sh genassym.o
195 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
197 genassym.o: $S/$M/$M/genassym.c
198 ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
200 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
202 # The argument list can be very long, use make -V and xargs to
204 kernel-depend: assym.s ${BEFORE_DEPEND} \
205 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
206 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
208 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
209 mkdep -a -f .newdep ${CFLAGS}
210 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
211 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
213 mv -f .newdep .depend
219 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
220 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
221 ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
222 sort -u | comm -23 - dontlink | \
223 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
224 sh makelinks && rm -f dontlink
227 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
228 sh $S/conf/systags.sh
230 sed -e 's, ../, ,' tags > tags1
232 # Note: when moving the existing kernel to .old, make sure it is stripped
233 # so we do not have two full debug environments sitting in / eating up space.
236 @if [ ! -f ${SELECTEDKERNEL} ] ; then \
237 echo "You must build a kernel first." ; \
241 .if exists(${DESTDIR}/${KERNEL})
242 ${OBJCOPY} --strip-debug ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
244 ${INSTALL} -m 555 -o root -g wheel \
245 ${SELECTEDKERNEL} ${DESTDIR}/${KERNEL}
247 .if exists(${DESTDIR}/${KERNEL})
248 -chflags noschg ${DESTDIR}/${KERNEL}
249 ${OBJCOPY} --strip-debug ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
251 ${INSTALL} -m 555 -o root -g wheel -fschg \
252 ${SELECTEDKERNEL} ${DESTDIR}/${KERNEL}
257 ${INSTALL} -m 555 -o root -g wheel \
258 ${SELECTEDKERNEL} ${DESTDIR}/${KERNEL}
260 ${INSTALL} -m 555 -o root -g wheel -fschg \
261 ${SELECTEDKERNEL} ${DESTDIR}/${KERNEL}
264 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
266 depend: modules-depend
268 cleandepend: modules-cleandepend
269 cleandir: modules-cleandir
271 install: modules-install
272 reinstall: modules-reinstall
275 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
276 .if defined(MODULES_OVERRIDE)
277 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
280 MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
282 .if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
283 MKMODULESENV+= INSTALLSTRIPPEDMODULES=1
285 MKMODULESENV+= MACHINE=i386
289 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
290 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
294 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
295 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
298 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
301 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
304 #modules-clobber: modules-clean
305 # rm -rf ${MKMODULESENV}
308 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
311 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
313 # Note: when moving the existing modules to .old, make sure they are stripped
314 # so we do not have two full debug environments sitting in / eating up space.
317 .if !defined(NO_MODULES_OLD)
318 set -- ${DESTDIR}/modules/*; \
319 if [ -f "$$1" ]; then \
320 mkdir -p ${DESTDIR}/modules.old; \
322 ${OBJCOPY} --strip-debug $$file ${DESTDIR}/modules.old/$${file##*/}; \
326 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
329 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
337 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
338 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
340 # XXX strictly, everything depends on Makefile because changes to ${PROF}
341 # only appear there, but we don't handle that.
345 #vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
346 # awk -f $S/tools/vnode_if.awk -- -c $S/kern/vnode_if.src
348 #vnode_if.h: $S/tools/vnode_if.awk $S/kern/vnode_if.src
349 # awk -f $S/tools/vnode_if.awk -- -h $S/kern/vnode_if.src
354 .include "$S/conf/bsd.kern.mk"
358 # DO NOT DELETE THIS LINE -- make depend uses it