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