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