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.10 2005/09/25 15:30:26 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
26 # build this target if none is specified on the command line
42 .if !defined(NO_CPU_COPTFLAGS)
43 COPTFLAGS+= ${_CPUCFLAGS}
45 # don't use -I- so we can use proper source-relative locality for local
47 INCLUDES= -nostdinc -I. -I$S
48 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
49 .if exists($S/../include)
50 INCLUDES+= -I$S/../include
52 INCLUDES+= -I/usr/include
55 # This hack lets us use the Intel ACPICA code without spamming a new
56 # include path into 100+ source files.
57 .include "$S/conf/acpi.mk"
58 INCLUDES+= -I${.OBJDIR} -I"$S/${OSACPI_MI_DIR}" -I"$S/${ACPICA_DIR}/include"
60 # This hack lets us use the ipfilter code without spamming a new
61 # include path into 100+ source files.
62 INCLUDES+= -I$S/contrib/ipfilter
64 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
65 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
67 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
68 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
72 CFLAGS+= -falign-functions=16
74 IDENT+= -DGPROF4 -DGUPROF
75 PROF+= -mprofiler-epilogue
79 # Put configuration-specific C flags last (except for ${PROF}) so that they
80 # can override the others.
81 CFLAGS+= ${CONF_CFLAGS}
83 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
84 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
85 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
86 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
88 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
89 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
91 GEN_CFILES= $S/$M/$M/genassym.c
92 SYSTEM_CFILES= ioconf.c config.c
93 SYSTEM_SFILES= $S/$M/$M/locore.s
94 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
95 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
96 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
97 -export-dynamic -dynamic-linker /red/herring \
98 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
99 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
100 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
101 SYSTEM_DEP+= $S/conf/ldscript.$M
119 depend: kernel-depend
121 cleandepend: kernel-cleandepend
123 install install.debug: kernel-install
124 reinstall reinstall.debug: kernel-reinstall
127 FULLKERNEL= ${KERNEL}
129 FULLKERNEL= ${KERNEL}.debug
130 ${KERNEL}: ${FULLKERNEL}
131 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}
134 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
136 @echo linking ${.TARGET}
141 ${SYSTEM_OBJS}: ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
144 .for mfile in ${MFILES}
145 ${mfile:T:S/.m$/.h/}: ${mfile}
146 perl5 $S/kern/makeobjops.pl -h ${mfile}
150 rm -f *.o *.so *.So *.ko *.s eddep errs \
151 ${FULLKERNEL} ${KERNEL} linterrs makelinks \
152 setdef[01].c setdefs.h tags \
153 vers.c vnode_if.c vnode_if.h \
154 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
158 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
159 # $S/$M/$M/Locore.c ${CFILES} ioconf.c | \
160 # grep -v 'struct/union .* never defined' | \
161 # grep -v 'possible pointer alignment problem'
163 locore.o: $S/$M/$M/locore.s assym.s
166 # This is a hack. BFD "optimizes" away dynamic mode if there are no
167 # dynamic references. We could probably do a '-Bforcedynamic' mode like
168 # in the a.out ld. For now, this works.
171 ${CC} -shared -nostdlib hack.c -o hack.So
174 # this rule stops ./assym.s in .depend from causing problems
177 assym.s: $S/kern/genassym.sh genassym.o
178 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
180 genassym.o: $S/$M/$M/genassym.c
181 ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
183 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
185 # The argument list can be very long, use make -V and xargs to
187 kernel-depend: assym.s ${BEFORE_DEPEND} \
188 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
189 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
191 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
192 mkdep -a -f .newdep ${CFLAGS}
193 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
194 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
196 mv -f .newdep .depend
202 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
203 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
204 ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
205 sort -u | comm -23 - dontlink | \
206 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
207 sh makelinks && rm -f dontlink
210 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
211 sh $S/conf/systags.sh
213 sed -e 's, ../, ,' tags > tags1
215 kernel-install kernel-install.debug:
216 @if [ ! -f ${KERNEL}${.TARGET:S/kernel-install//} ] ; then \
217 echo "You must build a kernel first." ; \
220 .if exists(${DESTDIR}/${KERNEL})
221 -chflags noschg ${DESTDIR}/${KERNEL}
222 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
224 ${INSTALL} -m 555 -o root -g wheel -fschg \
225 ${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
227 kernel-reinstall kernel-reinstall.debug:
228 ${INSTALL} -m 555 -o root -g wheel -fschg \
229 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
231 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES)
233 depend: modules-depend
235 cleandepend: modules-cleandepend
236 cleandir: modules-cleandir
238 install install.debug: modules-install
239 reinstall reinstall.debug: modules-reinstall
242 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
243 .if defined(MODULES_OVERRIDE)
244 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
247 MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
249 MKMODULESENV+= MACHINE=amd64
253 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
254 env ${MKMODULESENV} ${MAKE} -f Makefile.modules all
258 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules obj ; \
259 env ${MKMODULESENV} ${MAKE} -f Makefile.modules depend
262 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules clean
265 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandepend
268 #modules-clobber: modules-clean
269 # rm -rf ${MKMODULESENV}
272 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules cleandir
275 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules tags
277 modules-install modules-install.debug:
278 .if !defined(NO_MODULES_OLD)
279 set -- ${DESTDIR}/modules/*; \
280 if [ -f "$$1" ]; then \
281 mkdir -p ${DESTDIR}/modules.old; \
283 ${OBJCOPY} --strip-debug $$file ${DESTDIR}/modules.old/$${file##*/}; \
287 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
289 modules-reinstall modules-reinstall.debug:
290 cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
298 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
299 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
301 # XXX strictly, everything depends on Makefile because changes to ${PROF}
302 # only appear there, but we don't handle that.
306 #vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
307 # perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
309 #vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
310 # perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
315 .include "$S/conf/bsd.kern.mk"
319 # DO NOT DELETE THIS LINE -- make depend uses it