Fully synchronize sys/boot from FreeBSD-5.x, but add / to the module path
[dragonfly.git] / sys / conf / Makefile.pc98
... / ...
CommitLineData
1# Makefile for FreeBSD(98) after:
2#
3# Makefile.i386 -- with config changes.
4# Copyright 1990 W. Jolitz
5# from: @(#)Makefile.i386 7.1 5/10/91
6# $FreeBSD: src/sys/conf/Makefile.pc98,v 1.82.2.17 2002/11/18 11:26:49 ru Exp $
7# $DragonFly: src/sys/conf/Attic/Makefile.pc98,v 1.3 2003/11/10 06:12:03 dillon Exp $
8#
9# Makefile for FreeBSD
10#
11# This makefile is constructed from a machine description:
12# config machineid
13# Most changes should be made in the machine description
14# /sys/pc98/conf/``machineid''
15# after which you should do
16# config machineid
17# Generic makefile changes should be made in
18# /sys/conf/Makefile.pc98
19# after which config should be rerun for all machines.
20#
21
22# Which version of config(8) is required.
23%VERSREQ= 400019
24
25# Can be overridden by makeoptions or /etc/make.conf
26KERNEL?= kernel
27#STD8X16FONT?= iso
28
29.if !defined(S)
30.if exists(./@/.)
31S= ./@
32.else
33S= ../..
34.endif
35.endif
36M= ${MACHINE_ARCH}
37
38SIZE?= size
39OBJCOPY?= objcopy
40
41COPTFLAGS?=-O -pipe
42.if !defined(NO_CPU_COPTFLAGS)
43COPTFLAGS+= ${_CPUCFLAGS}
44.endif
45INCLUDES= -nostdinc -I- -I. -I$S
46# This hack is to allow kernel compiles to succeed on machines w/out srcdist
47.if exists($S/../include)
48INCLUDES+= -I$S/../include
49.else
50INCLUDES+= -I/usr/include
51.endif
52
53# This hack lets us use the ipfilter code without spamming a new
54# include path into 100+ source files.
55INCLUDES+= -I$S/contrib/ipfilter
56
57COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
58CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
59
60# XXX LOCORE means "don't declare C stuff" not "for locore.s".
61ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
62
63DEFINED_PROF= ${PROF}
64.if defined(PROF)
65CFLAGS+= -malign-functions=4
66.if ${PROFLEVEL} >= 2
67IDENT+= -DGPROF4 -DGUPROF
68PROF+= -mprofiler-epilogue
69.endif
70.endif
71
72# Put configuration-specific C flags last (except for ${PROF}) so that they
73# can override the others.
74CFLAGS+= ${CONF_CFLAGS}
75
76NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
77NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
78NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
79PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
80
81GEN_CFILES= $S/$M/$M/genassym.c
82SYSTEM_CFILES= ioconf.c vnode_if.c config.c
83SYSTEM_SFILES= $S/$M/$M/locore.s
84SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
85SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o config.o hack.So
86SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
87 -export-dynamic -dynamic-linker /red/herring \
88 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
89SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
90 ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
91SYSTEM_DEP+= $S/conf/ldscript.$M
92
93%BEFORE_DEPEND
94
95%OBJS
96
97%CFILES
98
99%SFILES
100
101%MFILES
102
103%CLEAN
104
105.PHONY: all modules
106
107all: ${KERNEL}
108
109depend: kernel-depend
110clean: kernel-clean
111cleandepend: kernel-cleandepend
112tags: kernel-tags
113install install.debug: kernel-install
114reinstall reinstall.debug: kernel-reinstall
115
116.if !defined(DEBUG)
117FULLKERNEL= ${KERNEL}
118.else
119FULLKERNEL= ${KERNEL}.debug
120${KERNEL}: ${FULLKERNEL}
121 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL}
122.endif
123
124${FULLKERNEL}: ${SYSTEM_DEP} vers.o
125 @rm -f ${.TARGET}
126 @echo linking ${.TARGET}
127 ${SYSTEM_LD}
128 ${SYSTEM_LD_TAIL}
129
130.if !exists(.depend)
131${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h}
132.endif
133
134kernel-clean:
135 rm -f *.o *.so *.So *.ko *.s eddep errs \
136 ${FULLKERNEL} ${KERNEL} linterrs makelinks \
137 setdef[01].c setdefs.h tags \
138 vers.c vnode_if.c vnode_if.h ${CLEAN}
139
140#lint: /tmp
141# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
142# $S/$M/$M/Locore.c ${CFILES} ioconf.c | \
143# grep -v 'struct/union .* never defined' | \
144# grep -v 'possible pointer alignment problem'
145
146locore.o: $S/$M/$M/locore.s assym.s
147 ${NORMAL_S}
148
149# This is a hack. BFD "optimizes" away dynamic mode if there are no
150# dynamic references. We could probably do a '-Bforcedynamic' mode like
151# in the a.out ld. For now, this works.
152hack.So: Makefile
153 touch hack.c
154 ${CC} -shared -nostdlib hack.c -o hack.So
155 rm -f hack.c
156
157# this rule stops ./assym.s in .depend from causing problems
158./assym.s: assym.s
159
160assym.s: $S/kern/genassym.sh genassym.o
161 sh $S/kern/genassym.sh genassym.o > ${.TARGET}
162
163genassym.o: $S/$M/$M/genassym.c
164 rm -f ./machine ; ln -s $S/$M/include ./machine
165 ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
166
167${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
168
169# The argument list can be very long, use make -V and xargs to
170# pass it to mkdep.
171kernel-depend: assym.s vnode_if.h ${BEFORE_DEPEND} \
172 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} ${SYSTEM_SFILES}
173 rm -f .newdep
174 ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \
175 mkdep -a -f .newdep ${CFLAGS}
176 ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \
177 env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS}
178 rm -f .depend
179 mv -f .newdep .depend
180
181kernel-cleandepend:
182 rm -f .depend
183
184links:
185 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
186 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
187 ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
188 sort -u | comm -23 - dontlink | \
189 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
190 sh makelinks && rm -f dontlink
191
192kernel-tags:
193 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
194 sh $S/conf/systags.sh
195 rm -f tags1
196 sed -e 's, ../, ,' tags > tags1
197
198kernel-install kernel-install.debug:
199 @if [ ! -f ${KERNEL}${.TARGET:S/kernel-install//} ] ; then \
200 echo "You must build a kernel first." ; \
201 exit 1 ; \
202 fi
203.if exists(${DESTDIR}/${KERNEL})
204 -chflags noschg ${DESTDIR}/${KERNEL}
205 mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
206.endif
207 ${INSTALL} -m 555 -o root -g wheel -fschg \
208 ${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
209
210kernel-reinstall kernel-reinstall.debug:
211 ${INSTALL} -m 555 -o root -g wheel -fschg \
212 ${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
213
214.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
215all: modules
216depend: modules-depend
217clean: modules-clean
218cleandepend: modules-cleandepend
219cleandir: modules-cleandir
220tags: modules-tags
221install install.debug: modules-install
222reinstall reinstall.debug: modules-reinstall
223.endif
224
225MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules
226.if defined(MODULES_OVERRIDE)
227MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
228.endif
229.if defined(DEBUG)
230MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
231.endif
232MKMODULESENV+= MACHINE=pc98
233
234modules:
235 @mkdir -p ${.OBJDIR}/modules
236 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
237 env ${MKMODULESENV} ${MAKE} all
238
239modules-depend:
240 @mkdir -p ${.OBJDIR}/modules
241 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
242 env ${MKMODULESENV} ${MAKE} depend
243
244modules-clean:
245 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
246
247modules-cleandepend:
248 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
249
250modules-clobber: modules-clean
251 rm -rf ${MKMODULESENV}
252
253modules-cleandir:
254 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
255
256modules-tags:
257 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
258
259modules-install modules-install.debug:
260.if !defined(NO_MODULES_OLD)
261 if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
262 mkdir -p ${DESTDIR}/modules.old; \
263 cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \
264 fi;
265.endif
266 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
267
268modules-reinstall modules-reinstall.debug:
269 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
270
271config.o:
272 ${NORMAL_C}
273
274ioconf.o:
275 ${NORMAL_C}
276
277vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
278 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
279
280# XXX strictly, everything depends on Makefile because changes to ${PROF}
281# only appear there, but we don't handle that.
282vers.o:
283 ${NORMAL_C}
284
285vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
286 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
287
288vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
289 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
290
291vnode_if.o:
292 ${NORMAL_C}
293
294# Commented out for now pending a better solution.
295# How do we pick up compiler version specific flags??
296#.if exists($S/../share/mk)
297#.include "$S/../share/mk/bsd.kern.mk"
298#.else
299.include <bsd.kern.mk>
300#.endif
301
302%RULES
303
304# DO NOT DELETE THIS LINE -- make depend uses it