Don't build sysctl as bootstrap tool. This helps us avoiding FreeBSD 4
[dragonfly.git] / sys / conf / Makefile.pc98
1 # Makefile for DragonFly BSD PC-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.6 2004/08/13 17:51:05 dillon Exp $
8 #
9 # Makefile for DragonFly BSD
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
26 KERNEL?=        kernel
27 #STD8X16FONT?=  iso
28
29 .if !defined(S)
30 .if exists(./@/.)
31 S=      ./@
32 .else
33 S=      ../..
34 .endif
35 .endif
36 M=      ${MACHINE_ARCH}
37
38 SIZE?=          size
39 OBJCOPY?=       objcopy
40
41 COPTFLAGS?=-O -pipe
42 .if !defined(NO_CPU_COPTFLAGS)
43 COPTFLAGS+= ${_CPUCFLAGS}
44 .endif
45 INCLUDES= -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)
48 INCLUDES+= -I$S/../include
49 .else
50 INCLUDES+= -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.
55 INCLUDES+= -I$S/contrib/ipfilter
56
57 COPTS=  ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
58 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
59
60 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
61 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
62
63 DEFINED_PROF=   ${PROF}
64 .if defined(PROF)
65 CFLAGS+=        -malign-functions=4
66 .if ${PROFLEVEL} >= 2
67 IDENT+= -DGPROF4 -DGUPROF
68 PROF+=  -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.
74 CFLAGS+=        ${CONF_CFLAGS}
75
76 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
77 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
78 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
79 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
80
81 GEN_CFILES= $S/$M/$M/genassym.c
82 SYSTEM_CFILES= ioconf.c config.c
83 SYSTEM_SFILES= $S/$M/$M/locore.s
84 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
85 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
86 SYSTEM_LD= @${LD} -Bdynamic -T $S/conf/ldscript.$M \
87         -export-dynamic -dynamic-linker /red/herring \
88         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
89 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
90         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
91 SYSTEM_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
107 all: ${KERNEL}
108
109 depend: kernel-depend
110 clean:  kernel-clean
111 cleandepend:  kernel-cleandepend
112 tags:  kernel-tags
113 install install.debug: kernel-install
114 reinstall reinstall.debug: kernel-reinstall
115
116 .if !defined(DEBUG)
117 FULLKERNEL=     ${KERNEL}
118 .else
119 FULLKERNEL=     ${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}: ${BEFORE_DEPEND:M*.h}
132 .endif
133
134 kernel-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
146 locore.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.
152 hack.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
160 assym.s: $S/kern/genassym.sh genassym.o
161         sh $S/kern/genassym.sh genassym.o > ${.TARGET}
162
163 genassym.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.
171 kernel-depend: assym.s ${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
181 kernel-cleandepend:
182         rm -f .depend
183
184 links:
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
192 kernel-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
198 kernel-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
210 kernel-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)
215 all:    modules
216 depend: modules-depend
217 clean:  modules-clean
218 cleandepend:  modules-cleandepend
219 cleandir:  modules-cleandir
220 tags:  modules-tags
221 install install.debug: modules-install
222 reinstall reinstall.debug: modules-reinstall
223 .endif
224
225 MKMODULESENV=   MAKEOBJDIRPREFIX=${.OBJDIR}/modules
226 .if defined(MODULES_OVERRIDE)
227 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
228 .endif
229 .if defined(DEBUG)
230 MKMODULESENV+=  DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
231 .endif
232 MKMODULESENV+=  MACHINE=pc98
233
234 modules:
235         @mkdir -p ${.OBJDIR}/modules
236         cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
237             env ${MKMODULESENV} ${MAKE} all
238
239 modules-depend:
240         @mkdir -p ${.OBJDIR}/modules
241         cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
242             env ${MKMODULESENV} ${MAKE} depend
243
244 modules-clean:
245         cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
246
247 modules-cleandepend:
248         cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
249
250 modules-clobber:        modules-clean
251         rm -rf ${MKMODULESENV}
252
253 modules-cleandir:
254         cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
255
256 modules-tags:
257         cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
258
259 modules-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
268 modules-reinstall modules-reinstall.debug:
269         cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
270
271 config.o:
272         ${NORMAL_C}
273
274 ioconf.o:
275         ${NORMAL_C}
276
277 vers.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.
282 vers.o:
283         ${NORMAL_C}
284
285 #vnode_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 #
288 #vnode_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 #
291 #vnode_if.o:
292 #       ${NORMAL_C}
293
294 .include "$S/conf/bsd.kern.mk"
295
296 %RULES
297
298 # DO NOT DELETE THIS LINE -- make depend uses it