1 # Makefile.ia64 -- with config changes.
2 # Copyright 1990 W. Jolitz
3 # from: src/sys/conf/Makefile.alpha,v 1.76
8 # This makefile is constructed from a machine description:
10 # Most changes should be made in the machine description
11 # /sys/ia64/conf/``machineid''
12 # after which you should do
14 # after which config should be rerun for all machines.
17 # The Linux cross tools don't understand -fformat-extensions
18 CWARNFLAGS= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
19 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
21 CC= ia64-unknown-linux-gcc -D__FreeBSD__ -U__linux__
22 LD= ia64-unknown-linux-ld
23 NM= ia64-unknown-linux-nm
24 SIZE= ia64-unknown-linux-size
25 OBJCOPY= ia64-unknown-linux-objcopy
26 OBJDUMP= ia64-unknown-linux-objdump
29 # Which version of config(8) is required.
32 # Can be overridden by makeoptions or /etc/make.conf
35 KODIR?= /boot/${KERNEL}
51 INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
52 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
53 .if exists($S/../include)
54 INCLUDES+= -I$S/../include
56 INCLUDES+= -I/usr/include
59 # This hack lets us use the Intel ACPICA code without spamming a new
60 # include path into 100+ source files.
61 INCLUDES+= -I$S/contrib/dev/acpica/Subsystem/Include
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 -Wa,-x -DLOCORE ${CFLAGS}
69 # Select the correct set of tools. Can't set OBJFORMAT here because it
70 # doesn't get exported into the environment, and if it were exported
71 # then it might break building of utilities.
77 CFLAGS+= -malign-functions=4
79 IDENT+= -DGPROF4 -DGUPROF
80 PROF+= -mprofiler-epilogue
84 # Put configuration-specific C flags last (except for ${PROF}) so that they
85 # can override the others.
86 CFLAGS+= ${CONF_CFLAGS}
88 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
89 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
90 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
91 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
93 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
94 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
96 GEN_CFILES= $S/$M/$M/genassym.c
97 # setdef0.c and setdef1.c are intentionally
98 # omitted from SYSTEM_CFILES. They include setdefs.h, a header which
99 # is generated from all of ${OBJS}. We don't want to have to compile
100 # everything just to do a make depend.
101 SYSTEM_CFILES= param.c vnode_if.c hints.c config.c
102 SYSTEM_SFILES= $S/$M/$M/locore.s
103 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
104 SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} param.o hints.o config.o \
105 setdef1.o # hack.So ski can't cope with dynamic relocs
106 SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
108 -export-dynamic -dynamic-linker /red/herring \
109 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
110 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
111 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
112 SYSTEM_DEP+= $S/conf/ldscript.$M
129 depend: kernel-depend
131 cleandepend: kernel-cleandepend
133 install: kernel-install
134 install.debug: kernel-install.debug
135 reinstall: kernel-reinstall
136 reinstall.debug: kernel-reinstall.debug
139 FULLKERNEL= ${KERNEL_KO}
141 FULLKERNEL= ${KERNEL_KO}.debug
142 ${KERNEL_KO}: ${FULLKERNEL}
143 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
146 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
148 @echo linking ${.TARGET}
153 ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
156 .for mfile in ${MFILES}
157 ${mfile:T:S/.m$/.h/}: ${mfile}
158 perl5 $S/kern/makeobjops.pl -h ${mfile}
162 rm -f *.o *.so *.So *.ko *.s eddep errs \
163 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \
164 setdef[01].c setdefs.h tags \
165 vers.c vnode_if.c vnode_if.h \
166 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
169 locore.o: $S/$M/$M/locore.s assym.s
172 # This is a hack. BFD "optimizes" away dynamic mode if there are no
173 # dynamic references. We could probably do a '-Bforcedynamic' mode like
174 # in the a.out ld. For now, this works.
177 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
180 .ORDER: setdefs.h setdef0.c setdef1.c
182 setdef0.o: setdef0.c setdefs.h
185 setdef1.o: setdef1.c setdefs.h
188 setdef0.c setdef1.c setdefs.h: Makefile ${OBJS}
189 @OBJDUMP=${OBJDUMP} perl5 $S/kern/gensetdefs.pl ${OBJS}
191 # this rule stops ./assym.s in .depend from causing problems
194 assym.s: $S/kern/genassym.sh genassym.o
195 NM=${NM} sh $S/kern/genassym.sh genassym.o > ${.TARGET}
197 genassym.o: $S/$M/$M/genassym.c
198 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
200 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
202 kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
203 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
204 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
206 CC="${CC}" mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
207 env MKDEP_CPP="${CC} -E" \
208 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
210 mv -f .newdep .depend
216 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
217 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
218 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
219 sort -u | comm -23 - dontlink | \
220 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
221 sh makelinks; rm -f dontlink
224 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
225 sh $S/conf/systags.sh
227 sed -e 's, ../, ,' tags > tags1
229 kernel-install kernel-install.debug:
230 .if exists(${DESTDIR}/boot)
231 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
232 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
235 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
236 echo "You must activate /boot/device.hints in loader.conf." ; \
240 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
241 echo "You must build a kernel first." ; \
244 .if exists(${DESTDIR}${KODIR})
245 .if exists(${DESTDIR}${KODIR}.old)
246 @-chflags -R noschg ${DESTDIR}${KODIR}.old
247 -rm -rf ${DESTDIR}${KODIR}.old
249 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
251 mkdir -p ${DESTDIR}${KODIR}
252 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
253 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
255 install -c -m 555 -o root -g wheel -fschg \
256 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
258 kernel-reinstall kernel-reinstall.debug:
259 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
260 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
262 install -c -m 555 -o root -g wheel -fschg \
263 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
265 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
267 depend: modules-depend
269 cleandepend: modules-cleandepend
270 cleandir: modules-cleandir
272 install: modules-install
273 install.debug: modules-install.debug
274 reinstall: modules-reinstall
275 reinstall.debug: modules-reinstall.debug
278 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
281 @mkdir -p ${.OBJDIR}/modules
282 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
283 env ${MKMODULESENV} ${MAKE} all
286 @mkdir -p ${.OBJDIR}/modules
287 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
288 env ${MKMODULESENV} ${MAKE} depend
291 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
294 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
297 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
300 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
302 modules-install modules-install.debug:
303 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
305 modules-reinstall modules-reinstall.debug:
306 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
311 param.c: $S/conf/param.c
318 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
319 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
321 # XXX strictly, everything depends on Makefile because changes to ${PROF}
322 # only appear there, but we don't handle that.
329 vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
330 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
332 vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
333 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
338 .include <bsd.kern.mk>
342 # DO NOT DELETE THIS LINE -- make depend uses it