1 # Makefile.amd64 -- with config changes.
2 # Copyright 1990 W. Jolitz
3 # from: @(#)Makefile.i386 7.1 5/10/91
4 # $DragonFly: src/sys/conf/Attic/Makefile.amd64,v 1.5 2005/02/18 11:41:41 corecode Exp $
6 # Makefile for DragonFly BSD
8 # This makefile is constructed from a machine description:
10 # Most changes should be made in the machine description
11 # /sys/amd64/conf/``machineid''
12 # after which you should do
14 # Generic makefile changes should be made in
15 # /sys/conf/Makefile.amd64
16 # after which config should be rerun for all machines.
19 # Which version of config(8) is required.
22 # Can be overridden by makeoptions or /etc/make.conf
39 .if !defined(NO_CPU_COPTFLAGS)
40 COPTFLAGS+= ${_CPUCFLAGS}
42 # don't use -I- so we can use proper source-relative locality for local
44 INCLUDES= -nostdinc -I. -I$S
45 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
46 .if exists($S/../include)
47 INCLUDES+= -I$S/../include
49 INCLUDES+= -I/usr/include
52 # This hack lets us use the Intel ACPICA code without spamming a new
53 # include path into 100+ source files.
54 INCLUDES+= -I$S/contrib/dev/acpica
58 # This hack lets us use the ipfilter code without spamming a new
59 # include path into 100+ source files.
60 INCLUDES+= -I$S/contrib/ipfilter
62 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
63 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
65 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
66 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
70 CFLAGS+= -malign-functions=4
72 IDENT+= -DGPROF4 -DGUPROF
73 PROF+= -mprofiler-epilogue
77 # Put configuration-specific C flags last (except for ${PROF}) so that they
78 # can override the others.
79 CFLAGS+= ${CONF_CFLAGS}
81 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
82 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
83 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
84 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
86 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
87 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
89 GEN_CFILES= $S/$M/$M/genassym.c
90 SYSTEM_CFILES= ioconf.c config.c
91 SYSTEM_SFILES= $S/$M/$M/locore.s
92 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
93 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
94 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
95 -export-dynamic -dynamic-linker /red/herring \
96 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
97 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
98 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
99 SYSTEM_DEP+= $S/conf/ldscript.$M
117 depend: kernel-depend
119 cleandepend: kernel-cleandepend
121 install install.debug: kernel-install
122 reinstall reinstall.debug: kernel-reinstall
125 FULLKERNEL= ${KERNEL}
127 FULLKERNEL= ${KERNEL}.debug
128 ${KERNEL}: ${FULLKERNEL}
129 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}
132 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
134 @echo linking ${.TARGET}
139 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
142 .for mfile in ${MFILES}
143 ${mfile:T:S/.m$/.h/}: ${mfile}
144 perl5 $S/kern/makeobjops.pl -h ${mfile}
148 rm -f *.o *.so *.So *.ko *.s eddep errs \
149 ${FULLKERNEL} ${KERNEL} linterrs makelinks \
150 setdef[01].c setdefs.h tags \
151 vers.c vnode_if.c vnode_if.h \
152 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
156 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
157 # $S/$M/$M/Locore.c ${CFILES} ioconf.c | \
158 # grep -v 'struct/union .* never defined' | \
159 # grep -v 'possible pointer alignment problem'
161 locore.o: $S/$M/$M/locore.s assym.s
164 # This is a hack. BFD "optimizes" away dynamic mode if there are no
165 # dynamic references. We could probably do a '-Bforcedynamic' mode like
166 # in the a.out ld. For now, this works.
169 ${CC} -shared -nostdlib hack.c -o hack.So
172 # this rule stops ./assym.s in .depend from causing problems
175 assym.s: $S/kern/genassym.sh genassym.o
176 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
178 genassym.o: $S/$M/$M/genassym.c
179 ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
181 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
183 # The argument list can be very long, use make -V and xargs to
185 kernel-depend: assym.s ${BEFORE_DEPEND} \
186 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
187 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
189 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
190 mkdep -a -f .newdep ${CFLAGS}
191 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
192 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
194 mv -f .newdep .depend
200 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
201 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
202 ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
203 sort -u | comm -23 - dontlink | \
204 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
205 sh makelinks && rm -f dontlink
208 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
209 sh $S/conf/systags.sh
211 sed -e 's, ../, ,' tags > tags1
213 kernel-install kernel-install.debug:
214 @if [ ! -f ${KERNEL}${.TARGET:S/kernel-install//} ] ; then \
215 echo "You must build a kernel first." ; \
218 .if exists(${DESTDIR}/${KERNEL})
219 -chflags noschg ${DESTDIR}/${KERNEL}
220 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
222 ${INSTALL} -m 555 -o root -g wheel -fschg \
223 ${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
225 kernel-reinstall kernel-reinstall.debug:
226 ${INSTALL} -m 555 -o root -g wheel -fschg \
227 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
229 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
231 depend: modules-depend
233 cleandepend: modules-cleandepend
234 cleandir: modules-cleandir
236 install install.debug: modules-install
237 reinstall reinstall.debug: modules-reinstall
240 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
241 .if defined(MODULES_OVERRIDE)
242 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
245 MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
247 MKMODULESENV+= MACHINE=amd64
251 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
252 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
256 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
257 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
260 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
263 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
266 #modules-clobber: modules-clean
267 # rm -rf ${MKMODULESENV}
270 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
273 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
275 modules-install modules-install.debug:
276 .if !defined(NO_MODULES_OLD)
277 if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
278 mkdir -p ${DESTDIR}/modules.old; \
279 cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \
282 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
284 modules-reinstall modules-reinstall.debug:
285 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
293 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
294 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
296 # XXX strictly, everything depends on Makefile because changes to ${PROF}
297 # only appear there, but we don't handle that.
301 #vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
302 # perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
304 #vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
305 # perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
310 .include "$S/conf/bsd.kern.mk"
314 # DO NOT DELETE THIS LINE -- make depend uses it