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
132 clobber: kernel-clobber
134 install: kernel-install
135 install.debug: kernel-install.debug
136 reinstall: kernel-reinstall
137 reinstall.debug: kernel-reinstall.debug
140 FULLKERNEL= ${KERNEL_KO}
142 FULLKERNEL= ${KERNEL_KO}.debug
143 ${KERNEL_KO}: ${FULLKERNEL}
144 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
147 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
149 @echo linking ${.TARGET}
154 ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
157 .for mfile in ${MFILES}
158 ${mfile:T:S/.m$/.h/}: ${mfile}
159 perl5 $S/kern/makeobjops.pl -h ${mfile}
163 rm -f *.o *.so *.So *.ko *.s eddep errs \
164 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \
165 setdef[01].c setdefs.h tags \
166 vers.c vnode_if.c vnode_if.h \
167 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
171 find . -type f ! -name version -delete
173 locore.o: $S/$M/$M/locore.s assym.s
176 # This is a hack. BFD "optimizes" away dynamic mode if there are no
177 # dynamic references. We could probably do a '-Bforcedynamic' mode like
178 # in the a.out ld. For now, this works.
181 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
184 .ORDER: setdefs.h setdef0.c setdef1.c
186 setdef0.o: setdef0.c setdefs.h
189 setdef1.o: setdef1.c setdefs.h
192 setdef0.c setdef1.c setdefs.h: Makefile ${OBJS}
193 @OBJDUMP=${OBJDUMP} perl5 $S/kern/gensetdefs.pl ${OBJS}
195 # this rule stops ./assym.s in .depend from causing problems
198 assym.s: $S/kern/genassym.sh genassym.o
199 NM=${NM} sh $S/kern/genassym.sh genassym.o > ${.TARGET}
201 genassym.o: $S/$M/$M/genassym.c
202 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
204 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
208 ${MAKE} _kernel-depend
210 _kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
211 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
212 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
214 CC="${CC}" mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
215 env MKDEP_CPP="${CC} -E" \
216 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
218 mv -f .newdep .depend
224 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
225 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
226 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
227 sort -u | comm -23 - dontlink | \
228 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
229 sh makelinks; rm -f dontlink
232 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
233 sh $S/conf/systags.sh
235 sed -e 's, ../, ,' tags > tags1
237 kernel-install kernel-install.debug:
238 .if exists(${DESTDIR}/boot)
239 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
240 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
243 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
244 echo "You must activate /boot/device.hints in loader.conf." ; \
248 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
249 echo "You must build a kernel first." ; \
252 .if exists(${DESTDIR}${KODIR})
253 .if exists(${DESTDIR}${KODIR}.old)
254 @-chflags -R noschg ${DESTDIR}${KODIR}.old
255 -rm -rf ${DESTDIR}${KODIR}.old
257 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
259 mkdir -p ${DESTDIR}${KODIR}
260 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
261 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
263 install -c -m 555 -o root -g wheel -fschg \
264 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
266 kernel-reinstall kernel-reinstall.debug:
267 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
268 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
270 install -c -m 555 -o root -g wheel -fschg \
271 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
273 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
275 depend: modules-depend
277 cleandepend: modules-cleandepend
278 cleandir: modules-cleandir
279 clobber: modules-clobber
281 install: modules-install
282 install.debug: modules-install.debug
283 reinstall: modules-reinstall
284 reinstall.debug: modules-reinstall.debug
287 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
290 @mkdir -p ${.OBJDIR}/modules
291 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
292 env ${MKMODULESENV} ${MAKE} all
295 @mkdir -p ${.OBJDIR}/modules
296 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
297 env ${MKMODULESENV} ${MAKE} depend
300 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
303 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
305 modules-clobber: modules-clean
306 rm -rf ${MKMODULESENV}
309 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
312 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
314 modules-install modules-install.debug:
315 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
317 modules-reinstall modules-reinstall.debug:
318 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
323 param.c: $S/conf/param.c
330 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
331 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
333 # XXX strictly, everything depends on Makefile because changes to ${PROF}
334 # only appear there, but we don't handle that.
341 vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
342 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
344 vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
345 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
350 .include <bsd.kern.mk>
354 # DO NOT DELETE THIS LINE -- make depend uses it