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